From 1e89e64ec0bccbe89b9cede0b2054547d40589fa Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Mon, 22 May 2023 15:27:01 +0700
Subject: Refactor hero banner and popular product section

---
 src/components/skeleton/BannerSkeleton.jsx | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

(limited to 'src/components/skeleton/BannerSkeleton.jsx')

diff --git a/src/components/skeleton/BannerSkeleton.jsx b/src/components/skeleton/BannerSkeleton.jsx
index 3de9c027..7cb3952d 100644
--- a/src/components/skeleton/BannerSkeleton.jsx
+++ b/src/components/skeleton/BannerSkeleton.jsx
@@ -1,19 +1,20 @@
+import useDevice from '@/core/hooks/useDevice'
+import classNames from 'classnames'
+import Skeleton from 'react-loading-skeleton'
+import 'react-loading-skeleton/dist/skeleton.css'
+
 const HeroBannerSkeleton = () => {
+  const { isDesktop, isMobile } = useDevice()
+
+  const deviceClassName = {
+    'min-h-[460px]': isDesktop,
+    'min-h-[230px]': isMobile
+  }
+  const defaultClassName = 'h-full'
+  const combinedClassName = classNames(defaultClassName, deviceClassName)
+
   return (
-    <div role='status' className='animate-pulse h-full min-h-[460px]'>
-      <div className='flex justify-center items-center h-full w-full mb-4 bg-gray-300 rounded' aria-busy>
-        <svg
-          className='w-20 h-20 text-gray-100'
-          xmlns='http://www.w3.org/2000/svg'
-          aria-hidden='true'
-          fill='currentColor'
-          viewBox='0 0 640 512'
-        >
-          <path d='M480 80C480 35.82 515.8 0 560 0C604.2 0 640 35.82 640 80C640 124.2 604.2 160 560 160C515.8 160 480 124.2 480 80zM0 456.1C0 445.6 2.964 435.3 8.551 426.4L225.3 81.01C231.9 70.42 243.5 64 256 64C268.5 64 280.1 70.42 286.8 81.01L412.7 281.7L460.9 202.7C464.1 196.1 472.2 192 480 192C487.8 192 495 196.1 499.1 202.7L631.1 419.1C636.9 428.6 640 439.7 640 450.9C640 484.6 612.6 512 578.9 512H55.91C25.03 512 .0006 486.1 .0006 456.1L0 456.1z' />
-        </svg>
-      </div>
-      <span className='sr-only'>Loading...</span>
-    </div>
+    <Skeleton className={combinedClassName} count={1} containerClassName='w-full h-full block' />
   )
 }
 
-- 
cgit v1.2.3

