From c5838a2873473440ba9b1bea740b714ae1fb2485 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Sat, 19 Nov 2022 11:13:02 +0700 Subject: brand with infinite scroll and fix product card style --- src/components/Alert.js | 4 ++-- src/components/ProductCard.js | 4 ++-- src/pages/shop/brands.js | 54 +++++++++++++++++++++++++++++++++++++++++++ src/styles/globals.css | 18 ++++++++++----- 4 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 src/pages/shop/brands.js (limited to 'src') diff --git a/src/components/Alert.js b/src/components/Alert.js index 3dddd56e..68fb84b1 100644 --- a/src/components/Alert.js +++ b/src/components/Alert.js @@ -2,10 +2,10 @@ const Alert = ({ children, className, type }) => { let typeClass = ''; switch (type) { case 'info': - typeClass = ' bg-blue-200 text-blue-900 ' + typeClass = ' bg-blue-100 text-blue-900 ' break; case 'success': - typeClass = ' bg-green-200 text-green-900 ' + typeClass = ' bg-green-100 text-green-900 ' break; } return ( diff --git a/src/components/ProductCard.js b/src/components/ProductCard.js index 23cc0665..af96de28 100644 --- a/src/components/ProductCard.js +++ b/src/components/ProductCard.js @@ -10,10 +10,10 @@ export default function ProductCard({ data }) { let product = data; return (
- + {product.variant_total > 1 ? ( -
{product.variant_total} Varian
+
{product.variant_total} Varian
) : ''}
diff --git a/src/pages/shop/brands.js b/src/pages/shop/brands.js new file mode 100644 index 00000000..f39839af --- /dev/null +++ b/src/pages/shop/brands.js @@ -0,0 +1,54 @@ +import { LazyLoadImage } from "react-lazy-load-image-component"; +import Header from "../../components/Header"; +import apiOdoo from "../../helpers/apiOdoo"; +import "react-lazy-load-image-component/src/effects/blur.css"; +import Link from "next/link"; +import { createSlug } from "../../helpers/slug"; +import InfiniteScroll from "react-infinite-scroll-component"; +import { useState } from "react"; +import Spinner from "../../components/Spinner"; + +export async function getServerSideProps() { + let initialManufactures = await apiOdoo('GET', '/api/v1/manufacture?limit=31'); + return {props: {initialManufactures}}; +} + +export default function Brands({ initialManufactures }) { + const [manufactures, setManufactures] = useState(initialManufactures.manufactures); + const [hasMoreManufacture, setHasMoreManufacture] = useState(true); + + const getMoreManufactures = async () => { + const result = await apiOdoo('GET', `/api/v1/manufacture?limit=31&offset=${manufactures.length}`); + if (manufactures.length + 30 >= result.manufacture_total) setHasMoreManufacture(false); + setManufactures((manufactures) => [...manufactures, ...result.manufactures]); + }; + return ( + <> +
+
+

Semua Brand di Indoteknik

+ + +
+ } + > + {manufactures?.map((manufacture, index) => ( + manufacture.name ? ( + + {manufacture.logo ? ( + + ) : manufacture.name} + + ) : '' + ))} + + + + ) +} \ No newline at end of file diff --git a/src/styles/globals.css b/src/styles/globals.css index 2ff05c47..5d741ab4 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -9,6 +9,7 @@ html, body { w-screen text-base text-gray-900 + bg-gray-100 ; } @@ -163,20 +164,25 @@ html, body { } @layer utilities { - .wrap-line-ellipsis-2 { + .wrap-line-ellipsis-1, + .wrap-line-ellipsis-2, + .wrap-line-ellipsis-3 { display: -webkit-box; - -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; } + + .wrap-line-ellipsis-1 { + -webkit-line-clamp: 1; + } + + .wrap-line-ellipsis-2 { + -webkit-line-clamp: 2; + } .wrap-line-ellipsis-3 { - display: -webkit-box; -webkit-line-clamp: 3; - -webkit-box-orient: vertical; - overflow: hidden; - text-overflow: ellipsis; } } -- cgit v1.2.3