From ac4730a022c9ed0abf0432e05ba54f4ad4065b10 Mon Sep 17 00:00:00 2001 From: Faris Date: Mon, 26 Jul 2021 05:41:48 +0700 Subject: [PATCH] Add new product thumbnail 2 for e-commerce component --- components/e-commerce/index.ts | 3 +- components/e-commerce/product-thumbnail-2.tsx | 41 +++++++++++++++++++ pages/components/e-commerce.tsx | 20 +++++++-- 3 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 components/e-commerce/product-thumbnail-2.tsx diff --git a/components/e-commerce/index.ts b/components/e-commerce/index.ts index 57a64fb..8f905ba 100644 --- a/components/e-commerce/index.ts +++ b/components/e-commerce/index.ts @@ -1 +1,2 @@ -export {default as ProductThumbnail1} from './product-thumbnail-1' \ No newline at end of file +export {default as ProductThumbnail1} from './product-thumbnail-1' +export {default as ProductThumbnail2} from './product-thumbnail-2' \ No newline at end of file diff --git a/components/e-commerce/product-thumbnail-2.tsx b/components/e-commerce/product-thumbnail-2.tsx new file mode 100644 index 0000000..48eba5d --- /dev/null +++ b/components/e-commerce/product-thumbnail-2.tsx @@ -0,0 +1,41 @@ +import Image from "next/image" +import Link from "next/link" +import { FC } from "react" + +interface IProductThumbnail2Props { + readonly imageUrl?: string + readonly title: string + readonly category?: string + readonly currency?: string + readonly price: number + readonly discountedPrice?: number + readonly href: string +} + +const ProductThumbnail2: FC = ({ imageUrl = '', title, category = '', currency = 'IDR', price = 0, discountedPrice = 0, href }) => ( + +
+ {imageUrl.length > 0 && + {`image`} + } +
+
+
{title}
+ {category.length > 0 &&
{category}
} +
+
+ {discountedPrice > 0 ? ( + <> +
{currency} {discountedPrice.toLocaleString()}
+
{currency} {price.toLocaleString()}
+ + ) : ( +
{currency} {price.toLocaleString()}
+ )} +
+
+
+ +) + +export default ProductThumbnail2 \ No newline at end of file diff --git a/pages/components/e-commerce.tsx b/pages/components/e-commerce.tsx index 5a72a0a..98f85d9 100644 --- a/pages/components/e-commerce.tsx +++ b/pages/components/e-commerce.tsx @@ -1,10 +1,10 @@ -import { ProductThumbnail1 } from "components/e-commerce"; +import { ProductThumbnail1, ProductThumbnail2 } from "components/e-commerce"; import LayoutComponentPreview from "./_layout"; export default function EcommercePreviewPage() { return ( -
+
Product Thumbnail 1
Electronics
@@ -14,7 +14,21 @@ export default function EcommercePreviewPage() { - + +
+
+ +
+
Product Thumbnail 2
+
+
Electronics
+ +
+
+ + + +