From d2950307d013d1a945313592cae75a10166aaf45 Mon Sep 17 00:00:00 2001 From: Faris Date: Sun, 25 Jul 2021 18:58:58 +0700 Subject: [PATCH] Add new component for e-commerce, and add product thumbnail 1 component --- components/e-commerce/index.ts | 1 + components/e-commerce/product-thumbnail-1.tsx | 36 +++++++++++++++++++ pages/components/_layout.tsx | 23 +++++++----- pages/components/e-commerce.tsx | 22 ++++++++++++ 4 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 components/e-commerce/index.ts create mode 100644 components/e-commerce/product-thumbnail-1.tsx create mode 100644 pages/components/e-commerce.tsx diff --git a/components/e-commerce/index.ts b/components/e-commerce/index.ts new file mode 100644 index 0000000..57a64fb --- /dev/null +++ b/components/e-commerce/index.ts @@ -0,0 +1 @@ +export {default as ProductThumbnail1} from './product-thumbnail-1' \ No newline at end of file diff --git a/components/e-commerce/product-thumbnail-1.tsx b/components/e-commerce/product-thumbnail-1.tsx new file mode 100644 index 0000000..14184d6 --- /dev/null +++ b/components/e-commerce/product-thumbnail-1.tsx @@ -0,0 +1,36 @@ +import { Image } from "antd" +import image from "next/image" +import Link from "next/link" +import { FC } from "react" + +interface IProductThumbnail1Props { + readonly imageUrl?: string + readonly title: string + readonly category?: string + readonly currency?: string + readonly price: number + readonly discountedPrice?: number + readonly href: string +} + +const ProductThumbnail1: 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 ProductThumbnail1 \ No newline at end of file diff --git a/pages/components/_layout.tsx b/pages/components/_layout.tsx index c36909e..3c14f01 100644 --- a/pages/components/_layout.tsx +++ b/pages/components/_layout.tsx @@ -9,15 +9,22 @@ const LayoutComponentPreview: FC = ({ children }) => { Component Preview -
-
-
Component Preview
- - -
- +
+
+
+
Component Preview
+ + + +
+ +
+
+ {children} +
-
+ +
{children}
diff --git a/pages/components/e-commerce.tsx b/pages/components/e-commerce.tsx new file mode 100644 index 0000000..5a72a0a --- /dev/null +++ b/pages/components/e-commerce.tsx @@ -0,0 +1,22 @@ +import { ProductThumbnail1 } from "components/e-commerce"; +import LayoutComponentPreview from "./_layout"; + +export default function EcommercePreviewPage() { + return ( + +
+
Product Thumbnail 1
+
+
Electronics
+ +
+
+ + + + +
+
+
+ ) +}