From a0db7911270e1d9a31f45e914e5b73eb25329a3e Mon Sep 17 00:00:00 2001 From: Agustinus Nathaniel Date: Fri, 25 Dec 2020 21:56:53 +0700 Subject: [PATCH] feat: add useAccordion props --- src/components/item/ItemCard.tsx | 78 +++++++++++++++++---------- src/components/item/ItemContainer.tsx | 5 +- src/pages/all.tsx | 4 +- 3 files changed, 56 insertions(+), 31 deletions(-) diff --git a/src/components/item/ItemCard.tsx b/src/components/item/ItemCard.tsx index 7157505..523a972 100644 --- a/src/components/item/ItemCard.tsx +++ b/src/components/item/ItemCard.tsx @@ -22,9 +22,10 @@ import { ListItem } from "../models/list"; type ItemCardProps = { value: ListItem; + useAccordion?: boolean; }; -const ItemCard = ({ value }: ItemCardProps) => { +const ItemCard = ({ value, useAccordion = true }: ItemCardProps) => { const { colorMode } = useColorMode(); const { @@ -37,6 +38,13 @@ const ItemCard = ({ value }: ItemCardProps) => { Link: APILink, } = value; + const apiDetailsProps: APIDetailsProps = { + Cors, + HTTPS, + Category, + Auth, + }; + const toast = useToast(); const handleCopy = () => { @@ -62,33 +70,23 @@ const ItemCard = ({ value }: ItemCardProps) => { {Description} - - - - - Details - - - - - Category: {Category} - Support: - - - HTTPS : - {HTTPS ? ( - - ) : ( - - )} - - - CORS : {Cors} - - {Auth && Auth : {Auth}} - - - + {useAccordion ? ( + + + + + Details + + + + + + + + + ) : ( + + )} API Link: @@ -111,4 +109,28 @@ const ItemCard = ({ value }: ItemCardProps) => { ); }; +type APIDetailsProps = Omit; + +const APIDetails = ({ Category, HTTPS, Cors, Auth }: APIDetailsProps) => { + return ( + <> + Category: {Category} + Support: + + + HTTPS : + {HTTPS ? ( + + ) : ( + + )} + + + CORS : {Cors} + + {Auth && Auth : {Auth}} + + ); +}; + export default ItemCard; diff --git a/src/components/item/ItemContainer.tsx b/src/components/item/ItemContainer.tsx index 32038bf..e405ec3 100644 --- a/src/components/item/ItemContainer.tsx +++ b/src/components/item/ItemContainer.tsx @@ -6,16 +6,17 @@ import { ListItem } from "../models/list"; type ItemContainerProps = { entries: Array; + useAccordion?: boolean; }; -const ItemContainer = ({ entries }: ItemContainerProps) => { +const ItemContainer = ({ entries, useAccordion }: ItemContainerProps) => { return ( {entries.map((entry, index) => ( - + ))} ); diff --git a/src/pages/all.tsx b/src/pages/all.tsx index e0e552e..4680871 100644 --- a/src/pages/all.tsx +++ b/src/pages/all.tsx @@ -28,7 +28,9 @@ const All = () => { - {data && data.entries && } + {data && data.entries && ( + + )} );