feat(poc): carousel and improved sub-collections

This commit is contained in:
Björn Meyer
2023-07-13 12:05:07 +02:00
parent 8dcf6db08f
commit 8550185eae
10 changed files with 239 additions and 127 deletions

View File

@@ -1,15 +1,15 @@
import clsx from 'clsx';
import { Suspense } from 'react';
import { getStaticCollections } from 'lib/shopware';
import { getSubCollections } from 'lib/shopware';
import FilterList from './filter';
import { transformStaticCollectionToList } from 'lib/shopware/transform';
import { transformCollectionToList } from 'lib/shopware/transform';
async function CollectionList() {
const collections = await getStaticCollections();
async function CollectionList({ collection }: { collection: string }) {
const collections = await getSubCollections(collection);
if (collections) {
const list = transformStaticCollectionToList(collections);
return <FilterList list={list} title="Collections" />;
const list = transformCollectionToList(collections);
if (list.length > 0) return <FilterList list={list} title="Sub-Collections" />;
}
}
@@ -17,7 +17,7 @@ const skeleton = 'mb-3 h-4 w-5/6 animate-pulse rounded';
const activeAndTitles = 'bg-gray-800 dark:bg-gray-300';
const items = 'bg-gray-400 dark:bg-gray-700';
export default function Collections() {
export default function Collections({ collection }: { collection: string }) {
return (
<Suspense
fallback={
@@ -35,7 +35,7 @@ export default function Collections() {
</div>
}
>
<CollectionList />
<CollectionList collection={collection} />
</Suspense>
);
}