From 6794376e39d9bb99eb649270316040e193217637 Mon Sep 17 00:00:00 2001 From: Chris Nanninga Date: Tue, 6 Feb 2024 20:54:54 -0600 Subject: [PATCH] Catalyst 536d9a8 --- .env.example | 14 +- .github/workflows/basic.yml | 2 +- .github/workflows/playwright.yml | 2 +- .gitignore | 2 + README.md | 6 +- apps/core/.eslintrc.cjs | 2 + apps/core/README.md | 2 +- .../(faceted)/_components/breadcrumbs.tsx | 8 +- .../(faceted)/_components/facets.tsx | 12 +- .../(faceted)/_components/mobile-side-nav.tsx | 4 +- .../(faceted)/_components/refine-by.tsx | 2 +- .../(faceted)/_components/skeleton-ui.tsx | 2 +- .../(faceted)/_components/sort-by.tsx | 2 +- .../(faceted)/brand/[slug]/static/page.tsx | 16 + .../(faceted)/category/[slug]/static/page.tsx | 28 ++ .../core/app/(default)/blog/[blogId]/page.tsx | 4 +- .../app/(default)/cart/CartItemCounter.tsx | 12 +- apps/core/app/(default)/cart/page.tsx | 2 +- apps/core/app/(default)/compare/AddToCart.tsx | 9 +- apps/core/app/(default)/compare/page.tsx | 4 +- apps/core/app/(default)/login/LoginForm.tsx | 8 +- apps/core/app/(default)/login/page.tsx | 2 +- .../product/[slug]/_components/Gallery.tsx | 8 +- .../[slug]/_components/ReviewSummary.tsx | 2 +- .../product/[slug]/_components/Reviews.tsx | 2 +- .../app/(default)/product/[slug]/loading.tsx | 2 +- .../app/(default)/product/[slug]/page.tsx | 32 +- .../(default)/product/[slug]/static/page.tsx | 17 ++ apps/core/app/(default)/static/page.tsx | 6 + apps/core/app/favicon.ico | Bin 25931 -> 1546 bytes apps/core/app/not-found.tsx | 2 +- apps/core/auth.ts | 14 +- apps/core/client/queries/getCategory.ts | 1 + apps/core/client/queries/getCategoryTree.ts | 1 + apps/core/components/BlogPostCard/index.tsx | 8 +- apps/core/components/CompareDrawer/index.tsx | 4 +- apps/core/components/Footer/Footer.tsx | 10 +- .../Footer/FooterMenus/BaseFooterMenu.tsx | 2 +- apps/core/components/Footer/SocialIcons.tsx | 2 +- apps/core/components/Forbidden/index.tsx | 2 +- apps/core/components/Forms/ContactUs.tsx | 10 +- apps/core/components/Header/cart.tsx | 4 +- apps/core/components/Header/index.tsx | 6 +- apps/core/components/Hero/index.tsx | 4 +- apps/core/components/Pricing/index.tsx | 25 +- .../core/components/ProductCard/AddToCart.tsx | 9 +- apps/core/components/ProductCard/Compare.tsx | 4 +- apps/core/components/ProductCard/index.tsx | 10 +- .../ProductCardCarousel/Pagination.tsx | 2 +- .../components/ProductCardCarousel/index.tsx | 2 +- .../core/components/ProductForm/AddToCart.tsx | 4 +- .../ProductForm/Fields/CheckboxField.tsx | 4 +- .../ProductForm/Fields/DateField.tsx | 4 +- .../ProductForm/Fields/MultiLineTextField.tsx | 4 +- .../Fields/MultipleChoiceField.tsx | 12 +- .../ProductForm/Fields/NumberField.tsx | 4 +- .../ProductForm/Fields/QuantityField.tsx | 4 +- .../ProductForm/Fields/TextField.tsx | 4 +- apps/core/components/ProductForm/index.tsx | 2 +- apps/core/components/ProductSheet/index.tsx | 38 ++- apps/core/components/QuickSearch/index.tsx | 8 +- apps/core/components/SearchForm/index.tsx | 6 +- apps/core/middlewares/with-custom-urls.ts | 26 +- apps/core/next.config.js | 4 +- apps/core/package.json | 2 +- apps/core/tailwind.config.js | 6 +- apps/core/tsconfig.json | 2 +- apps/docs/.eslintrc.cjs | 1 + apps/docs/package.json | 4 +- apps/docs/stories/Accordion.stories.tsx | 2 +- apps/docs/stories/Badge.stories.tsx | 2 +- apps/docs/stories/BlogPostCard.stories.tsx | 2 +- apps/docs/stories/Breadcrumbs.stories.tsx | 2 +- apps/docs/stories/Button.stories.tsx | 2 +- apps/docs/stories/Calendar.stories.tsx | 2 +- apps/docs/stories/Carousel.stories.tsx | 4 +- apps/docs/stories/Checkbox.stories.tsx | 4 +- apps/docs/stories/Counter.stories.tsx | 3 +- apps/docs/stories/DatePicker.stories.tsx | 2 +- apps/docs/stories/FileChooser.stories.tsx | 4 +- apps/docs/stories/Footer.stories.tsx | 2 +- apps/docs/stories/Form.stories.tsx | 10 +- apps/docs/stories/Gallery.stories.tsx | 2 +- apps/docs/stories/Input.stories.tsx | 2 +- apps/docs/stories/Label.stories.tsx | 4 +- apps/docs/stories/Message.stories.tsx | 2 +- apps/docs/stories/NavigationMenu.stories.tsx | 6 +- apps/docs/stories/PickList.stories.tsx | 4 +- apps/docs/stories/Popover.stories.tsx | 4 +- apps/docs/stories/ProductCard.stories.tsx | 2 +- apps/docs/stories/RadioGroup.stories.tsx | 4 +- apps/docs/stories/Rating.stories.tsx | 2 +- apps/docs/stories/RectangleList.stories.tsx | 4 +- apps/docs/stories/Select.stories.tsx | 2 +- apps/docs/stories/Sheet.stories.tsx | 2 +- apps/docs/stories/Skeleton.stories.tsx | 2 +- apps/docs/stories/Slideshow.stories.tsx | 4 +- apps/docs/stories/Swatch.stories.tsx | 4 +- apps/docs/stories/Tag.stories.tsx | 2 +- apps/docs/stories/TextArea.stories.tsx | 2 +- apps/docs/tailwind.config.js | 6 +- packages/client/.eslintrc.cjs | 1 + .../{reactant => components}/.eslintrc.cjs | 2 + .../{reactant => components}/package.json | 2 +- .../postcss.config.js | 0 .../prettier.config.js | 0 .../src/components/Accordion/Accordion.tsx | 0 .../src/components/Accordion/index.ts | 0 .../src/components/Badge/Badge.tsx | 0 .../src/components/Badge/index.ts | 0 .../components/BlogPostCard/BlogPostCard.tsx | 0 .../src/components/BlogPostCard/index.ts | 0 .../components/Breadcrumbs/Breadcrumbs.tsx | 0 .../src/components/Breadcrumbs/index.ts | 0 .../src/components/Button/Button.tsx | 0 .../src/components/Button/index.ts | 0 .../src/components/Calendar/Calendar.tsx | 0 .../src/components/Calendar/index.ts | 0 .../src/components/Carousel/Carousel.tsx | 0 .../src/components/Carousel/index.ts | 0 .../src/components/Checkbox/Checkbox.tsx | 0 .../src/components/Checkbox/index.ts | 0 .../src/components/Counter/Counter.tsx | 4 + .../src/components/Counter/index.ts | 0 .../src/components/DatePicker/DatePicker.tsx | 0 .../src/components/DatePicker/index.ts | 0 .../components/FileChooser/FileChooser.tsx | 0 .../src/components/FileChooser/index.ts | 0 .../src/components/Footer/Footer.tsx | 0 .../src/components/Footer/index.ts | 0 .../src/components/Form/Form.tsx | 0 .../src/components/Form/index.ts | 0 .../src/components/Gallery/Gallery.tsx | 0 .../src/components/Gallery/index.ts | 0 .../src/components/Input/Input.tsx | 0 .../src/components/Input/index.ts | 0 .../src/components/Label/Label.tsx | 0 .../src/components/Label/index.ts | 0 .../src/components/Message/Message.tsx | 0 .../src/components/Message/index.ts | 0 .../NavigationMenu/NavigationMenu.tsx | 0 .../src/components/NavigationMenu/index.ts | 0 .../src/components/PickList/PickList.tsx | 0 .../src/components/PickList/index.ts | 0 .../src/components/Popover/Popover.tsx | 0 .../src/components/Popover/index.ts | 0 .../components/ProductCard/ProductCard.tsx | 0 .../src/components/ProductCard/index.ts | 0 .../src/components/RadioGroup/RadioGroup.tsx | 0 .../src/components/RadioGroup/index.ts | 0 .../src/components/Rating/Rating.tsx | 0 .../components/Rating/StarIcons/StarEmpty.tsx | 0 .../Rating/StarIcons/StarFilled.tsx | 0 .../components/Rating/StarIcons/StarHalf.tsx | 0 .../src/components/Rating/index.ts | 0 .../RectangleList/RectangleList.tsx | 0 .../src/components/RectangleList/index.ts | 0 .../src/components/Select/Select.tsx | 0 .../src/components/Select/index.ts | 0 .../src/components/Sheet/Sheet.tsx | 0 .../src/components/Sheet/index.ts | 0 .../src/components/Skeleton/Skeleton.tsx | 0 .../src/components/Skeleton/index.ts | 0 .../src/components/Slideshow/Slideshow.tsx | 0 .../src/components/Slideshow/index.ts | 0 .../src/components/Swatch/Swatch.tsx | 0 .../src/components/Swatch/index.ts | 0 .../src/components/Tag/Tag.tsx | 0 .../src/components/Tag/index.ts | 0 .../src/components/TextArea/TextArea.tsx | 0 .../src/components/TextArea/index.ts | 0 .../{reactant => components}/src/lib/utils.ts | 0 .../tailwind.config.js | 0 .../{reactant => components}/tsconfig.json | 0 packages/create-catalyst/README.md | 2 +- packages/eslint-config-catalyst/base.js | 19 ++ packages/eslint-config-catalyst/package.json | 1 + packages/functional/.eslintrc.cjs | 3 + .../functional/actions/product-actions.ts | 2 +- .../ui/core/components/Accordion.spec.ts | 48 ++- .../ui/core/components/BreadCrumbs.spec.ts | 10 +- .../tests/ui/core/components/Carousel.spec.ts | 26 +- .../tests/ui/core/components/Checkbox.spec.ts | 19 +- .../tests/ui/core/components/Counter.spec.ts | 51 ++++ .../ui/core/components/RadioGroup.spec.ts | 25 ++ .../tests/ui/core/components/Select.spec.ts | 37 +++ .../ui/core/components/Slideshow.spec.ts | 21 +- .../tests/ui/core/components/Swatch.spec.ts | 24 ++ pnpm-lock.yaml | 285 +++++++++++------- 189 files changed, 766 insertions(+), 392 deletions(-) create mode 100644 apps/core/app/(default)/(faceted)/brand/[slug]/static/page.tsx create mode 100644 apps/core/app/(default)/(faceted)/category/[slug]/static/page.tsx create mode 100644 apps/core/app/(default)/product/[slug]/static/page.tsx create mode 100644 apps/core/app/(default)/static/page.tsx rename packages/{reactant => components}/.eslintrc.cjs (83%) rename packages/{reactant => components}/package.json (98%) rename packages/{reactant => components}/postcss.config.js (100%) rename packages/{reactant => components}/prettier.config.js (100%) rename packages/{reactant => components}/src/components/Accordion/Accordion.tsx (100%) rename packages/{reactant => components}/src/components/Accordion/index.ts (100%) rename packages/{reactant => components}/src/components/Badge/Badge.tsx (100%) rename packages/{reactant => components}/src/components/Badge/index.ts (100%) rename packages/{reactant => components}/src/components/BlogPostCard/BlogPostCard.tsx (100%) rename packages/{reactant => components}/src/components/BlogPostCard/index.ts (100%) rename packages/{reactant => components}/src/components/Breadcrumbs/Breadcrumbs.tsx (100%) rename packages/{reactant => components}/src/components/Breadcrumbs/index.ts (100%) rename packages/{reactant => components}/src/components/Button/Button.tsx (100%) rename packages/{reactant => components}/src/components/Button/index.ts (100%) rename packages/{reactant => components}/src/components/Calendar/Calendar.tsx (100%) rename packages/{reactant => components}/src/components/Calendar/index.ts (100%) rename packages/{reactant => components}/src/components/Carousel/Carousel.tsx (100%) rename packages/{reactant => components}/src/components/Carousel/index.ts (100%) rename packages/{reactant => components}/src/components/Checkbox/Checkbox.tsx (100%) rename packages/{reactant => components}/src/components/Checkbox/index.ts (100%) rename packages/{reactant => components}/src/components/Counter/Counter.tsx (98%) rename packages/{reactant => components}/src/components/Counter/index.ts (100%) rename packages/{reactant => components}/src/components/DatePicker/DatePicker.tsx (100%) rename packages/{reactant => components}/src/components/DatePicker/index.ts (100%) rename packages/{reactant => components}/src/components/FileChooser/FileChooser.tsx (100%) rename packages/{reactant => components}/src/components/FileChooser/index.ts (100%) rename packages/{reactant => components}/src/components/Footer/Footer.tsx (100%) rename packages/{reactant => components}/src/components/Footer/index.ts (100%) rename packages/{reactant => components}/src/components/Form/Form.tsx (100%) rename packages/{reactant => components}/src/components/Form/index.ts (100%) rename packages/{reactant => components}/src/components/Gallery/Gallery.tsx (100%) rename packages/{reactant => components}/src/components/Gallery/index.ts (100%) rename packages/{reactant => components}/src/components/Input/Input.tsx (100%) rename packages/{reactant => components}/src/components/Input/index.ts (100%) rename packages/{reactant => components}/src/components/Label/Label.tsx (100%) rename packages/{reactant => components}/src/components/Label/index.ts (100%) rename packages/{reactant => components}/src/components/Message/Message.tsx (100%) rename packages/{reactant => components}/src/components/Message/index.ts (100%) rename packages/{reactant => components}/src/components/NavigationMenu/NavigationMenu.tsx (100%) rename packages/{reactant => components}/src/components/NavigationMenu/index.ts (100%) rename packages/{reactant => components}/src/components/PickList/PickList.tsx (100%) rename packages/{reactant => components}/src/components/PickList/index.ts (100%) rename packages/{reactant => components}/src/components/Popover/Popover.tsx (100%) rename packages/{reactant => components}/src/components/Popover/index.ts (100%) rename packages/{reactant => components}/src/components/ProductCard/ProductCard.tsx (100%) rename packages/{reactant => components}/src/components/ProductCard/index.ts (100%) rename packages/{reactant => components}/src/components/RadioGroup/RadioGroup.tsx (100%) rename packages/{reactant => components}/src/components/RadioGroup/index.ts (100%) rename packages/{reactant => components}/src/components/Rating/Rating.tsx (100%) rename packages/{reactant => components}/src/components/Rating/StarIcons/StarEmpty.tsx (100%) rename packages/{reactant => components}/src/components/Rating/StarIcons/StarFilled.tsx (100%) rename packages/{reactant => components}/src/components/Rating/StarIcons/StarHalf.tsx (100%) rename packages/{reactant => components}/src/components/Rating/index.ts (100%) rename packages/{reactant => components}/src/components/RectangleList/RectangleList.tsx (100%) rename packages/{reactant => components}/src/components/RectangleList/index.ts (100%) rename packages/{reactant => components}/src/components/Select/Select.tsx (100%) rename packages/{reactant => components}/src/components/Select/index.ts (100%) rename packages/{reactant => components}/src/components/Sheet/Sheet.tsx (100%) rename packages/{reactant => components}/src/components/Sheet/index.ts (100%) rename packages/{reactant => components}/src/components/Skeleton/Skeleton.tsx (100%) rename packages/{reactant => components}/src/components/Skeleton/index.ts (100%) rename packages/{reactant => components}/src/components/Slideshow/Slideshow.tsx (100%) rename packages/{reactant => components}/src/components/Slideshow/index.ts (100%) rename packages/{reactant => components}/src/components/Swatch/Swatch.tsx (100%) rename packages/{reactant => components}/src/components/Swatch/index.ts (100%) rename packages/{reactant => components}/src/components/Tag/Tag.tsx (100%) rename packages/{reactant => components}/src/components/Tag/index.ts (100%) rename packages/{reactant => components}/src/components/TextArea/TextArea.tsx (100%) rename packages/{reactant => components}/src/components/TextArea/index.ts (100%) rename packages/{reactant => components}/src/lib/utils.ts (100%) rename packages/{reactant => components}/tailwind.config.js (100%) rename packages/{reactant => components}/tsconfig.json (100%) create mode 100644 packages/functional/tests/ui/core/components/Counter.spec.ts create mode 100644 packages/functional/tests/ui/core/components/RadioGroup.spec.ts create mode 100644 packages/functional/tests/ui/core/components/Select.spec.ts create mode 100644 packages/functional/tests/ui/core/components/Swatch.spec.ts diff --git a/.env.example b/.env.example index 80874d01..9c28c2ca 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,16 @@ -# Shared env vars, used by all apps and api client +# The hash visible in the subject store's URL when signed in to the store control panel. +# The control panel URL is of the form `https://store-{hash}.mybigcommerce.com`. BIGCOMMERCE_STORE_HASH= + +# The access token from a store-level API account. The only scope required to run Catalyst is Carts `read-only`. +# See https://developer.bigcommerce.com/api-docs/getting-started/api-accounts#store-level-api-accounts BIGCOMMERCE_ACCESS_TOKEN= + +# A bearer token that authorizes server-to-server requests to the GraphQL Storefront API +# See https://developer.bigcommerce.com/docs/rest-authentication/tokens/customer-impersonation-token BIGCOMMERCE_CUSTOMER_IMPERSONATION_TOKEN= + +# The channel ID for the Catalyst storefront's dedicated channel. BIGCOMMERCE_CHANNEL_ID=1 # Set to true to allow the /admin route to redirect to the BigCommerce control panel. @@ -9,4 +18,5 @@ BIGCOMMERCE_CHANNEL_ID=1 # You may also delete /admin/route.ts if you wish. ENABLE_ADMIN_ROUTE=true -AUTH_SECRET= # Generate one typing `openssl rand -hex 32` in your terminal +# Used by NextAuth, can be generated by running `openssl rand -hex 32` in your terminal. +AUTH_SECRET= diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml index e8e4f91d..e7c21adc 100644 --- a/.github/workflows/basic.yml +++ b/.github/workflows/basic.yml @@ -1,4 +1,4 @@ -name: Basic workflow +name: Lint, Typecheck, GraphQL Codegen on: push: diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index f91d286e..1a04916b 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -34,7 +34,7 @@ jobs: PLAYWRIGHT_TEST_BASE_URL: ${{ github.event.deployment_status.target_url }} run: | cd packages/functional - npx playwright test tests/visual-regression/reactant/components/ --project=tests-chromium + npx playwright test tests/visual-regression/reactant/components/ --project=tests-chromium - uses: actions/upload-artifact@v3 if: failure() diff --git a/.gitignore b/.gitignore index 97e23f9c..5a7229c0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ dist .turbo .vscode/**/* !.vscode/settings.example.json +.idea +.vercel .env .env*.local test-results/ diff --git a/README.md b/README.md index eefba2e1..08ff8524 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,12 @@ > [!WARNING] > - Catalyst is in development and should not be used in production environments. -**Catalyst** is a composable, fully customizable headless storefront that offers a set of opinionated defaults. It is intended to fit the needs of modern developers, merchants, and shoppers. Catalyst is built with [Next.js (nextjs.org)](https://nextjs.org/) and uses our [React.js-based (react.dev)](https://react.dev/) **Reactant** storefront components. +**Catalyst** is a composable, fully customizable headless storefront that offers a set of opinionated defaults. It is intended to fit the needs of modern developers, merchants, and shoppers. Catalyst is built with [Next.js (nextjs.org)](https://nextjs.org/) and uses our [React.js-based (react.dev)](https://react.dev/) storefront components. The Catalyst monorepo contains the following: * The core **Catalyst** Next.js storefront, in [apps/core](apps/core). -* The **Reactant** storefront component library, in [packages/reactant](packages/reactant). +* The storefront component library, in [packages/components](packages/components). * The BigCommerce [GraphQL Storefront API (BigCommerce Dev Center)](https://developer.bigcommerce.com/docs/graphql-storefront) client, in [packages/client](packages/client). ## Requirements @@ -83,7 +83,7 @@ The `dev` script runs all packages and apps in watch mode. The following table l | Process | URL with port | |:--------|:--------------| | Core Catalyst storefront | http://localhost:3000 | -| Reactant Storybook | http://localhost:6006 | +| Components Storybook | http://localhost:6006 | Happy developing! Let us know how things are going in the dedicated Slack channel. diff --git a/apps/core/.eslintrc.cjs b/apps/core/.eslintrc.cjs index e2155b80..d0a7c7bf 100644 --- a/apps/core/.eslintrc.cjs +++ b/apps/core/.eslintrc.cjs @@ -25,6 +25,8 @@ const config = { ], }, ], + 'check-file/filename-naming-convention': 'off', + 'check-file/folder-naming-convention': 'off', }, }; diff --git a/apps/core/README.md b/apps/core/README.md index 788f7aac..0e9c1e68 100644 --- a/apps/core/README.md +++ b/apps/core/README.md @@ -1,6 +1,6 @@ # Catalyst -Catalyst is the next generation of storefronts at BigCommerce. It aims to be composable and powerful to meet the needs of our enterprise customers, exceeding performance of Stencil and Blueprint themes. Catalyst is built with [Next.js](https://nextjs.org/) using our React.js storefront component library called Reactant. +Catalyst is the next generation of storefronts at BigCommerce. It aims to be composable and powerful to meet the needs of our enterprise customers, exceeding performance of Stencil and Blueprint themes. Catalyst is built with [Next.js](https://nextjs.org/) using our React.js storefront component library. ## Getting Started diff --git a/apps/core/app/(default)/(faceted)/_components/breadcrumbs.tsx b/apps/core/app/(default)/(faceted)/_components/breadcrumbs.tsx index 15262c00..a721dab3 100644 --- a/apps/core/app/(default)/(faceted)/_components/breadcrumbs.tsx +++ b/apps/core/app/(default)/(faceted)/_components/breadcrumbs.tsx @@ -1,8 +1,8 @@ import { BreadcrumbDivider, BreadcrumbItem, - Breadcrumbs as ReactantBreadcrumbs, -} from '@bigcommerce/reactant/Breadcrumbs'; + Breadcrumbs as ComponentsBreadcrumbs, +} from '@bigcommerce/components/Breadcrumbs'; import { ChevronRight } from 'lucide-react'; import { Fragment } from 'react'; @@ -18,7 +18,7 @@ interface Props { } export const Breadcrumbs = ({ breadcrumbs, category }: Props) => ( - + {breadcrumbs.map(({ name, entityId, path }, index) => { if (!path || breadcrumbs.length - 1 === index) { return ( @@ -39,5 +39,5 @@ export const Breadcrumbs = ({ breadcrumbs, category }: Props) => ( ); })} - + ); diff --git a/apps/core/app/(default)/(faceted)/_components/facets.tsx b/apps/core/app/(default)/(faceted)/_components/facets.tsx index 752391a3..02dc8b98 100644 --- a/apps/core/app/(default)/(faceted)/_components/facets.tsx +++ b/apps/core/app/(default)/(faceted)/_components/facets.tsx @@ -5,12 +5,12 @@ import { AccordionContent, AccordionItem, AccordionTrigger, -} from '@bigcommerce/reactant/Accordion'; -import { Button } from '@bigcommerce/reactant/Button'; -import { Checkbox } from '@bigcommerce/reactant/Checkbox'; -import { Input } from '@bigcommerce/reactant/Input'; -import { Label } from '@bigcommerce/reactant/Label'; -import { Rating } from '@bigcommerce/reactant/Rating'; +} from '@bigcommerce/components/Accordion'; +import { Button } from '@bigcommerce/components/Button'; +import { Checkbox } from '@bigcommerce/components/Checkbox'; +import { Input } from '@bigcommerce/components/Input'; +import { Label } from '@bigcommerce/components/Label'; +import { Rating } from '@bigcommerce/components/Rating'; import { usePathname, useRouter, useSearchParams } from 'next/navigation'; import { FormEvent, useRef } from 'react'; diff --git a/apps/core/app/(default)/(faceted)/_components/mobile-side-nav.tsx b/apps/core/app/(default)/(faceted)/_components/mobile-side-nav.tsx index bea891b5..97fe13b0 100644 --- a/apps/core/app/(default)/(faceted)/_components/mobile-side-nav.tsx +++ b/apps/core/app/(default)/(faceted)/_components/mobile-side-nav.tsx @@ -1,6 +1,6 @@ 'use client'; -import { Button } from '@bigcommerce/reactant/Button'; +import { Button } from '@bigcommerce/components/Button'; import { Sheet, SheetClose, @@ -9,7 +9,7 @@ import { SheetOverlay, SheetTitle, SheetTrigger, -} from '@bigcommerce/reactant/Sheet'; +} from '@bigcommerce/components/Sheet'; import { Filter } from 'lucide-react'; import { PropsWithChildren, useEffect, useState } from 'react'; diff --git a/apps/core/app/(default)/(faceted)/_components/refine-by.tsx b/apps/core/app/(default)/(faceted)/_components/refine-by.tsx index d9e3421d..eee24b8b 100644 --- a/apps/core/app/(default)/(faceted)/_components/refine-by.tsx +++ b/apps/core/app/(default)/(faceted)/_components/refine-by.tsx @@ -1,6 +1,6 @@ 'use client'; -import { Tag, TagAction, TagContent } from '@bigcommerce/reactant/Tag'; +import { Tag, TagAction, TagContent } from '@bigcommerce/components/Tag'; import { usePathname, useRouter, useSearchParams } from 'next/navigation'; import type { Facet, PageType, PublicParamKeys } from '../types'; diff --git a/apps/core/app/(default)/(faceted)/_components/skeleton-ui.tsx b/apps/core/app/(default)/(faceted)/_components/skeleton-ui.tsx index 49c41399..43d6a79a 100644 --- a/apps/core/app/(default)/(faceted)/_components/skeleton-ui.tsx +++ b/apps/core/app/(default)/(faceted)/_components/skeleton-ui.tsx @@ -1,4 +1,4 @@ -import { Skeleton } from '@bigcommerce/reactant/Skeleton'; +import { Skeleton } from '@bigcommerce/components/Skeleton'; export const SkeletonIU = () => (
diff --git a/apps/core/app/(default)/(faceted)/_components/sort-by.tsx b/apps/core/app/(default)/(faceted)/_components/sort-by.tsx index de205074..7fc28df7 100644 --- a/apps/core/app/(default)/(faceted)/_components/sort-by.tsx +++ b/apps/core/app/(default)/(faceted)/_components/sort-by.tsx @@ -1,6 +1,6 @@ 'use client'; -import { Select, SelectContent, SelectItem } from '@bigcommerce/reactant/Select'; +import { Select, SelectContent, SelectItem } from '@bigcommerce/components/Select'; import { usePathname, useRouter, useSearchParams } from 'next/navigation'; export function SortBy() { diff --git a/apps/core/app/(default)/(faceted)/brand/[slug]/static/page.tsx b/apps/core/app/(default)/(faceted)/brand/[slug]/static/page.tsx new file mode 100644 index 00000000..06ce7d67 --- /dev/null +++ b/apps/core/app/(default)/(faceted)/brand/[slug]/static/page.tsx @@ -0,0 +1,16 @@ +import { getBrands } from '~/client/queries/getBrands'; + +import BrandPage from '../page'; + +export default BrandPage; + +export async function generateStaticParams() { + const brands = await getBrands(); + + return brands.map((brand) => ({ + slug: brand.entityId.toString(), + })); +} + +export const dynamic = 'force-static'; +export const revalidate = 600; diff --git a/apps/core/app/(default)/(faceted)/category/[slug]/static/page.tsx b/apps/core/app/(default)/(faceted)/category/[slug]/static/page.tsx new file mode 100644 index 00000000..7f268259 --- /dev/null +++ b/apps/core/app/(default)/(faceted)/category/[slug]/static/page.tsx @@ -0,0 +1,28 @@ +import { getCategoryTree } from '~/client/queries/getCategoryTree'; +import { ExistingResultType } from '~/client/util'; + +import CategoryPage from '../page'; + +export default CategoryPage; + +type Categories = ExistingResultType; +type Category = Omit & { children?: Category[] }; + +const getEntityIdsOfChildren = (categories: Category[] = []): number[] => + categories.reduce( + (acc, category) => acc.concat(category.entityId, getEntityIdsOfChildren(category.children)), + [], + ); + +export async function generateStaticParams() { + const categories = await getCategoryTree(); + + const entityIds = getEntityIdsOfChildren(categories); + + return entityIds.map((entityId) => ({ + slug: entityId.toString(), + })); +} + +export const dynamic = 'force-static'; +export const revalidate = 600; diff --git a/apps/core/app/(default)/blog/[blogId]/page.tsx b/apps/core/app/(default)/blog/[blogId]/page.tsx index 0e265dcc..dda1c510 100644 --- a/apps/core/app/(default)/blog/[blogId]/page.tsx +++ b/apps/core/app/(default)/blog/[blogId]/page.tsx @@ -4,8 +4,8 @@ import { BlogPostDate, BlogPostImage, BlogPostTitle, -} from '@bigcommerce/reactant/BlogPostCard'; -import { Tag, TagContent } from '@bigcommerce/reactant/Tag'; +} from '@bigcommerce/components/BlogPostCard'; +import { Tag, TagContent } from '@bigcommerce/components/Tag'; import type { Metadata } from 'next'; import Image from 'next/image'; import { notFound } from 'next/navigation'; diff --git a/apps/core/app/(default)/cart/CartItemCounter.tsx b/apps/core/app/(default)/cart/CartItemCounter.tsx index 5295d778..88ef0599 100644 --- a/apps/core/app/(default)/cart/CartItemCounter.tsx +++ b/apps/core/app/(default)/cart/CartItemCounter.tsx @@ -1,6 +1,6 @@ 'use client'; -import { Counter } from '@bigcommerce/reactant/Counter'; +import { Counter } from '@bigcommerce/components/Counter'; import { useState } from 'react'; import { @@ -21,10 +21,13 @@ interface UpdateProductQuantityData extends CartLineItemInput { export const CartItemCounter = ({ itemData }: { itemData: CartItemData }) => { const { quantity, lineItemEntityId, productEntityId, variantEntityId } = itemData; - const [counterValue, setCounterValue] = useState(quantity); + + const [counterValue, setCounterValue] = useState<'' | number>(quantity); const handleCountUpdate = async (value: string | number) => { - if (Number.isNaN(value)) { - setCounterValue(0); + if (value === '') { + setCounterValue(value); + + return; } setCounterValue(Number(value)); @@ -40,6 +43,7 @@ export const CartItemCounter = ({ itemData }: { itemData: CartItemData }) => { return ( diff --git a/apps/core/app/(default)/cart/page.tsx b/apps/core/app/(default)/cart/page.tsx index e4b6984e..0b49e5e6 100644 --- a/apps/core/app/(default)/cart/page.tsx +++ b/apps/core/app/(default)/cart/page.tsx @@ -1,4 +1,4 @@ -import { Button } from '@bigcommerce/reactant/Button'; +import { Button } from '@bigcommerce/components/Button'; import { Trash2 as Trash } from 'lucide-react'; import { cookies } from 'next/headers'; import Image from 'next/image'; diff --git a/apps/core/app/(default)/compare/AddToCart.tsx b/apps/core/app/(default)/compare/AddToCart.tsx index 90c79eba..b678a001 100644 --- a/apps/core/app/(default)/compare/AddToCart.tsx +++ b/apps/core/app/(default)/compare/AddToCart.tsx @@ -1,7 +1,7 @@ 'use client'; -import { Button } from '@bigcommerce/reactant/Button'; -import { ShoppingCart, Loader2 as Spinner } from 'lucide-react'; +import { Button } from '@bigcommerce/components/Button'; +import { Loader2 as Spinner } from 'lucide-react'; import { useFormStatus } from 'react-dom'; export const AddToCart = ({ @@ -21,10 +21,7 @@ export const AddToCart = ({ Processing... ) : ( - <> -