diff --git a/templates/hydrogen-theme/app/components/CollectionCard.tsx b/templates/hydrogen-theme/app/components/CollectionCard.tsx index f178068..f25aa0d 100644 --- a/templates/hydrogen-theme/app/components/CollectionCard.tsx +++ b/templates/hydrogen-theme/app/components/CollectionCard.tsx @@ -1,18 +1,31 @@ import {Link} from '@remix-run/react'; import {Image} from '@shopify/hydrogen'; +import {cx} from 'class-variance-authority'; + import type {CollectionsQuery} from 'storefrontapi.generated'; export function CollectionCard(props: { collection: CollectionsQuery['collections']['nodes'][0]; className?: string; + columns?: number | null; }) { const {collection} = props; + const sizes = cx([ + '(min-width: 1024px)', + props.columns ? `${100 / props.columns}vw,` : '33vw,', + '100vw', + ]); return (
{collection.image && ( - + )}
{collection.title}
diff --git a/templates/hydrogen-theme/app/components/CollectionListGrid.tsx b/templates/hydrogen-theme/app/components/CollectionListGrid.tsx index de32240..ed05cf6 100644 --- a/templates/hydrogen-theme/app/components/CollectionListGrid.tsx +++ b/templates/hydrogen-theme/app/components/CollectionListGrid.tsx @@ -1,17 +1,30 @@ -import type {CollectionsQuery} from 'storefrontapi.generated'; +import type {CSSProperties} from 'react'; import {flattenConnection} from '@shopify/hydrogen'; +import {cx} from 'class-variance-authority'; + +import type {CollectionsQuery} from 'storefrontapi.generated'; import {CollectionCard} from './CollectionCard'; export function CollectionListGrid(props: { collections?: CollectionsQuery['collections']; + columns?: number | null; }) { const collections = flattenConnection(props.collections); + const columnsVar = { + '--columns': props.columns ?? 3, + } as CSSProperties; return collections?.length > 0 ? ( -