Skip to content

Commit

Permalink
feat: category page empty state (#1476)
Browse files Browse the repository at this point in the history
  • Loading branch information
deini authored Oct 17, 2024
1 parent 79e705f commit d47e3ac
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/rich-flies-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bigcommerce/catalyst-core": patch
---

adds an empty state to category pages
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { PackageOpen } from 'lucide-react';
import { useTranslations } from 'next-intl';

import { Link } from '~/components/link';
import { Button } from '~/components/ui/button';

export const EmptyState = () => {
const t = useTranslations('Category.Empty');

return (
<div className="my-10 flex flex-col items-center justify-center rounded-lg text-center">
<PackageOpen className="text-muted-foreground mb-4 h-16 w-16" />
<h2 className="mb-2 text-2xl font-semibold tracking-tight">{t('message')}</h2>

<div>
<Button asChild variant="subtle">
<Link href="/">{t('cta')}</Link>
</Button>
</div>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { SortBy } from '../../_components/sort-by';
import { fetchFacetedSearch } from '../../fetch-faceted-search';

import { CategoryViewed } from './_components/category-viewed';
import { EmptyState } from './_components/empty-state';
import { SubCategories } from './_components/sub-categories';
import { getCategoryPageData } from './page-data';

Expand Down Expand Up @@ -109,6 +110,8 @@ export default async function Category({ params: { locale, slug }, searchParams
{t('products')}
</h2>

{products.length === 0 && <EmptyState />}

<div className="grid grid-cols-2 gap-6 sm:grid-cols-3 sm:gap-8">
{products.map((product, index) => (
<ProductCard
Expand Down
6 changes: 5 additions & 1 deletion core/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@
"Category": {
"sortBy": "{items, plural, =0 {no items} =1 {1 item} other {# items}}",
"products": "Products",
"items": "items"
"items": "items",
"Empty": {
"message": "No products in this category",
"cta": "Return to Home"
}
},
"Search": {
"title": "Search results",
Expand Down

0 comments on commit d47e3ac

Please sign in to comment.