summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2022-11-02 12:01:32 +0700
committerIT Fixcomart <it@fixcomart.co.id>2022-11-02 12:01:32 +0700
commit4e1bc974c409cc1707aae5857377c3bd20767ea3 (patch)
tree0308d7dfd9869ae6d3954df0301a76933fcd34d8 /src
parent72fbc1cf1c4768ffbb5028c2c46537732ed89112 (diff)
Add card placeholder
Diffstat (limited to 'src')
-rw-r--r--src/icons/image-placeholder.svg1
-rw-r--r--src/pages/shop/product/[slug].js28
2 files changed, 29 insertions, 0 deletions
diff --git a/src/icons/image-placeholder.svg b/src/icons/image-placeholder.svg
new file mode 100644
index 00000000..935e1097
--- /dev/null
+++ b/src/icons/image-placeholder.svg
@@ -0,0 +1 @@
+<svg 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> \ No newline at end of file
diff --git a/src/pages/shop/product/[slug].js b/src/pages/shop/product/[slug].js
index 82c0fef1..10b4c322 100644
--- a/src/pages/shop/product/[slug].js
+++ b/src/pages/shop/product/[slug].js
@@ -13,6 +13,8 @@ import { LazyLoadImage } from "react-lazy-load-image-component";
import 'swiper/css';
import 'react-lazy-load-image-component/src/effects/blur.css';
+import ImagePlaceholderIcon from '../../../icons/image-placeholder.svg';
+
export async function getServerSideProps(context) {
const { slug } = context.query;
@@ -173,6 +175,32 @@ export default function ProductDetail({product}) {
<Swiper freeMode={true} slidesPerView={2.15} spaceBetween={8} loop={true}>
{similarProducts?.products?.map((product, index) => (<SwiperSlide key={index}><ProductCard data={product} /></SwiperSlide>))}
</Swiper>
+ {similarProducts == null ? (
+ <div className="grid grid-cols-2 gap-x-4">
+ <div role="status" className="p-4 max-w-sm rounded border border-gray-300 shadow animate-pulse md:p-6">
+ <div className="flex justify-center items-center mb-4 h-48 bg-gray-300 rounded">
+ <ImagePlaceholderIcon className="w-12 h-12 text-gray-200" />
+ </div>
+ <div className="h-2 bg-gray-200 rounded-full w-10 mb-1"></div>
+ <div className="h-2.5 bg-gray-200 rounded-full w-full mb-4"></div>
+ <div className="h-2 bg-gray-200 rounded-full mb-2.5"></div>
+ <div className="h-2 bg-gray-200 rounded-full mb-2.5"></div>
+ <div className="h-2 bg-gray-200 rounded-full"></div>
+ <span className="sr-only">Loading...</span>
+ </div>
+ <div role="status" className="p-4 max-w-sm rounded border border-gray-300 shadow animate-pulse md:p-6">
+ <div className="flex justify-center items-center mb-4 h-48 bg-gray-300 rounded">
+ <ImagePlaceholderIcon className="w-12 h-12 text-gray-200" />
+ </div>
+ <div className="h-2 bg-gray-200 rounded-full w-10 mb-1"></div>
+ <div className="h-2.5 bg-gray-200 rounded-full w-full mb-4"></div>
+ <div className="h-2 bg-gray-200 rounded-full mb-2.5"></div>
+ <div className="h-2 bg-gray-200 rounded-full mb-2.5"></div>
+ <div className="h-2 bg-gray-200 rounded-full"></div>
+ <span className="sr-only">Loading...</span>
+ </div>
+ </div>
+ ) : ''}
</div>
</div>