diff --git a/.changeset/short-donkeys-raise.md b/.changeset/short-donkeys-raise.md new file mode 100644 index 000000000..bd91fbd5d --- /dev/null +++ b/.changeset/short-donkeys-raise.md @@ -0,0 +1,5 @@ +--- +'@theguild/components': minor +--- + +Add ProductCard diff --git a/packages/components/src/components/explore-main-product-cards.tsx b/packages/components/src/components/explore-main-product-cards.tsx index 34c67c739..862d64f63 100644 --- a/packages/components/src/components/explore-main-product-cards.tsx +++ b/packages/components/src/components/explore-main-product-cards.tsx @@ -3,8 +3,8 @@ import { cn } from '../cn'; import { FOUR_MAIN_PRODUCTS } from '../products'; import { Heading } from './heading'; import { ArrowIcon } from './icons'; +import { MainProductCard } from './product-card'; import { TextLink } from './text-link'; -import { MainProductCard } from './tools-and-libraries-cards'; export type ExploreMainProductCardsProps = HTMLAttributes; diff --git a/packages/components/src/components/index.ts b/packages/components/src/components/index.ts index 99389e60b..68885d663 100644 --- a/packages/components/src/components/index.ts +++ b/packages/components/src/components/index.ts @@ -26,11 +26,7 @@ export { type GraphQLConfCardProps, } from './hive-navigation'; export { HiveFooter } from './hive-footer'; -export { - ToolsAndLibrariesCards, - MainProductCard, - AncillaryProductCard, -} from './tools-and-libraries-cards'; +export { ToolsAndLibrariesCards } from './tools-and-libraries-cards'; export * from './decorations'; export * from './call-to-action'; export * from './cookies-consent'; @@ -38,3 +34,4 @@ export * from './heading'; export * from './info-card'; export * from './stud'; export * from './explore-main-product-cards'; +export * from './product-card'; diff --git a/packages/components/src/components/tools-and-libraries-cards/hive-decoration.svg b/packages/components/src/components/product-card/hive-decoration.svg similarity index 97% rename from packages/components/src/components/tools-and-libraries-cards/hive-decoration.svg rename to packages/components/src/components/product-card/hive-decoration.svg index 5e143d6bb..9d94d3765 100644 --- a/packages/components/src/components/tools-and-libraries-cards/hive-decoration.svg +++ b/packages/components/src/components/product-card/hive-decoration.svg @@ -1,4 +1,4 @@ - + + + +

{product.name}

+ + + + + + + ); +} + +export function AncillaryProductCard({ product, as: Root, className, ...rest }: ProductCardProps) { + const Logo = product.logo; + return ( + + +
+

{product.name}

+

{product.title}

+
+
+ +
+ +
+
+ ); +} + +export interface ProductCardProps extends React.HTMLAttributes { + as: 'div' | 'li'; + product: ProductInfo; +} + +export function ProductCard(props: ProductCardProps) { + const isMainProduct = FOUR_MAIN_PRODUCTS.some(p => p.name === props.product.name); + + return isMainProduct ? : ; +} diff --git a/packages/components/src/components/tools-and-libraries-cards/mesh-decoration.svg b/packages/components/src/components/product-card/mesh-decoration.svg similarity index 98% rename from packages/components/src/components/tools-and-libraries-cards/mesh-decoration.svg rename to packages/components/src/components/product-card/mesh-decoration.svg index f71c79561..00f29425c 100644 --- a/packages/components/src/components/tools-and-libraries-cards/mesh-decoration.svg +++ b/packages/components/src/components/product-card/mesh-decoration.svg @@ -1,4 +1,4 @@ - + + a.name.localeCompare(b.name), +); + +export const Default: StoryObj = { + name: 'ProductCard', + render() { + return ( +
    + {productsLexicographically.map(product => ( + + ))} +
+ ); + }, +}; diff --git a/packages/components/src/components/tools-and-libraries-cards/yoga-decoration.svg b/packages/components/src/components/product-card/yoga-decoration.svg similarity index 98% rename from packages/components/src/components/tools-and-libraries-cards/yoga-decoration.svg rename to packages/components/src/components/product-card/yoga-decoration.svg index f90268230..ed1f86d5d 100644 --- a/packages/components/src/components/tools-and-libraries-cards/yoga-decoration.svg +++ b/packages/components/src/components/product-card/yoga-decoration.svg @@ -1,4 +1,4 @@ - + ))} - + Explore the Ecosystem ); } - -export function MainProductCard({ as: Root, product }: { as: 'div' | 'li'; product: ProductInfo }) { - const Decoration = cardDecorations[product.name]; - const Icon = product.logo; - - return ( - - -

{product.name}

- - - - - - - ); -} - -export function AncillaryProductCard({ - product, - as: Root, -}: { - product: ProductInfo; - as: 'div' | 'li'; -}) { - const Logo = product.logo; - return ( - - -

{product.name}

-

{product.title}

-
-
- -
- -
- - ); -}