diff --git a/.github/workflows/periodic-build.yml b/.github/workflows/periodic-build.yml index 0bd36f1808d..0800e4c589a 100644 --- a/.github/workflows/periodic-build.yml +++ b/.github/workflows/periodic-build.yml @@ -21,7 +21,7 @@ jobs: publish: strategy: matrix: - version: [20, 22] + version: [22, 24] runs-on: ubuntu-latest steps: - name: Checkout @@ -31,7 +31,7 @@ jobs: path: graphcommerce - name: Set up Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.version }} registry-url: 'https://registry.npmjs.org' diff --git a/.github/workflows/pr-analysis.yml b/.github/workflows/pr-analysis.yml index 466719af485..0cf0a66cec2 100644 --- a/.github/workflows/pr-analysis.yml +++ b/.github/workflows/pr-analysis.yml @@ -9,7 +9,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: 20 + node-version: 24 cache: yarn cache-dependency-path: package.json - run: yarn install diff --git a/.github/workflows/release-canary.yml b/.github/workflows/release-canary.yml index 14e52796823..646c36e7f0c 100644 --- a/.github/workflows/release-canary.yml +++ b/.github/workflows/release-canary.yml @@ -19,10 +19,20 @@ jobs: - uses: actions/setup-node@v4 with: cache: yarn - node-version: 20 + node-version: 24 cache-dependency-path: package.json registry-url: 'https://registry.npmjs.org' scope: '@graphcommerce' + - name: verify npm auth (fail fast on expired/invalid NPM_TOKEN) + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + if ! WHOAMI=$(npm whoami --registry=https://registry.npmjs.org 2>&1); then + echo "::error::NPM_TOKEN is invalid, expired, or has no publish access. npm whoami output: $WHOAMI" + echo "::error::Generate a new token at https://www.npmjs.com/settings//tokens and update the NPM_TOKEN secret." + exit 1 + fi + echo "Authenticated to npm as: $WHOAMI" - name: yarn install && yarn postinstall run: yarn install && yarn postinstall - name: set pre canary @@ -36,8 +46,12 @@ jobs: git add . git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git config user.name "github-actions[bot]" - git commit -m "chore(release): update prerelease versions" - git push + if ! git diff --staged --quiet; then + git commit -m "chore(release): update prerelease versions" + git push + else + echo "No version changes to commit; proceeding to publish step." + fi env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: set version variables diff --git a/.github/workflows/release-main.yml b/.github/workflows/release-main.yml index 35c2242faf0..df16945831b 100644 --- a/.github/workflows/release-main.yml +++ b/.github/workflows/release-main.yml @@ -18,7 +18,7 @@ jobs: - uses: actions/setup-node@v4 with: cache: yarn - node-version: 20 + node-version: 24 cache-dependency-path: package.json registry-url: 'https://registry.npmjs.org' scope: '@graphcommerce' diff --git a/.gitignore b/.gitignore index 4a19cc4f80a..173fe446382 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,7 @@ build !.yarn/sdks !.yarn/versions yarn.lock + +# playwright +test-results +playwright-report diff --git a/.gitpod.yml b/.gitpod.yml index 381dc780001..4c50ad0bd08 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,5 +1,5 @@ tasks: - - before: nvm install 18 + - before: nvm install 24 init: | cd examples/magento-graphcms yarn diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 00000000000..19a6f091da8 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,618 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with +code in this repository. + +## Repository Overview + +GraphCommerce is a React/Next.js framework for building headless ecommerce +storefronts, backed by Magento 2 and Hygraph. It's a **Yarn 4 workspaces +monorepo** with ~68 packages. + +### graphcommerce vs graphcommerce-private + +This repo (`graphcommerce/`) is the **open-source core framework**. It is a +submodule inside the **`graphcommerce-private`** parent repo +(`../graphcommerce-private/`), which adds proprietary packages in +`packagesPrivate/` (Adobe Commerce features, B2B, gift cards, store credit, +returns, cache-notify, private pricing, etc.). + +**Where to put new code:** + +- **This repo (`graphcommerce/`)** — Generic, open-source framework features + that benefit all users. Core Magento integrations, UI components, build + tooling. +- **Parent repo (`graphcommerce-private/packagesPrivate/`)** — Specialized, + proprietary features: B2B (company accounts, purchase orders, requisition + lists, negotiable quotes), Adobe Commerce-specific features (gift cards, store + credit, returns, reward points), private pricing, cache invalidation, etc. + +When building a new feature, ask: "Is this generic enough for the open-source +framework, or is it specific to Adobe Commerce / B2B / a paid add-on?" If the +latter, it belongs in `graphcommerce-private/packagesPrivate/`. Private packages +are activated via `PRIVATE_ADDITIONAL_DEPENDENCIES` in `.env`. + +## Common Commands + +### Development + +```bash +# Start the main example storefront (runs codegen watcher + Next.js dev with Turbopack) +yarn workspace @graphcommerce/magento-graphcms dev + +# Watch + rebuild the TS-compiled framework packages in parallel +# (`pkgroll -w` / `tsc -W` — never exits, leave running during development) +yarn packages + +# One-shot build of the same set — use this before committing or +# generating patches +yarn packages:build + +# Full production build of example +yarn workspace @graphcommerce/magento-graphcms build +``` + +**After editing TS source in any of the seven framework packages that ship as +compiled `dist/`, run `yarn packages:build` before committing.** The seven +packages are: + +| Package | Path | +| ------------------------------------------------------- | --------------------------------- | +| `@graphcommerce/next-config` | `packagesDev/next-config` | +| `@graphcommerce/cli` | `packages/cli` | +| `@graphcommerce/hygraph-cli` | `packages/hygraph-cli` | +| `@graphcommerce/changeset-changelog` | `packagesDev/changeset-changelog` | +| `@graphcommerce/graphql-codegen-near-operation-file` | `packagesDev/` | +| `@graphcommerce/graphql-codegen-relay-optimizer-plugin` | `packagesDev/` | +| `@graphcommerce/graphql-codegen-markdown-docs` | `packagesDev/` | + +These ship as compiled `dist/**/*.js`, not source — without rebuilding, the +change is invisible to consumers (including local +`node_modules/@graphcommerce/*` when generating `patch-package` patches). Commit +the regenerated `dist/` alongside the source change so the patch stays in sync. +`yarn packages` (watch mode) is fine during active development — the watchers +hot-rebuild on save — but `yarn packages:build` is the one-shot pre-commit step. + +The remaining `packagesDev/*` directories (`prettier-config`, `eslint-config`, +`typescript-config`, `browserslist-config`, `misc`) are config-only — no compile +step, no rebuild needed. + +`yarn packages:build` also regenerates +`packagesDev/next-config/dist/generated/config.js` because zod-schema codegen +runs alongside `next-config`'s build. That diff is normally unrelated to your +change and should be discarded with +`git checkout -- packagesDev/next-config/dist/generated/config.js` before +committing — only keep it when your change actually touches the config schema. + +### Testing + +```bash +yarn test # Run all tests (vitest) +yarn test:watch # Watch mode +yarn test packages/foo # Run tests matching a path +``` + +Tests use Vitest with +`include: ['**/__tests__/**/*.ts', '**/*.test.ts', '**/*.test.tsx']`. + +#### Playwright (E2E) + +End-to-end tests live next to the package they exercise, named +`.playwright.ts` (e.g. +`packages/magento-product/test/youtubeEmbedInGallery.playwright.ts`, +`packages/magento-customer/test/authentication.playwright.ts`). They're +picked up by `playwright.config.ts` via `testMatch: ['**/*.playwright.ts']` +and they exercise a real running example storefront — there is no jsdom, +no mocked Apollo cache. + +One-time setup (only needed if you've never run Playwright on this machine +or the browsers are stale): + +```bash +npx playwright install chromium # or `npx playwright install` for all browsers +``` + +Day-to-day workflow: + +```bash +# Terminal A — start the storefront the test will hit +yarn workspace @graphcommerce/magento-graphcms dev + +# Terminal B — run the suite (default project is chrome, headed) +yarn playwright +# Or a single test, headless, with a non-default port / URL: +URL=http://localhost:3210 npx playwright test \ + packages/magento-product/test/youtubeEmbedInGallery.playwright.ts \ + --project=chrome --reporter=line +``` + +- `URL` overrides the `baseURL` for every test (`page.goto('/p/foo')` + resolves against `$URL/p/foo`). +- `PLAYWRIGHT_LOCALES=nl,de` generates extra `-` projects + that target `$URL/` — opt-in only because most tests are + locale-agnostic. +- `test-results/` and `playwright-report/` are gitignored — both are local + artifacts that the runner regenerates on every invocation. + +Backend assumptions: tests run against the Magento endpoint configured in +`examples/magento-graphcms/graphcommerce.config.ts`. They hardcode SKUs / +URL keys that are present in the GraphCommerce demo backend +(`configurator.reachdigital.dev`); when running against a different backend +either override via env vars (the gallery test reads `PRODUCT_URL` and +`EXPECTED_YOUTUBE_ID`) or skip backend-specific tests. + +### Linting & Type Checking + +**Important:** You can **only type check an example, never the whole repo**. +Codegen generates types per-example (`.mesh/`, `.gql.ts`) and a private/optional +package's fragments only land in the generated types of an example that +activates the package. Always run `tsgo` from inside an example directory. + +The full workflow for type checking — including any optional/private packages +you want exercised — is: + +1. **Activate the package** by adding it to `PRIVATE_ADDITIONAL_DEPENDENCIES` + in the example's `.env` (comma-separated, no spaces). Yarn workspaces also + needs the package linked, so run `yarn install` from the repo root if the + package is new or hasn't been installed before. +2. **Run codegen** so the package's `.graphql` fragments are injected into the + example's generated `.gql.ts` files: + ```bash + cd examples/magento-graphcms + yarn codegen + ``` +3. **Run `tsgo`** from the same example directory: + ```bash + npx --package=@typescript/native-preview tsgo --noEmit -p . + ``` + +Skipping steps 1–2 produces misleading "field does not exist" errors on +injected fragments, because the example's types still reflect the previously +activated set of packages. Running `tsgo` from the repo root fails for the same +reason — there is no single project-wide type-check, only per-example checks. + +```bash +yarn eslint:lint # ESLint across all TS/TSX +yarn eslint:fix # ESLint with auto-fix +yarn prettier:fix # Prettier formatting +``` + +### Code Generation + +```bash +# In an example directory — regenerate GraphQL Mesh + codegen types +yarn workspace @graphcommerce/magento-graphcms codegen + +# Individual steps: +graphcommerce codegen # Generate config types +gc-mesh build # Build GraphQL Mesh (merges Magento + Hygraph schemas) +gc-gql-codegen # Generate TypeScript from .graphql files → .gql.ts +``` + +### Cleaning Up Codegen Interceptors + +Codegen wraps any module that has a matching plugin with an interceptor +(`*.tsx` rewritten to a re-export, original saved as `*.original.tsx`). When +you change `PRIVATE_ADDITIONAL_DEPENDENCIES`, switch branches, or are about to +commit, those wrappers should not end up in `git status`. Restore the +originals with: + +```bash +# Run from any example directory (e.g. examples/magento-graphcms) +graphcommerce cleanup-interceptors +``` + +The command walks every `*.original.*` it finds and restores it back over the +matching wrapped file. **Always run this before committing**, otherwise you +end up with diffs to dozens of `next-ui`, `magento-cart-items`, +`magento-customer`, etc. files that only exist because of your local +`.env`/plugin set. + +### Showcasing New Features + +**Every feature PR must wire the feature into one of the existing example +storefronts so it is visible and presentable on a real page.** A standalone +demo route under `pages/test/*` is **not** a showcase — it lives outside the +real flow, never gets walked by a reviewer, and proves nothing about the +integration. The bar is "if I `yarn workspace @graphcommerce/magento-graphcms +dev` and open the storefront, can I navigate to a place where this feature is +actually used?". + +Concrete patterns by feature kind: + +- **A new UI component** — find the existing page in `examples/magento-graphcms` + (or `examples/magento-open-source`) where it belongs and render it there. A + product video player gets wired into the product page's media gallery, a new + account-menu element into the account layout, a new cart summary block into + the cart page, etc. If the showcase needs backend content (a product with a + YouTube video uploaded, a Magento config flipped on, a Hygraph row created), + call that out in the PR description so the reviewer knows what to configure + before previewing. +- **A new plugin** — wire it where it would actually wrap something, and make + sure the storefront still renders. Activating the package via + `PRIVATE_ADDITIONAL_DEPENDENCIES` is enough wiring as long as the host + component is reachable from a real page in the example. +- **A new GraphQL fragment / mutation** — exercise it from the page or + component that needs the data; don't ship the fragment alone. + +The PR description's "Test plan" must name the storefront URL (or click path) +the reviewer should open to see the feature working. + +### i18n + +```bash +yarn workspace @graphcommerce/magento-graphcms lingui # Extract translation strings +``` + +### Changesets & Versioning + +Every PR needs a `.changeset/.md` file — the changesets bot otherwise +blocks the PR with `⚠️ No Changeset found`. Frontmatter lists the affected +packages and the bump type, followed by a short description: + +```md +--- +'@graphcommerce/magento-customer': minor +'@graphcommerce/magento-store': patch +--- + +Short, complete-sentence description of what changed and why. +``` + +**Bump types — almost always `patch` or `minor`:** + +- `patch` — bug fixes, internal refactors with no API change, doc tweaks, dist + regenerations. Most PRs. +- `minor` — additive changes: new components, new optional props, new config + options, new exports. Default for new features. +- `major` — **avoid almost always.** A major release ships with downstream + migration cost (consumer projects rewrite code), an upgrade guide, and + coordinated marketing/release communication. Reserve for genuinely breaking + changes that can't be expressed additively, and coordinate with the + maintainers before opening the PR. When the change looks breaking, first ask: + can it be a new optional prop / new export that defaults to the old behavior? + If yes, that's a `minor`. + +**Placeless changes go in `@graphcommerce/misc`.** For docs-only PRs, repo-wide +tooling, root-level scripts, CLAUDE.md updates, GitHub workflows — anything that +doesn't logically bump a published package — target `@graphcommerce/misc` as +`patch`: + +```md +--- +'@graphcommerce/misc': patch +--- + +Document . +``` + +`@graphcommerce/misc` (`packagesDev/misc/`) is intentionally empty — it has no +consumers, so the published changelog stays clean. + +**Stuck release recovery hint:** when a canary publish fails after versions are +already bumped, remove the not-yet-published changeset IDs from +`.changeset/pre.json`'s `changesets` array and push — the next run will +re-consume them and retry the publish. + +## Architecture + +### Directory Layout + +- **`packages/`** — Core feature packages (`@graphcommerce/*`): UI components, + Magento integrations (cart, checkout, product, search, payment), Hygraph/CMS, + analytics, Algolia search +- **`packagesDev/`** — Build tooling: `next-config` (the framework's core build + system), codegen plugins, ESLint/Prettier/TypeScript configs, CLI +- **`examples/`** — Full storefronts: `magento-graphcms` (primary), + `magento-open-source` +- **`docs/`** — Documentation site + +### GraphQL Mesh (Schema Federation) + +Multiple GraphQL/REST sources are combined into a single schema via GraphQL +Mesh. The merged schema is generated into `examples/*/.mesh/index.ts`. Sources +include Magento GraphQL and Hygraph, with transforms for field renaming, +filtering, and type merging. + +### GraphQL Codegen + +`.graphql` files throughout packages generate co-located `.gql.ts` files +containing TypeScript types and Apollo Client hooks. The **fragment injection +system** uses an `@inject` directive to extend existing queries: + +```graphql +fragment MyCustomData on ProductInterface @inject(into: ["ProductListItem"]) { + my_custom_attribute +} +``` + +### Plugin System (Zero-Runtime Interception) + +Plugins live in `plugins/` directories and are auto-discovered at build time. +They work via webpack/Turbopack interceptors — no runtime cost. Three types: + +- **`component`** — Wraps a React component. Receives `Prev` as a prop to render + the original. +- **`function`** — Intercepts a function call. Receives `prev` to call the + original. +- **`replace`** — Completely replaces an export. + +Each plugin exports a `config: PluginConfig` with `type` and `module` (the +`@graphcommerce/*` package to intercept). Conditional plugins use `ifConfig`. +Restart dev server after adding the first plugin; hot-reload works after that. + +### Configuration + +`graphcommerce.config.ts` in each example defines storefront config (Magento +endpoint, Hygraph endpoint, locales, feature flags). Required fields: +`canonicalBaseUrl`, `magentoEndpoint`, `magentoVersion` (245/246/247), +`hygraphEndpoint`, `storefront[]` (locale + magentoStoreCode). + +Access config values in code: + +```tsx +import { cartDisplayPricesInclTax } from '@graphcommerce/next-config/config' +import { useStorefrontConfig } from '@graphcommerce/next-ui' + +// Global value +const global = cartDisplayPricesInclTax + +// Per-storefront with fallback +const scoped = + useStorefrontConfig().cartDisplayPricesInclTax ?? cartDisplayPricesInclTax +``` + +Extend the config schema by creating a `graphql/Config.graphqls` file: + +```graphql +extend input GraphCommerceConfig { + myConfig: String @public + myApiSecret: String +} +extend input GraphCommerceStorefrontConfig { + myField: Boolean @public +} +``` + +A field without `@public` is server-only. The `browser` export condition of +`@graphcommerce/next-config/config` resolves to a file with only the `@public` +fields, so Turbopack stops the build on a browser import of a server-only field. Add `@public` only to fields that browser code +reads, and never to secrets. Put `@public` on scalar and enum fields, also in +nested inputs. In the browser, a server-only field of a storefront throws in +development, and a server-only field of a section is `undefined`. + +You can also extend existing enums from other packages: + +```graphql +extend enum WebsitePermissions { + CUSTOMER_ONLY +} +``` + +### Environment Variables (.env) + +Each example directory has a `.env` file. Two types of env vars are used: + +**`GC_*` — GraphCommerce config overrides.** Any config value can be overridden: + +- Convert camelCase to SCREAMING*SNAKE_CASE, prefix with `GC*` +- Arrays indexed with `_0`, `_1`: `GC_STOREFRONT_0_LOCALE="en"` +- Nested objects with `_`: `GC_DEBUG_PLUGIN_STATUS="1"` +- Booleans: `"1"` / `"true"` / `"0"` / `"false"` +- Objects as JSON: `GC_PERMISSIONS='{"cart":"CUSTOMER_ONLY"}'` + +Examples: + +```bash +GC_MAGENTO_ENDPOINT="https://magento.example.com/graphql" +GC_MAGENTO_VERSION="247" +GC_LIMIT_SSG="1" +GC_PREVIEW_SECRET="mySecret" +GC_GOOGLE_RECAPTCHA_KEY="6Ld..." +GC_GRAPHQL_MESH_EDIT_MODE="1" +``` + +Export current config to env vars: `yarn graphcommerce export-config` + +**`PRIVATE_ADDITIONAL_DEPENDENCIES` — Activate optional packages.** +Comma-separated list of `@graphcommerce/*` packages to include in dependency +resolution without adding them to `package.json`. This enables their plugins, +GraphQL fragments, and mesh config extensions: + +```bash +PRIVATE_ADDITIONAL_DEPENDENCIES="@graphcommerce/magento-search-overlay,@graphcommerce/b2b-permissions" +``` + +This is also used in the root `package.json` test scripts to include optional +packages during testing. The resolution system only picks up packages with +`graphcommerce` in the name (configurable via `PRIVATE_PACKAGE_NAMESPACES`). + +## Plugin System (Development Guide) + +**When building new features, prefer plugins over direct code modifications.** +Plugins keep functionality modular and independent from the core codebase. + +### Creating a Plugin + +Place files in `plugins/` directory (in your example project or in a package). +Each plugin file exports a `config` object and the named export to intercept. + +**Component plugin** — wrap a React component: + +```tsx +import type { ProductListItemProps } from '@graphcommerce/magento-product' +import type { PluginConfig, PluginProps } from '@graphcommerce/next-config' + +export const config: PluginConfig = { + type: 'component', + module: '@graphcommerce/magento-product', +} + +export function ProductListItem(props: PluginProps) { + const { Prev, ...rest } = props + return +} +``` + +**Function plugin** — intercept a function: + +```tsx +import type { graphqlConfig as graphqlConfigType } from '@graphcommerce/graphql' +import type { FunctionPlugin, PluginConfig } from '@graphcommerce/next-config' + +export const config: PluginConfig = { + type: 'function', + module: '@graphcommerce/graphql', +} + +export const graphqlConfig: FunctionPlugin = ( + prev, + conf, +) => { + const results = prev(conf) + return { ...results, links: [...results.links, myCustomLink] } +} +``` + +**Replacement plugin** — completely replace an export (no access to original): + +```tsx +export const config: PluginConfig = { + type: 'replace', + module: '@graphcommerce/magento-product', +} + +export function ProductListCount(props: ProductCountProps) { + return
{props.total_count}
+} +``` + +### Plugin Rules + +- The exported function/component name must match the target export exactly +- Restart dev server after creating the first plugin; hot-reload works after + that +- Plugin loading order follows `package.json` dependency order; local plugins + wrap last (closest to the original) +- Auto-discovered via glob: `${packageLocation}/plugins/**/*.{ts,tsx}` +- Only packages with `graphcommerce` in the name are scanned + +### Conditional Plugins + +Load a plugin only when a config value is truthy or matches a specific value: + +```tsx +export const config: PluginConfig = { + type: 'component', + module: '@graphcommerce/magento-product', + ifConfig: 'demoMode', // loads when demoMode is truthy +} + +// Or match a specific value: +export const config: PluginConfig<'compareVariant'> = { + type: 'component', + module: '@graphcommerce/magento-product', + ifConfig: ['compareVariant', 'CHECKBOX'], +} +``` + +### Extending GraphQL Queries via Fragment Injection + +Instead of modifying queries directly, inject fields into existing fragments: + +```graphql +fragment MyCustomFragment on ProductInterface +@inject(into: ["ProductListItem"]) { + my_custom_attribute +} +``` + +After running `yarn codegen`, `my_custom_attribute` will be available in +`ProductListItem.gql.ts` and all queries that use that fragment. + +### Debugging Plugins + +Enable with `debug.pluginStatus: true` in config or `GC_DEBUG_PLUGIN_STATUS=1` +in env. This logs which plugins are enabled/disabled during build. + +## Authentication & Cookies + +Customer auth tokens are stored in Apollo Client cache. Auth state is tracked +via the CSS flags system: the `private-query` flag in the `gc-flags` cookie +indicates a logged-in user. This is set automatically by `setCssFlag` on sign-in +and cleared by `removeCssFlag` on sign-out. The cookie is readable both +client-side and server-side (in Next.js proxy). + +**Cookie utility** (`@graphcommerce/next-ui`): + +```tsx +import { cookie } from '@graphcommerce/next-ui' +cookie('name', 'value') // set +cookie('name') // read +cookie('name', null) // delete +``` + +### CSS Flags + +CSS flags set `data-*` attributes on `` for instant visual toggling before +JS hydrates. Stored in a `gc-flags` cookie (JSON), restored via a blocking +script in `_document.tsx` (`getCssFlagsInitScript()`) that reads +`document.cookie`. The cookie is also readable server-side in Next.js proxy. + +```tsx +import { + setCssFlag, + removeCssFlag, + cssFlag, + cssNotFlag, +} from '@graphcommerce/next-ui' + +setCssFlag('private-query', true) +// In MUI sx: { [cssFlag('private-query')]: { display: 'none' } } +// In MUI sx: { [cssNotFlag('private-query')]: { display: 'none' } } +``` + +The `private-query` flag is set on sign-in, cleared on sign-out. Used by +`GuestOrCustomerMask` and `PrivateQueryMask` to show/hide customer-specific +content without waiting for React hydration. + +### Permissions System + +Permissions are configured via `GraphCommercePermissions` input type in +`Config.graphqls`. Set globally and overridable per storefront: + +```tsx +import { permissions } from '@graphcommerce/next-config/config' +import { useStorefrontConfig } from '@graphcommerce/next-ui' +const perm = + useStorefrontConfig().permissions?.website ?? + permissions?.website ?? + 'ENABLED' +``` + +Existing enums: `WebsitePermissions`, `CustomerAccountPermissions`, +`CartPermissions`, `BillingAddressPermissions`. Extendable via `extend enum` in +package `Config.graphqls` files. + +### GuestOrCustomerMask + +Component for showing different content based on auth state, with CSS-flag-based +masking to avoid flash of wrong content: + +```tsx +} + skeleton={} + loggedIn={} +/> +``` + +## Tech Stack + +- Next.js with Turbopack, React 19, TypeScript 5.9 +- Apollo Client 4 for GraphQL +- MUI (Material-UI) + Emotion for styling +- Lingui for i18n +- Framer Motion for animations +- React Hook Form for forms +- Changesets for versioning/releases diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 3759b5ef1e7..39af9a9b1c7 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,159 @@ # Change Log +## 11.0.0 + +## 11.0.0-canary.75 + +## 11.0.0-canary.74 + +## 11.0.0-canary.73 + +## 11.0.0-canary.72 + +## 11.0.0-canary.71 + +## 11.0.0-canary.70 + +## 11.0.0-canary.69 + +## 11.0.0-canary.68 + +## 11.0.0-canary.67 + +## 11.0.0-canary.66 + +## 11.0.0-canary.65 + +## 11.0.0-canary.64 + +## 11.0.0-canary.63 + +## 11.0.0-canary.62 + +## 11.0.0-canary.61 + +## 11.0.0-canary.60 + +## 11.0.0-canary.59 + +## 11.0.0-canary.58 + +## 11.0.0-canary.57 + +## 11.0.0-canary.56 + +## 11.0.0-canary.55 + +## 11.0.0-canary.54 + +## 11.0.0-canary.53 + +## 11.0.0-canary.52 + +## 11.0.0-canary.51 + +## 11.0.0-canary.50 + +## 11.0.0-canary.49 + +## 11.0.0-canary.48 + +## 11.0.0-canary.47 + +## 11.0.0-canary.46 + +## 11.0.0-canary.45 + +## 10.1.0-canary.44 + +## 10.1.0-canary.43 + +## 10.1.0-canary.42 + +## 10.1.0-canary.41 + +## 10.1.0-canary.40 + +## 10.1.0-canary.39 + +## 10.1.0-canary.38 + +## 10.1.0-canary.37 + +## 10.1.0-canary.36 + +## 10.1.0-canary.35 + +## 10.1.0-canary.34 + +## 10.1.0-canary.33 + +## 10.1.0-canary.32 + +## 10.1.0-canary.31 + +## 10.1.0-canary.30 + +## 10.1.0-canary.29 + +## 10.1.0-canary.28 + +## 10.1.0-canary.27 + +## 10.1.0-canary.26 + +## 10.1.0-canary.25 + +## 10.1.0-canary.24 + +## 10.1.0-canary.23 + +## 10.1.0-canary.22 + +## 10.1.0-canary.21 + +## 10.1.0-canary.20 + +## 10.1.0-canary.19 + +## 10.1.0-canary.18 + +## 10.1.0-canary.17 + +## 10.1.0-canary.16 + +## 10.1.0-canary.15 + +## 10.1.0-canary.14 + +## 10.1.0-canary.13 + +## 10.1.0-canary.12 + +## 10.1.0-canary.11 + +## 10.1.0-canary.10 + +## 10.1.0-canary.9 + +## 10.1.0-canary.8 + +## 10.1.0-canary.7 + +## 10.1.0-canary.6 + +## 10.1.0-canary.5 + +## 10.1.0-canary.4 + +## 10.1.0-canary.3 + +## 10.0.4-canary.2 + +## 10.0.4-canary.1 + +## 10.0.4-canary.0 + ## 10.0.3 ## 10.0.3-canary.0 diff --git a/docs/framework/config.md b/docs/framework/config.md index 8375d7f434c..8add87494d5 100644 --- a/docs/framework/config.md +++ b/docs/framework/config.md @@ -48,6 +48,20 @@ You can also use the configuration in your `.meshrc.yml` by accessing endpoint: '{graphCommerce.magentoEndpoint}' ``` +## Public and server-only configuration + +A field with `@public` is available in the browser. A field without `@public` is server-only: +code that runs in the browser cannot read it. + +- Turbopack stops the build when browser code imports a server-only field from + `@graphcommerce/next-config/config`. +- A server-only field of a storefront, such as `useStorefrontConfig().myServerField`, throws in + development and returns `undefined` in production. +- A server-only field of a section, such as `algolia.searchOnlyApiKey`, is `undefined`. + +Put `@public` on fields with a scalar or enum type. In the browser, a field with an input type, such +as `debug: GraphCommerceDebugConfig`, contains only the `@public` fields of that input. + ## Environment variables to override configuration Configuration values can be overwriten by environment variables, with the following rules: @@ -72,10 +86,11 @@ Create a graphql/Config.graphqls file in your project and extend the GraphCommer ```graphql extend input GraphCommerceConfig { - myConfig: String # or Boolean, or Int, or Float, make required with `!` + myConfig: String @public # or Boolean, or Int, or Float, make required with `!` + myApiSecret: String } extend input GraphCommerceStorefrontConfig { - myField: Boolean + myField: Boolean @public } ``` @@ -285,6 +300,10 @@ GC_HYGRAPH_WRITE_ACCESS_TOKEN="AccessTokenFromHygraph" yarn graphcommerce hygraph-migrate ``` +#### imageQuality: [ImageQualityConfig](#ImageQualityConfig) = `{ content: 75, product: 52 }` + +Sets the quality of the images of `` and `imageUrl()`. + #### limitSsg: boolean Limit the static generation of SSG when building. @@ -488,6 +507,18 @@ Allows the option to require login or completely disable certain sections of the Allow the site to be indexed by search engines. If false, the robots.txt file will be set to disallow all. +### ImageQualityConfig + +The quality of each kind of image. Choose the kind with `quality` on `` or `imageUrl()`, for example `quality='product'`. + +#### content: number = `75` + +The quality of a content image, such as a banner or another CMS image. `quality='content'` is the default for `` without the quality prop. + +#### product: number = `52` + +The quality of a product image from the Magento catalog. + ### MagentoConfigurableVariantValues Options to configure which values will be replaced when a variant is selected on the product page. diff --git a/docs/framework/mesh.md b/docs/framework/mesh.md index 082ecbb913e..1a9654a47b9 100644 --- a/docs/framework/mesh.md +++ b/docs/framework/mesh.md @@ -92,3 +92,35 @@ To make sure changes are picked up during development set the config value `graphqlMeshEditMode: true` in your graphcommerce.config.js or set the env variable `GC_GRAPHQL_MESH_EDIT_MODE=1`. This _will_ make the frontend considerably slower. + +## Routing Magento traffic over an internal network + +When the frontend runs next to Magento — e.g. both in the same Kubernetes +cluster — the mesh's server-side Magento requests (GraphQL and REST) can be +routed directly to an internal Service instead of hairpinning over the public +load balancer. Set in the **runtime** environment (e.g. a Kubernetes +ConfigMap): + +``` +GC_MAGENTO_ENDPOINT_SERVER=http://varnish.magento-namespace.svc.cluster.local +``` + +Every request whose URL starts with the origin of `GC_MAGENTO_ENDPOINT` is +rewritten to this origin, so both the GraphQL endpoint and the REST endpoint +are covered. `GC_MAGENTO_ENDPOINT` itself stays the public URL: it keeps +feeding build-time schema introspection, `images.remotePatterns` and the media +URLs Magento generates. The rewrite also sends `X-Forwarded-Proto: https`, +which the TLS-terminating proxy would normally add — Magento needs it to keep +generating `https://` URLs. + +Caveats: + +- Both `GC_MAGENTO_ENDPOINT_SERVER` and `GC_MAGENTO_ENDPOINT` must be present + in the runtime environment; the rewrite happens per request at runtime. +- Do **not** set `GC_MAGENTO_ENDPOINT_SERVER` in the build environment: schema + introspection (`gc-mesh build`) and static generation run where the internal + endpoint is typically not reachable. Unset, the feature is a no-op. +- Point it at the Varnish service (not the webserver directly) to keep + Magento's GraphQL full-page cache in the path. +- When a NetworkPolicy guards the Magento namespace, allow ingress from the + frontend namespace to the Varnish pods. diff --git a/docs/getting-started/create.md b/docs/getting-started/create.md index e8e24227fb5..db1daf209d0 100644 --- a/docs/getting-started/create.md +++ b/docs/getting-started/create.md @@ -11,7 +11,7 @@ start building. ### Preparations - MacOS, Windows with WSL2 or Linux -- Install and use node 20: `nvm install 20` or `nvm use 20` +- Install and use node 22 or 24: `nvm install 24` or `nvm use 24` - Install yarn: `corepack enable` ## Step 1: Create a GraphCommerce app diff --git a/docs/package.json b/docs/package.json index 2ab2fe86e60..b9be2e92442 100644 --- a/docs/package.json +++ b/docs/package.json @@ -2,10 +2,10 @@ "name": "@graphcommerce/docs", "homepage": "https://www.graphcommerce.org/docs", "repository": "github:graphcommerce-org/graphcommerce/docs", - "version": "10.0.3", + "version": "11.0.0", "sideEffects": true, "peerDependencies": { - "@graphcommerce/prettier-config-pwa": "^10.0.3" + "@graphcommerce/prettier-config-pwa": "^11.0.0" }, "prettier": "@graphcommerce/prettier-config-pwa" } diff --git a/docs/upgrading/graphcommerce-10-to-11.md b/docs/upgrading/graphcommerce-10-to-11.md new file mode 100644 index 00000000000..2a479a7cc7a --- /dev/null +++ b/docs/upgrading/graphcommerce-10-to-11.md @@ -0,0 +1,220 @@ +# Upgrading from GraphCommerce 10 to 11 + +GraphCommerce 11 drops support for Node.js 20 (EOL April 2026) and aligns the +framework with the +[Node.js release schedule](https://nodejs.org/en/about/previous-releases). The +minimum supported version is now Node.js 22, and Node.js 24 is recommended. +Configuration fields are server-only, unless their definition has `@public`. + +## Step 1: Upgrade your local Node.js + +| Version | Status as of May 2026 | +| -------------------- | ----------------------------------------------------- | +| Node.js 20 (Iron) | **EOL** — no longer supported | +| Node.js 22 (Jod) | Maintenance LTS through ~April 2027 — **new minimum** | +| Node.js 24 (Krypton) | Active LTS since Oct 2025 — **recommended** | +| Node.js 26 | Current since May 2026 — supported | + +Pick whichever LTS you prefer; `>=22.19.0 <27.0.0` is the accepted range. + +With `nvm`: + +```bash +nvm install 24 +nvm use 24 +``` + +Then re-enable corepack so the project's pinned yarn version is picked up: + +```bash +corepack enable +``` + +## Step 2: Bump `engines.node` in your project + +If you copied the example's `engines.node` into your own `package.json`, update +it from the old GC 10 value to the GC 11 range: + +```diff + "engines": { +- "node": ">=20 <24.0.0" ++ "node": ">=22.19.0 <27.0.0" + } +``` + +If your project doesn't set `engines.node` itself, nothing to do — the engine +constraint is inherited from `@graphcommerce/magento-graphcms` (or whichever +example you bootstrapped from). + +## Step 3: Update your CI / hosting + +Anywhere that pins a Node version, move from 20 to 22 or 24: + +- **GitHub Actions** (`.github/workflows/*.yml`): + + ```diff + - uses: actions/setup-node@v4 + with: + - node-version: 20 + + node-version: 24 + ``` + + If you use `actions/setup-node@v3`, bump it to `@v4` while you're there. + +- **Vercel** — set the project's "Node.js Version" to 22.x or 24.x under + Settings → General. Vercel's `20.x` option will be removed in line with Node's + own EOL. + +- **Docker images** — update any `FROM node:20…` to `FROM node:22-…` or + `FROM node:24-…` (alpine/slim/bookworm variants all work). + +- **Devcontainer / Gitpod / Codespaces** — Gitpod users can switch their + `.gitpod.yml` bootstrap from `nvm install 18` (or 20) to `nvm install 24`. + Devcontainer setups that use `"lts": true` resolve to v24 automatically and + need no change. + +## Step 4: Add `@public` to configuration fields that browser code reads + +1. In `graphql/Config.graphqls`, add `@public` to each scalar or enum field that + browser code reads, also in nested inputs. Keep secrets without `@public`. + + ```diff + extend input GraphCommerceConfig { + - myFeatureEnabled: Boolean + + myFeatureEnabled: Boolean @public + myApiSecret: String + myIntegration: MyIntegrationConfig + } + input MyIntegrationConfig { + - apiUrl: String + + apiUrl: String @public + apiSecret: String + } + extend input GraphCommerceStorefrontConfig { + - myStoreLabel: String + + myStoreLabel: String @public + } + ``` + +2. Run codegen and build: + + ```bash + yarn codegen + yarn build + ``` + +3. For each error like this one, add `@public` to the field, or move the read to + server code: + + ``` + Export myApiSecret doesn't exist in target module + The export myApiSecret was not found in module [project]/node_modules/@graphcommerce/next-config/dist/generated/configValues/publicOnly/index.js [client] (ecmascript). + ``` + + The error names the file that imports the field. When that file is a shared + module, move the function that reads the field to a module that only server + code imports: + + ```ts + // lib/myApi.server.ts + import { myApiSecret } from '@graphcommerce/next-config/config' + + export const fetchFromMyApi = (path: string) => + fetch(`https://api.example.com${path}`, { + headers: { Authorization: `Bearer ${myApiSecret}` }, + }) + ``` + +4. Run `yarn dev` and open the pages that use your fields. A server-only field + of a section, such as `myIntegration.apiSecret`, is `undefined` in browser + code. A server-only field of a storefront, such as + `useStorefrontConfig().myServerField`, throws in browser code: + + ``` + storefront[].myServerField is server-only. Read it on the server or add @public to GraphCommerceStorefrontConfig.myServerField in Config.graphqls. + ``` + +Codegen lists the server-only fields at the top of each file in +`node_modules/@graphcommerce/next-config/dist/generated/configValues/publicOnly`. + +## Step 5: Import from `motion/react` + +GraphCommerce 11 animates with `motion`. Change the `framer-motion` imports in +your own files: + +```bash +grep -rlE "from ['\"]framer-motion['\"]" --include='*.ts' --include='*.tsx' --exclude-dir=node_modules . \ + | xargs perl -pi -e "s/from (['\"])framer-motion(['\"])/from \1motion\/react\2/g" +``` + +## Step 6: Import the Lingui macros from `@lingui/react/macro` and `@lingui/core/macro` + +Lingui 6 has no `@lingui/macro` package. Import `Trans`, `Plural`, `Select`, +`SelectOrdinal` and `useLingui` from `@lingui/react/macro`, and `t`, `msg`, +`plural`, `select` and `defineMessage` from `@lingui/core/macro`: + +```diff +-import { Trans, t } from '@lingui/macro' ++import { t } from '@lingui/core/macro' ++import { Trans } from '@lingui/react/macro' +``` + +Find the files to change: + +```bash +grep -rl "@lingui/macro" --include='*.ts' --include='*.tsx' --exclude-dir=node_modules . +``` + +## Step 7: Check `configurableVariantValues` + +When `graphcommerce.config.ts` does not set `configurableVariantValues`, the +default `{ url: true, content: true }` applies. When a shopper selects a variant +on the product page, the URL changes to the URL of the variant and the page +shows the name, description, short description and meta data of the variant. + +To keep the values of the configurable product: + +```ts +// graphcommerce.config.ts +configurableVariantValues: { url: false, content: false }, +``` + +## Step 8: Set `quality='product'` on catalog images + +`imageQuality` sets the quality of each kind of image. `quality='content'` is +for content images, such as CMS images, and is the default, with quality 75. +`quality='product'` is for product images from the Magento catalog, with +quality 52. Add `quality='product'` to each `` in your own components +that shows a product image: + +```diff + +``` + +To change the qualities: + +```ts +// graphcommerce.config.ts +imageQuality: { content: 80, product: 52 }, +``` + +## Step 9: Reinstall + +After upgrading Node: + +```bash +rm -rf node_modules .next +yarn install +yarn codegen +yarn dev +``` + +## Notes + +- Node 22 will move from Maintenance LTS to EOL around April 2027 — start + planning the move to Node 24 (or 26) before then. +- Node 25/26 are non-LTS "current" releases. They're accepted by the engine + range, but production deployments should generally stay on the latest LTS. diff --git a/docs/upgrading/readme.md b/docs/upgrading/readme.md index d363c1c2ab1..480e77596cc 100644 --- a/docs/upgrading/readme.md +++ b/docs/upgrading/readme.md @@ -110,6 +110,7 @@ After resolving the diff issues, manually process upgrade instructions: - [Upgrading to GraphCommerce 7 to 8](../upgrading/graphcommerce-7-to-8.md) - [Upgrading to GraphCommerce 8 to 9](../upgrading/graphcommerce-8-to-9.md) - [Upgrading to GraphCommerce 9 to 10](../upgrading/graphcommerce-9-to-10.md) +- [Upgrading to GraphCommerce 10 to 11](../upgrading/graphcommerce-10-to-11.md) Run and validate your local environment: diff --git a/examples/__tests__/ProductPage2.test.ts b/examples/__tests__/ProductPage2.test.ts new file mode 100644 index 00000000000..46d4d444eb7 --- /dev/null +++ b/examples/__tests__/ProductPage2.test.ts @@ -0,0 +1,28 @@ +import { readFileSync } from 'node:fs' +import { fileURLToPath } from 'node:url' +import type { FieldNode, OperationDefinitionNode, SelectionSetNode } from 'graphql' +import { Kind, parse } from 'graphql' +import { describe, expect, it } from 'vitest' + +const fields = (selectionSet?: SelectionSetNode) => + (selectionSet?.selections ?? []).filter((s): s is FieldNode => s.kind === Kind.FIELD) + +describe('ProductPage2', () => { + // `products` and `relatedUpsells` write to one cache field. Without `id` in both, Apollo Client + // keeps one of the two, and reading the query back misses the related products and reviews. + it.each(['magento-graphcms', 'magento-open-source', 'magento-storyblok'])( + '%s requests the id in relatedUpsells', + (example) => { + const file = new URL(`../${example}/graphql/ProductPage2.graphql`, import.meta.url) + const [query] = parse(readFileSync(fileURLToPath(file), 'utf8')) + .definitions as OperationDefinitionNode[] + + const relatedUpsells = fields(query.selectionSet).find( + (field) => field.alias?.value === 'relatedUpsells', + ) + const items = fields(relatedUpsells?.selectionSet).find((f) => f.name.value === 'items') + + expect(fields(items?.selectionSet).map((field) => field.name.value)).toContain('id') + }, + ) +}) diff --git a/examples/__tests__/checkoutAdded.test.ts b/examples/__tests__/checkoutAdded.test.ts new file mode 100644 index 00000000000..c49b1c061ed --- /dev/null +++ b/examples/__tests__/checkoutAdded.test.ts @@ -0,0 +1,35 @@ +import { readFileSync } from 'node:fs' +import { fileURLToPath } from 'node:url' +import ts from 'typescript' +import { describe, expect, it } from 'vitest' + +describe('pages/checkout/added', () => { + // A scrolling focus() puts the overlay in its open position before OverlayBase animates it. + it.each(['magento-graphcms', 'magento-open-source', 'magento-storyblok'])( + '%s focuses the heading without a scroll', + (example) => { + const file = fileURLToPath(new URL(`../${example}/pages/checkout/added.tsx`, import.meta.url)) + const source = ts.createSourceFile( + file, + readFileSync(file, 'utf8'), + ts.ScriptTarget.Latest, + true, + ts.ScriptKind.TSX, + ) + + const focusOptions: (string | undefined)[] = [] + const visit = (node: ts.Node) => { + if ( + ts.isCallExpression(node) && + ts.isPropertyAccessExpression(node.expression) && + node.expression.name.text === 'focus' + ) + focusOptions.push(node.arguments[0]?.getText(source)) + ts.forEachChild(node, visit) + } + visit(source) + + expect(focusOptions).toEqual(['{ preventScroll: true }']) + }, + ) +}) diff --git a/examples/magento-graphcms/.gitignore b/examples/magento-graphcms/.gitignore index 7ff2e15df4d..5ed613d72b1 100644 --- a/examples/magento-graphcms/.gitignore +++ b/examples/magento-graphcms/.gitignore @@ -38,6 +38,7 @@ pages/account/payment-tokens.tsx pages/downloadable/download/link/id/\[id\].tsx pages/downloadable/download/linkSample/link_id/\[id\].tsx pages/downloadable/download/sample/sample_id/\[id\].tsx +pages/private.tsx pages/test/\[\[...url\]\].tsx pages/test/buttons.tsx pages/test/form-elements.tsx @@ -48,4 +49,5 @@ pages/test/sheet.tsx pages/test/slider.tsx pages/test/typography.tsx pages/test/usebacklink/\[\[...url\]\].tsx +proxy.ts # end managed by: graphcommerce diff --git a/examples/magento-graphcms/CHANGELOG.md b/examples/magento-graphcms/CHANGELOG.md index f0b4f49677e..35fff3a0981 100644 --- a/examples/magento-graphcms/CHANGELOG.md +++ b/examples/magento-graphcms/CHANGELOG.md @@ -1,5 +1,245 @@ # Change Log +## 11.0.0 + +### Major Changes + +- [#2626](https://github.com/graphcommerce-org/graphcommerce/pull/2626) [`e2c9f9b`](https://github.com/graphcommerce-org/graphcommerce/commit/e2c9f9bfc762ed1c4d46f1e24babd6bd658c7343) - **Breaking change — requires Node.js 22 or newer.** This kicks off GraphCommerce 11. + + Node.js 20 hit end-of-life in April 2026, so the framework no longer supports it. `engines.node` is now `>=22.0.0 <27.0.0` across the root and all example storefronts — Node 22 (Maintenance LTS) is the new minimum, Node 24 (Active LTS) is recommended, and Node 26 (current) is also accepted. + + - CI: `release-canary`, `release-main` and `pr-analysis` now run on Node 24. `periodic-build` matrix changed from `[20, 22]` to `[22, 24]`, and `actions/setup-node` bumped from v3 to v4. + - `.gitpod.yml` bootstrap moved from `nvm install 18` to `nvm install 24`. + - Getting-started docs and the three example READMEs now point at Node 22/24. + + See [docs/upgrading/graphcommerce-10-to-11.md](docs/upgrading/graphcommerce-10-to-11.md) for the migration steps. ([@paales](https://github.com/paales)) + +### Minor Changes + +- [#2637](https://github.com/graphcommerce-org/graphcommerce/pull/2637) [`bdaa6ec`](https://github.com/graphcommerce-org/graphcommerce/commit/bdaa6ec6aa2669b74fc6702ad46336db4c154b7c) - Refactored `LayoutNavigation` into composable pieces (`Header`, `HeaderContainer`, `MenuOverlay`, project-local `LayoutDefault`). `LayoutDefault` / `LayoutDefaultProps` in `@graphcommerce/next-ui` are marked `@deprecated`. If you are upgrading and do not want these changes, you can just discard them. This is just a structural change for more ease of use. No visually change. ([@bramvanderholst](https://github.com/bramvanderholst)) + +### Patch Changes + +- [#2716](https://github.com/graphcommerce-org/graphcommerce/pull/2716) [`a91abd7`](https://github.com/graphcommerce-org/graphcommerce/commit/a91abd727e2c42ad26373902be48accb3b3c0ca6) - `pages/checkout/added.tsx` focuses its heading without a scroll, so the overlay slides in after an add to cart. A scrolling `focus()` put the overlay in its open position before `OverlayBase` started the animation. ([@bramvanderholst](https://github.com/bramvanderholst)) + +- [#2731](https://github.com/graphcommerce-org/graphcommerce/pull/2731) [`0a65ed3`](https://github.com/graphcommerce-org/graphcommerce/commit/0a65ed3359950fb29234f1d228e30aef41d72df3) - Fix `yarn install` on CI in a project that starts from an example: `patch-package` stopped, because the patches were for `next` 16.2.6 and `react-hook-form` 7.67.0. ([@bramvanderholst](https://github.com/bramvanderholst)) + +- [#2730](https://github.com/graphcommerce-org/graphcommerce/pull/2730) [`acd08e7`](https://github.com/graphcommerce-org/graphcommerce/commit/acd08e72e504e06b2fbaeb6c9f996606ed5e2b7e) - Fix `next build` in a project that starts from `magento-graphcms`: the type check stopped with `Cannot find module 'vitest'` in two tests of the monorepo. If your project has `__tests__/checkoutAdded.test.ts` or `graphql/ProductPage2.test.ts`, delete these files. ([@bramvanderholst](https://github.com/bramvanderholst)) + +- [#2634](https://github.com/graphcommerce-org/graphcommerce/pull/2634) [`06082ad`](https://github.com/graphcommerce-org/graphcommerce/commit/06082ad47a59217fbdfb24f1a60411e4d0eecd9b) - Make GraphCommerce compatible with Apollo Client 4.2+ by augmenting Apollo's `DefaultOptions` type with the `preview` extension and the SSR clients' `errorPolicy: 'all'` default. ([@bramvanderholst](https://github.com/bramvanderholst)) + +- [#2732](https://github.com/graphcommerce-org/graphcommerce/pull/2732) [`cba75a0`](https://github.com/graphcommerce-org/graphcommerce/commit/cba75a006d4efface5d1149e9cc6ebe3a9b5b9f8) - Added `imageQuality` to `graphcommerce.config.ts`. Choose the kind (`content` or `product`) with `quality` on `` or `imageUrl()`. `quality='content'` is for content images, such as CMS images, and is the default when no quality is given, with quality 75 in place of the previous 52. `quality='product'` is for product images from the Magento catalog, with quality 52. ([@bramvanderholst](https://github.com/bramvanderholst)) + +- [#2623](https://github.com/graphcommerce-org/graphcommerce/pull/2623) [`241576a`](https://github.com/graphcommerce-org/graphcommerce/commit/241576a981fe97595000d74630a8ac8544a5e77f) - Bump Next.js from 16.1.1 to 16.2.6 across the framework and example storefronts. Also bumps the matching `@next/env` and `@next/eslint-plugin-next` pins. ([@paales](https://github.com/paales)) + +- [#2710](https://github.com/graphcommerce-org/graphcommerce/pull/2710) [`59dd648`](https://github.com/graphcommerce-org/graphcommerce/commit/59dd648fadfd7e4598395dcd7fb6f6818fe10179) - `relatedUpsells` in `ProductPage2` requests the `id` of the product. `products` and `relatedUpsells` write to one cache field, and without `id` in both, the cache lost the related products and the reviews. ([@bramvanderholst](https://github.com/bramvanderholst)) + +- [#2636](https://github.com/graphcommerce-org/graphcommerce/pull/2636) [`0af6794`](https://github.com/graphcommerce-org/graphcommerce/commit/0af679485950c934cdadc56b8b3ea8ace9de8ab9) - Fix for codegen issue where codegen would stop (without error) halfway through ([@bramvanderholst](https://github.com/bramvanderholst)) + +## 11.0.0-canary.75 + +## 11.0.0-canary.74 + +## 11.0.0-canary.73 + +## 11.0.0-canary.72 + +## 11.0.0-canary.71 + +## 11.0.0-canary.70 + +## 11.0.0-canary.69 + +### Patch Changes + +- [#2732](https://github.com/graphcommerce-org/graphcommerce/pull/2732) [`cba75a0`](https://github.com/graphcommerce-org/graphcommerce/commit/cba75a006d4efface5d1149e9cc6ebe3a9b5b9f8) - Added `imageQuality` to `graphcommerce.config.ts`. Choose the kind (`content` or `product`) with `quality` on `` or `imageUrl()`. `quality='content'` is for content images, such as CMS images, and is the default when no quality is given, with quality 75 in place of the previous 52. `quality='product'` is for product images from the Magento catalog, with quality 52. ([@bramvanderholst](https://github.com/bramvanderholst)) + +## 11.0.0-canary.68 + +## 11.0.0-canary.67 + +## 11.0.0-canary.66 + +### Patch Changes + +- [#2731](https://github.com/graphcommerce-org/graphcommerce/pull/2731) [`0a65ed3`](https://github.com/graphcommerce-org/graphcommerce/commit/0a65ed3359950fb29234f1d228e30aef41d72df3) - Fix `yarn install` on CI in a project that starts from an example: `patch-package` stopped, because the patches were for `next` 16.2.6 and `react-hook-form` 7.67.0. ([@bramvanderholst](https://github.com/bramvanderholst)) + +## 11.0.0-canary.65 + +### Patch Changes + +- [#2730](https://github.com/graphcommerce-org/graphcommerce/pull/2730) [`acd08e7`](https://github.com/graphcommerce-org/graphcommerce/commit/acd08e72e504e06b2fbaeb6c9f996606ed5e2b7e) - Fix `next build` in a project that starts from `magento-graphcms`: the type check stopped with `Cannot find module 'vitest'` in two tests of the monorepo. If your project has `__tests__/checkoutAdded.test.ts` or `graphql/ProductPage2.test.ts`, delete these files. ([@bramvanderholst](https://github.com/bramvanderholst)) + +## 11.0.0-canary.64 + +## 11.0.0-canary.63 + +## 11.0.0-canary.62 + +## 11.0.0-canary.61 + +## 11.0.0-canary.60 + +## 11.0.0-canary.59 + +## 11.0.0-canary.58 + +## 11.0.0-canary.57 + +### Patch Changes + +- [#2716](https://github.com/graphcommerce-org/graphcommerce/pull/2716) [`a91abd7`](https://github.com/graphcommerce-org/graphcommerce/commit/a91abd727e2c42ad26373902be48accb3b3c0ca6) - `pages/checkout/added.tsx` focuses its heading without a scroll, so the overlay slides in after an add to cart. A scrolling `focus()` put the overlay in its open position before `OverlayBase` started the animation. ([@bramvanderholst](https://github.com/bramvanderholst)) + +## 11.0.0-canary.56 + +## 11.0.0-canary.55 + +## 11.0.0-canary.54 + +## 11.0.0-canary.53 + +### Patch Changes + +- [#2710](https://github.com/graphcommerce-org/graphcommerce/pull/2710) [`59dd648`](https://github.com/graphcommerce-org/graphcommerce/commit/59dd648fadfd7e4598395dcd7fb6f6818fe10179) - `relatedUpsells` in `ProductPage2` requests the `id` of the product. `products` and `relatedUpsells` write to one cache field, and without `id` in both, the cache lost the related products and the reviews. ([@bramvanderholst](https://github.com/bramvanderholst)) + +## 11.0.0-canary.52 + +## 11.0.0-canary.51 + +## 11.0.0-canary.50 + +## 11.0.0-canary.49 + +## 11.0.0-canary.48 + +## 11.0.0-canary.47 + +## 11.0.0-canary.46 + +## 11.0.0-canary.45 + +### Major Changes + +- [#2626](https://github.com/graphcommerce-org/graphcommerce/pull/2626) [`e2c9f9b`](https://github.com/graphcommerce-org/graphcommerce/commit/e2c9f9bfc762ed1c4d46f1e24babd6bd658c7343) - **Breaking change — requires Node.js 22 or newer.** This kicks off GraphCommerce 11. + + Node.js 20 hit end-of-life in April 2026, so the framework no longer supports it. `engines.node` is now `>=22.0.0 <27.0.0` across the root and all example storefronts — Node 22 (Maintenance LTS) is the new minimum, Node 24 (Active LTS) is recommended, and Node 26 (current) is also accepted. + + - CI: `release-canary`, `release-main` and `pr-analysis` now run on Node 24. `periodic-build` matrix changed from `[20, 22]` to `[22, 24]`, and `actions/setup-node` bumped from v3 to v4. + - `.gitpod.yml` bootstrap moved from `nvm install 18` to `nvm install 24`. + - Getting-started docs and the three example READMEs now point at Node 22/24. + + See [docs/upgrading/graphcommerce-10-to-11.md](docs/upgrading/graphcommerce-10-to-11.md) for the migration steps. ([@paales](https://github.com/paales)) + +## 10.1.0-canary.44 + +## 10.1.0-canary.43 + +## 10.1.0-canary.42 + +## 10.1.0-canary.41 + +## 10.1.0-canary.40 + +## 10.1.0-canary.39 + +## 10.1.0-canary.38 + +## 10.1.0-canary.37 + +## 10.1.0-canary.36 + +## 10.1.0-canary.35 + +## 10.1.0-canary.34 + +## 10.1.0-canary.33 + +## 10.1.0-canary.32 + +## 10.1.0-canary.31 + +## 10.1.0-canary.30 + +## 10.1.0-canary.29 + +## 10.1.0-canary.28 + +## 10.1.0-canary.27 + +## 10.1.0-canary.26 + +## 10.1.0-canary.25 + +### Minor Changes + +- [#2637](https://github.com/graphcommerce-org/graphcommerce/pull/2637) [`bdaa6ec`](https://github.com/graphcommerce-org/graphcommerce/commit/bdaa6ec6aa2669b74fc6702ad46336db4c154b7c) - Refactored `LayoutNavigation` into composable pieces (`Header`, `HeaderContainer`, `MenuOverlay`, project-local `LayoutDefault`). `LayoutDefault` / `LayoutDefaultProps` in `@graphcommerce/next-ui` are marked `@deprecated`. If you are upgrading and do not want these changes, you can just discard them. This is just a structural change for more ease of use. No visually change. ([@bramvanderholst](https://github.com/bramvanderholst)) + +## 10.1.0-canary.24 + +### Patch Changes + +- [#2636](https://github.com/graphcommerce-org/graphcommerce/pull/2636) [`0af6794`](https://github.com/graphcommerce-org/graphcommerce/commit/0af679485950c934cdadc56b8b3ea8ace9de8ab9) - Fix for codegen issue where codegen would stop (without error) halfway through ([@bramvanderholst](https://github.com/bramvanderholst)) + +## 10.1.0-canary.23 + +### Patch Changes + +- [#2634](https://github.com/graphcommerce-org/graphcommerce/pull/2634) [`06082ad`](https://github.com/graphcommerce-org/graphcommerce/commit/06082ad47a59217fbdfb24f1a60411e4d0eecd9b) - Make GraphCommerce compatible with Apollo Client 4.2+ by augmenting Apollo's `DefaultOptions` type with the `preview` extension and the SSR clients' `errorPolicy: 'all'` default. ([@bramvanderholst](https://github.com/bramvanderholst)) + +## 10.1.0-canary.22 + +## 10.1.0-canary.21 + +## 10.1.0-canary.20 + +## 10.1.0-canary.19 + +## 10.1.0-canary.18 + +## 10.1.0-canary.17 + +### Patch Changes + +- [#2623](https://github.com/graphcommerce-org/graphcommerce/pull/2623) [`241576a`](https://github.com/graphcommerce-org/graphcommerce/commit/241576a981fe97595000d74630a8ac8544a5e77f) - Bump Next.js from 16.1.1 to 16.2.6 across the framework and example storefronts. Also bumps the matching `@next/env` and `@next/eslint-plugin-next` pins. ([@paales](https://github.com/paales)) + +## 10.1.0-canary.16 + +## 10.1.0-canary.15 + +### Patch Changes + +- [#2623](https://github.com/graphcommerce-org/graphcommerce/pull/2623) [`241576a`](https://github.com/graphcommerce-org/graphcommerce/commit/241576a981fe97595000d74630a8ac8544a5e77f) - Bump Next.js from 16.1.1 to 16.2.6 across the framework and example storefronts. Also bumps the matching `@next/env` and `@next/eslint-plugin-next` pins. ([@paales](https://github.com/paales)) + +## 10.1.0-canary.14 + +## 10.1.0-canary.13 + +## 10.1.0-canary.12 + +## 10.1.0-canary.11 + +## 10.1.0-canary.10 + +## 10.1.0-canary.9 + +## 10.1.0-canary.8 + +## 10.1.0-canary.7 + +## 10.1.0-canary.6 + +## 10.1.0-canary.5 + +## 10.1.0-canary.4 + +## 10.1.0-canary.3 + +## 10.0.4-canary.2 + +## 10.0.4-canary.1 + +## 10.0.4-canary.0 + ## 10.0.3 ## 10.0.3-canary.0 diff --git a/examples/magento-graphcms/README.md b/examples/magento-graphcms/README.md index 865df4e6dfe..9c0f31407d0 100644 --- a/examples/magento-graphcms/README.md +++ b/examples/magento-graphcms/README.md @@ -52,7 +52,7 @@ start building. ### Requirements -- Install and use node 16/18: `nvm install 16` or `nvm use 16` +- Install and use node 22 or 24: `nvm install 24` or `nvm use 24` - Install yarn: `corepack enable` ## Step 1: Create a GraphCommerce app diff --git a/examples/magento-graphcms/components/Blog/BlogAuthor.tsx b/examples/magento-graphcms/components/Blog/BlogAuthor.tsx index 5c964c91cc9..69354357429 100644 --- a/examples/magento-graphcms/components/Blog/BlogAuthor.tsx +++ b/examples/magento-graphcms/components/Blog/BlogAuthor.tsx @@ -1,5 +1,5 @@ import { BlogAuthor as NextBlogAuthor } from '@graphcommerce/next-ui' -import { BlogAuthorFragment } from './BlogAuthor.gql' +import type { BlogAuthorFragment } from './BlogAuthor.gql' type BlogAuthorProps = BlogAuthorFragment diff --git a/examples/magento-graphcms/components/Blog/BlogHeader.tsx b/examples/magento-graphcms/components/Blog/BlogHeader.tsx index 48ef13b08a3..07ca1191555 100644 --- a/examples/magento-graphcms/components/Blog/BlogHeader.tsx +++ b/examples/magento-graphcms/components/Blog/BlogHeader.tsx @@ -1,4 +1,5 @@ -import { Asset, AssetFragment } from '@graphcommerce/hygraph-ui' +import type { AssetFragment } from '@graphcommerce/hygraph-ui' +import { Asset } from '@graphcommerce/hygraph-ui' import { BlogHeader as NextBlogHeader } from '@graphcommerce/next-ui' export function BlogHeader(props: { asset?: AssetFragment }) { diff --git a/examples/magento-graphcms/components/Blog/BlogItem.tsx b/examples/magento-graphcms/components/Blog/BlogItem.tsx index a290014faf7..22f2ebabf26 100644 --- a/examples/magento-graphcms/components/Blog/BlogItem.tsx +++ b/examples/magento-graphcms/components/Blog/BlogItem.tsx @@ -2,7 +2,7 @@ import { Asset } from '@graphcommerce/hygraph-ui' import { BlogListItem } from '@graphcommerce/next-ui' import { Trans } from '@lingui/react/macro' import { Typography, useTheme } from '@mui/material' -import { BlogItemFragment } from './BlogItem.gql' +import type { BlogItemFragment } from './BlogItem.gql' type BlogItemProps = BlogItemFragment diff --git a/examples/magento-graphcms/components/Blog/BlogList.tsx b/examples/magento-graphcms/components/Blog/BlogList.tsx index 63d3775152b..ce680c3a08c 100644 --- a/examples/magento-graphcms/components/Blog/BlogList.tsx +++ b/examples/magento-graphcms/components/Blog/BlogList.tsx @@ -1,6 +1,6 @@ import { BlogItemGrid } from '@graphcommerce/next-ui' import { BlogItem } from './BlogItem' -import { BlogListQuery } from './BlogList.gql' +import type { BlogListQuery } from './BlogList.gql' type BlogListProps = BlogListQuery diff --git a/examples/magento-graphcms/components/Blog/BlogTags.tsx b/examples/magento-graphcms/components/Blog/BlogTags.tsx index 7628013a88f..c1dec0c068f 100644 --- a/examples/magento-graphcms/components/Blog/BlogTags.tsx +++ b/examples/magento-graphcms/components/Blog/BlogTags.tsx @@ -1,5 +1,5 @@ import { BlogTag, BlogTags as NextBlogTags } from '@graphcommerce/next-ui' -import { BlogTagsFragment } from './BlogTags.gql' +import type { BlogTagsFragment } from './BlogTags.gql' type BlogTagsProps = BlogTagsFragment diff --git a/examples/magento-graphcms/components/Blog/RowBlogContent.tsx b/examples/magento-graphcms/components/Blog/RowBlogContent.tsx index 4b17c50ab9e..1e9f39ddad2 100644 --- a/examples/magento-graphcms/components/Blog/RowBlogContent.tsx +++ b/examples/magento-graphcms/components/Blog/RowBlogContent.tsx @@ -1,6 +1,6 @@ import { RichText } from '@graphcommerce/hygraph-ui' import { BlogContent } from '@graphcommerce/next-ui' -import { RowBlogContentFragment } from './RowBlogContent.gql' +import type { RowBlogContentFragment } from './RowBlogContent.gql' type RowBlogContentProps = RowBlogContentFragment diff --git a/examples/magento-graphcms/components/GraphCMS/RowButtonLinkList/RowButtonLinkList.tsx b/examples/magento-graphcms/components/GraphCMS/RowButtonLinkList/RowButtonLinkList.tsx index b6822e8037e..aedd023a598 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowButtonLinkList/RowButtonLinkList.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowButtonLinkList/RowButtonLinkList.tsx @@ -1,5 +1,5 @@ import { ButtonLinkListItem, ButtonLinkList } from '@graphcommerce/next-ui' -import { RowButtonLinkListFragment } from './RowButtonLinkList.gql' +import type { RowButtonLinkListFragment } from './RowButtonLinkList.gql' export type RowButtonLinkListProps = RowButtonLinkListFragment diff --git a/examples/magento-graphcms/components/GraphCMS/RowColumnOne/variant/Default.tsx b/examples/magento-graphcms/components/GraphCMS/RowColumnOne/variant/Default.tsx index a29e8d3a863..ec0b92d8560 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowColumnOne/variant/Default.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowColumnOne/variant/Default.tsx @@ -1,4 +1,5 @@ -import { RichText, RichTextProps } from '@graphcommerce/hygraph-ui' +import type { RichTextProps } from '@graphcommerce/hygraph-ui' +import { RichText } from '@graphcommerce/hygraph-ui' import { ColumnOne } from '@graphcommerce/next-ui' import type { RowColumnOneFragment } from '../RowColumnOne.gql' diff --git a/examples/magento-graphcms/components/GraphCMS/RowColumnOne/variant/Message.tsx b/examples/magento-graphcms/components/GraphCMS/RowColumnOne/variant/Message.tsx index 3d476cbe803..7de4ec11211 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowColumnOne/variant/Message.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowColumnOne/variant/Message.tsx @@ -1,4 +1,5 @@ -import { RichText, RichTextProps } from '@graphcommerce/hygraph-ui' +import type { RichTextProps } from '@graphcommerce/hygraph-ui' +import { RichText } from '@graphcommerce/hygraph-ui' import { VariantMessage } from '@graphcommerce/next-ui' import type { RowColumnOneFragment } from '../RowColumnOne.gql' diff --git a/examples/magento-graphcms/components/GraphCMS/RowColumnThree/RowColumnThree.tsx b/examples/magento-graphcms/components/GraphCMS/RowColumnThree/RowColumnThree.tsx index 383eb087473..a90b4095f1a 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowColumnThree/RowColumnThree.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowColumnThree/RowColumnThree.tsx @@ -1,6 +1,6 @@ import { RichText } from '@graphcommerce/hygraph-ui' import { ColumnThree } from '@graphcommerce/next-ui' -import { RowColumnThreeFragment } from './RowColumnThree.gql' +import type { RowColumnThreeFragment } from './RowColumnThree.gql' export function RowColumnThree(props: RowColumnThreeFragment) { const { colOne, colTwo, colThree } = props diff --git a/examples/magento-graphcms/components/GraphCMS/RowColumnTwo/RowColumnTwo.tsx b/examples/magento-graphcms/components/GraphCMS/RowColumnTwo/RowColumnTwo.tsx index 4e90dcb635c..ee1dc15f5e6 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowColumnTwo/RowColumnTwo.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowColumnTwo/RowColumnTwo.tsx @@ -1,6 +1,6 @@ import { RichText } from '@graphcommerce/hygraph-ui' import { ColumnTwo } from '@graphcommerce/next-ui' -import { RowColumnTwoFragment } from './RowColumnTwo.gql' +import type { RowColumnTwoFragment } from './RowColumnTwo.gql' export function RowColumnTwo(props: RowColumnTwoFragment) { const { colOne, colTwo } = props diff --git a/examples/magento-graphcms/components/GraphCMS/RowContentLinks/RowContentLinks.tsx b/examples/magento-graphcms/components/GraphCMS/RowContentLinks/RowContentLinks.tsx index f9783856b7e..875c6215950 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowContentLinks/RowContentLinks.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowContentLinks/RowContentLinks.tsx @@ -1,6 +1,6 @@ import { ContentLinks } from '@graphcommerce/next-ui' import { Link } from '@mui/material' -import { RowContentLinksFragment } from './RowContentLinks.gql' +import type { RowContentLinksFragment } from './RowContentLinks.gql' /** @deprecated Replace with RowLinks */ export function RowContentLinks(props: RowContentLinksFragment) { diff --git a/examples/magento-graphcms/components/GraphCMS/RowHeroBanner/RowHeroBanner.tsx b/examples/magento-graphcms/components/GraphCMS/RowHeroBanner/RowHeroBanner.tsx index 1f531bd47f5..28d531717dd 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowHeroBanner/RowHeroBanner.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowHeroBanner/RowHeroBanner.tsx @@ -1,10 +1,19 @@ -import { RichText } from '@graphcommerce/hygraph-ui' +import type { AssetProps } from '@graphcommerce/hygraph-ui' +import { Asset, RichText } from '@graphcommerce/hygraph-ui' import { breakpointVal, HeroBanner } from '@graphcommerce/next-ui' import { Button } from '@mui/material' -import { RowHeroBannerFragment } from './RowHeroBanner.gql' +import type { RowHeroBannerFragment } from './RowHeroBanner.gql' -export function RowHeroBanner(props: RowHeroBannerFragment) { - const { copy, heroAsset, pageLinks } = props +export type RowHeroBannerProps = RowHeroBannerFragment & { + /** + * Only applies to an image asset — a video is never lazy-loaded. Pass + * `'eager'` where the banner is the LCP element. + */ + loading?: AssetProps['loading'] +} + +export function RowHeroBanner(props: RowHeroBannerProps) { + const { copy, heroAsset, pageLinks, loading } = props return ( ))} - videoSrc={heroAsset.url} + asset={heroAsset && } sx={(theme) => ({ '& .HeroBanner-copy': { minHeight: { xs: 'min(70vh,600px)', md: 'min(70vh,1080px)' }, diff --git a/examples/magento-graphcms/components/GraphCMS/RowLinks/variant/ImageLabelSwiper.tsx b/examples/magento-graphcms/components/GraphCMS/RowLinks/variant/ImageLabelSwiper.tsx index 5cd0c34aa3b..7657f5a76fb 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowLinks/variant/ImageLabelSwiper.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowLinks/variant/ImageLabelSwiper.tsx @@ -1,7 +1,7 @@ import { Asset, RichText } from '@graphcommerce/hygraph-ui' import { responsiveVal, VariantImageLabelSwiper } from '@graphcommerce/next-ui' import { Box, ButtonBase, Typography } from '@mui/material' -import { RowLinksFragment } from '../RowLinks.gql' +import type { RowLinksFragment } from '../RowLinks.gql' export function ImageLabelSwiper(props: RowLinksFragment) { const { title, rowLinksCopy, pageLinks } = props diff --git a/examples/magento-graphcms/components/GraphCMS/RowLinks/variant/Inline.tsx b/examples/magento-graphcms/components/GraphCMS/RowLinks/variant/Inline.tsx index d9536fc3e6c..2ccd86e208c 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowLinks/variant/Inline.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowLinks/variant/Inline.tsx @@ -1,7 +1,7 @@ import { VariantInline } from '@graphcommerce/next-ui' import { Link } from '@mui/material' -import { RowLinksFragment } from '../RowLinks.gql' +import type { RowLinksFragment } from '../RowLinks.gql' export function Inline(props: RowLinksFragment) { const { title, pageLinks } = props diff --git a/examples/magento-graphcms/components/GraphCMS/RowLinks/variant/LogoSwiper.tsx b/examples/magento-graphcms/components/GraphCMS/RowLinks/variant/LogoSwiper.tsx index 3fb599ea8c8..d6a8e1c8315 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowLinks/variant/LogoSwiper.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowLinks/variant/LogoSwiper.tsx @@ -1,7 +1,7 @@ import { Asset } from '@graphcommerce/hygraph-ui' import { VariantLogoSwiper } from '@graphcommerce/next-ui' import { Link } from '@mui/material' -import { RowLinksFragment } from '../RowLinks.gql' +import type { RowLinksFragment } from '../RowLinks.gql' export function LogoSwiper(props: RowLinksFragment) { const { title, pageLinks } = props diff --git a/examples/magento-graphcms/components/GraphCMS/RowLinks/variant/Usps.tsx b/examples/magento-graphcms/components/GraphCMS/RowLinks/variant/Usps.tsx index 6cd3697241b..4e62125e83d 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowLinks/variant/Usps.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowLinks/variant/Usps.tsx @@ -2,7 +2,7 @@ import { RichText } from '@graphcommerce/hygraph-ui' import { iconCheckmark, IconSvg, VariantUsps } from '@graphcommerce/next-ui' import { Box } from '@mui/material' -import { RowLinksFragment } from '../RowLinks.gql' +import type { RowLinksFragment } from '../RowLinks.gql' export function Usps(props: RowLinksFragment) { const { title, pageLinks } = props diff --git a/examples/magento-graphcms/components/GraphCMS/RowProduct/RowProduct.tsx b/examples/magento-graphcms/components/GraphCMS/RowProduct/RowProduct.tsx index 9a757f14c6f..c16db55d89d 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowProduct/RowProduct.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowProduct/RowProduct.tsx @@ -1,11 +1,8 @@ import { PrivateQueryMaskProvider, usePrivateQuery } from '@graphcommerce/graphql' -import { - ProductListDocument, - ProductListItemsFragment, - ProductSpecsFragment, -} from '@graphcommerce/magento-product' +import type { ProductListItemsFragment, ProductSpecsFragment } from '@graphcommerce/magento-product' +import { ProductListDocument } from '@graphcommerce/magento-product' import { filterNonNullableKeys } from '@graphcommerce/next-ui' -import { RowProductFragment } from './RowProduct.gql' +import type { RowProductFragment } from './RowProduct.gql' import { Backstory, Feature, diff --git a/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Backstory.tsx b/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Backstory.tsx index afa0f255214..da3c13c06b4 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Backstory.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Backstory.tsx @@ -1,9 +1,10 @@ import { Asset, RichText } from '@graphcommerce/hygraph-ui' -import { AddProductsToCartForm, ProductListItemsFragment } from '@graphcommerce/magento-product' +import type { ProductListItemsFragment } from '@graphcommerce/magento-product' +import { AddProductsToCartForm } from '@graphcommerce/magento-product' import { ParagraphWithSidebarSlide, RenderType } from '@graphcommerce/next-ui' import { useTheme } from '@mui/material' import { productListRenderer } from '../../../ProductListItems' -import { RowProductFragment } from '../RowProduct.gql' +import type { RowProductFragment } from '../RowProduct.gql' type BackstoryProps = RowProductFragment & ProductListItemsFragment diff --git a/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Feature.tsx b/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Feature.tsx index 109b4730994..46b8a0a917a 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Feature.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Feature.tsx @@ -2,8 +2,8 @@ import { RichText } from '@graphcommerce/hygraph-ui' import { Image } from '@graphcommerce/image' import { ImageText, useContainerSpacing } from '@graphcommerce/next-ui' import { Typography, useTheme } from '@mui/material' -import { RowProductFragment } from '../RowProduct.gql' -import { ProductFeatureMediaFragment } from './ProductFeatureMedia.gql' +import type { RowProductFragment } from '../RowProduct.gql' +import type { ProductFeatureMediaFragment } from './ProductFeatureMedia.gql' type FeatureProps = RowProductFragment & ProductFeatureMediaFragment @@ -25,6 +25,7 @@ export function Feature(props: FeatureProps) { width={1532} height={1678} src={item.url} + quality='product' sizes={{ 0: '100vw', [theme.breakpoints.values.md]: '50vw', diff --git a/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/FeatureBoxed.tsx b/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/FeatureBoxed.tsx index 7ea010b21c7..71b967d4450 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/FeatureBoxed.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/FeatureBoxed.tsx @@ -2,8 +2,8 @@ import { RichText } from '@graphcommerce/hygraph-ui' import { Image } from '@graphcommerce/image' import { ImageTextBoxed, responsiveVal } from '@graphcommerce/next-ui' import { Typography, useTheme } from '@mui/material' -import { RowProductFragment } from '../RowProduct.gql' -import { ProductFeatureMediaBoxedFragment } from './ProductFeatureMediaBoxed.gql' +import type { RowProductFragment } from '../RowProduct.gql' +import type { ProductFeatureMediaBoxedFragment } from './ProductFeatureMediaBoxed.gql' type FeatureBoxedProps = RowProductFragment & ProductFeatureMediaBoxedFragment @@ -24,6 +24,7 @@ export function FeatureBoxed(props: FeatureBoxedProps) { width={1532} height={1678} src={item.url} + quality='product' sizes={{ 0: '100vw', [theme.breakpoints.values.md]: responsiveVal(100, 600), diff --git a/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Grid.tsx b/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Grid.tsx index 6fbf98caef0..3327693300b 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Grid.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Grid.tsx @@ -1,7 +1,8 @@ import { ContainerWithHeader } from '@graphcommerce/next-ui' import { Link } from '@mui/material' -import { ProductListItems, ProductListItemsProps } from '../../../ProductListItems/ProductListItems' -import { RowProductFragment } from '../RowProduct.gql' +import type { ProductListItemsProps } from '../../../ProductListItems/ProductListItems' +import { ProductListItems } from '../../../ProductListItems/ProductListItems' +import type { RowProductFragment } from '../RowProduct.gql' type GridProps = RowProductFragment & ProductListItemsProps diff --git a/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Related.tsx b/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Related.tsx index 9791fc73cd3..c54e9bdd23f 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Related.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Related.tsx @@ -1,13 +1,10 @@ -import { AddProductsToCartForm, RelatedProductsFragment } from '@graphcommerce/magento-product' -import { - SidebarSlider, - RenderType, - responsiveVal, - SidebarSliderProps, -} from '@graphcommerce/next-ui' +import type { RelatedProductsFragment } from '@graphcommerce/magento-product' +import { AddProductsToCartForm } from '@graphcommerce/magento-product' +import type { SidebarSliderProps } from '@graphcommerce/next-ui' +import { SidebarSlider, RenderType, responsiveVal } from '@graphcommerce/next-ui' import { Typography } from '@mui/material' import { productListRenderer } from '../../../ProductListItems/productListRenderer' -import { RowProductFragment } from '../RowProduct.gql' +import type { RowProductFragment } from '../RowProduct.gql' type RelatedProps = RowProductFragment & RelatedProductsFragment & Pick diff --git a/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Reviews.tsx b/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Reviews.tsx index 7012fd0c25e..24be2234c9e 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Reviews.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Reviews.tsx @@ -1,9 +1,10 @@ import { useQuery } from '@graphcommerce/graphql' -import { ProductReviews, ProductReviewsProps } from '@graphcommerce/magento-review' +import type { ProductReviewsProps } from '@graphcommerce/magento-review' +import { ProductReviews } from '@graphcommerce/magento-review' import { StoreConfigDocument } from '@graphcommerce/magento-store' -import { Row, sxx } from '@graphcommerce/next-ui' +import { Row } from '@graphcommerce/next-ui' import { Box, Typography } from '@mui/material' -import { RowProductFragment } from '../RowProduct.gql' +import type { RowProductFragment } from '../RowProduct.gql' type ReviewsProps = RowProductFragment & Partial diff --git a/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Specs.tsx b/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Specs.tsx index 3b22e3c8071..67a0580cbc7 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Specs.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Specs.tsx @@ -1,5 +1,6 @@ -import { ProductSpecs, ProductSpecsFragment } from '@graphcommerce/magento-product' -import { RowProductFragment } from '../RowProduct.gql' +import type { ProductSpecsFragment } from '@graphcommerce/magento-product' +import { ProductSpecs } from '@graphcommerce/magento-product' +import type { RowProductFragment } from '../RowProduct.gql' type SpecsProps = RowProductFragment & ProductSpecsFragment diff --git a/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Swipeable.tsx b/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Swipeable.tsx index 97a8232cba9..e48dcb2e3f0 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Swipeable.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Swipeable.tsx @@ -1,14 +1,10 @@ -import { AddProductsToCartForm, ProductListItemsFragment } from '@graphcommerce/magento-product' -import { - RenderType, - responsiveVal, - SidebarSlider, - SidebarSliderProps, - sxx, -} from '@graphcommerce/next-ui' +import type { ProductListItemsFragment } from '@graphcommerce/magento-product' +import { AddProductsToCartForm } from '@graphcommerce/magento-product' +import type { SidebarSliderProps } from '@graphcommerce/next-ui' +import { RenderType, responsiveVal, SidebarSlider, sxx } from '@graphcommerce/next-ui' import { Typography } from '@mui/material' import { productListRenderer } from '../../../ProductListItems/productListRenderer' -import { RowProductFragment } from '../RowProduct.gql' +import type { RowProductFragment } from '../RowProduct.gql' type SwipeableProps = RowProductFragment & ProductListItemsFragment & Pick diff --git a/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Upsells.tsx b/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Upsells.tsx index ab1a496cbed..2e009c7ac74 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Upsells.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowProduct/variant/Upsells.tsx @@ -1,13 +1,10 @@ -import { AddProductsToCartForm, UpsellProductsFragment } from '@graphcommerce/magento-product' -import { - SidebarSlider, - RenderType, - responsiveVal, - SidebarSliderProps, -} from '@graphcommerce/next-ui' +import type { UpsellProductsFragment } from '@graphcommerce/magento-product' +import { AddProductsToCartForm } from '@graphcommerce/magento-product' +import type { SidebarSliderProps } from '@graphcommerce/next-ui' +import { SidebarSlider, RenderType, responsiveVal } from '@graphcommerce/next-ui' import { Typography } from '@mui/material' import { productListRenderer } from '../../../ProductListItems/productListRenderer' -import { RowProductFragment } from '../RowProduct.gql' +import type { RowProductFragment } from '../RowProduct.gql' type UpsellsProps = RowProductFragment & UpsellProductsFragment & Pick diff --git a/examples/magento-graphcms/components/GraphCMS/RowQuote/RowQuote.tsx b/examples/magento-graphcms/components/GraphCMS/RowQuote/RowQuote.tsx index f243e905901..54564322945 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowQuote/RowQuote.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowQuote/RowQuote.tsx @@ -1,7 +1,6 @@ import { RichText } from '@graphcommerce/hygraph-ui' import { Quote } from '@graphcommerce/next-ui' -import React from 'react' -import { RowQuoteFragment } from './RowQuote.gql' +import type { RowQuoteFragment } from './RowQuote.gql' type RowQuoteProps = RowQuoteFragment diff --git a/examples/magento-graphcms/components/GraphCMS/RowRenderer.tsx b/examples/magento-graphcms/components/GraphCMS/RowRenderer.tsx index 55f11894a0b..9d1d9a736b2 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowRenderer.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowRenderer.tsx @@ -1,7 +1,8 @@ -import { LazyHydrate, RenderType, TypeRenderer } from '@graphcommerce/next-ui' +import type { TypeRenderer } from '@graphcommerce/next-ui' +import { LazyHydrate, RenderType } from '@graphcommerce/next-ui' import { memo } from 'react' import { RowBlogContent } from '../Blog' -import { PageContentQueryFragment } from './PageContentQueryFragment.gql' +import type { PageContentQueryFragment } from './PageContentQueryFragment.gql' import { RowButtonLinkList } from './RowButtonLinkList/RowButtonLinkList' import { RowColumnOne } from './RowColumnOne/RowColumnOne' import { RowColumnThree } from './RowColumnThree/RowColumnThree' @@ -11,7 +12,7 @@ import { RowHeroBanner } from './RowHeroBanner/RowHeroBanner' import { RowLinks } from './RowLinks/RowLinks' import { RowProduct } from './RowProduct/RowProduct' import { RowQuote } from './RowQuote/RowQuote' -import { RowRendererFragment } from './RowRenderer.gql' +import type { RowRendererFragment } from './RowRenderer.gql' import { RowServiceOptions } from './RowServiceOptions/RowServiceOptions' import { RowSpecialBanner } from './RowSpecialBanner/RowSpecialBanner' diff --git a/examples/magento-graphcms/components/GraphCMS/RowServiceOptions/RowServiceOptions.tsx b/examples/magento-graphcms/components/GraphCMS/RowServiceOptions/RowServiceOptions.tsx index 869ee17e352..d74ed3fb6d1 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowServiceOptions/RowServiceOptions.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowServiceOptions/RowServiceOptions.tsx @@ -7,7 +7,7 @@ import { iconPhone, IconSvg, } from '@graphcommerce/next-ui' -import { RowServiceOptionsFragment } from './RowServiceOptions.gql' +import type { RowServiceOptionsFragment } from './RowServiceOptions.gql' type RowServiceOptionsProps = RowServiceOptionsFragment diff --git a/examples/magento-graphcms/components/GraphCMS/RowSpecialBanner/RowSpecialBanner.tsx b/examples/magento-graphcms/components/GraphCMS/RowSpecialBanner/RowSpecialBanner.tsx index cc79a4ae45c..78b8178ea9d 100644 --- a/examples/magento-graphcms/components/GraphCMS/RowSpecialBanner/RowSpecialBanner.tsx +++ b/examples/magento-graphcms/components/GraphCMS/RowSpecialBanner/RowSpecialBanner.tsx @@ -1,7 +1,7 @@ import { RichText, Asset } from '@graphcommerce/hygraph-ui' import { breakpointVal, SpecialBanner } from '@graphcommerce/next-ui' import { Link } from '@mui/material' -import { RowSpecialBannerFragment } from './RowSpecialBanner.gql' +import type { RowSpecialBannerFragment } from './RowSpecialBanner.gql' type RowSpecialBannerProps = RowSpecialBannerFragment diff --git a/examples/magento-graphcms/components/Layout/Footer.tsx b/examples/magento-graphcms/components/Layout/Footer.tsx index 943a38fd966..36b6a9fca7d 100644 --- a/examples/magento-graphcms/components/Layout/Footer.tsx +++ b/examples/magento-graphcms/components/Layout/Footer.tsx @@ -5,7 +5,7 @@ import { magentoVersion } from '@graphcommerce/next-config/config' import { DateFormat, FindAndReplace, Footer as FooterBase } from '@graphcommerce/next-ui' import { Trans } from '@lingui/react/macro' import { Button, IconButton, Link } from '@mui/material' -import { FooterQueryFragment } from './FooterQueryFragment.gql' +import type { FooterQueryFragment } from './FooterQueryFragment.gql' import { useQuery } from '@graphcommerce/graphql' export type FooterProps = FooterQueryFragment diff --git a/examples/magento-graphcms/components/Layout/Header.tsx b/examples/magento-graphcms/components/Layout/Header.tsx new file mode 100644 index 00000000000..9d9886d6232 --- /dev/null +++ b/examples/magento-graphcms/components/Layout/Header.tsx @@ -0,0 +1,82 @@ +import { useCartEnabled } from '@graphcommerce/magento-cart' +import { CustomerFab } from '@graphcommerce/magento-customer' +import { SearchFab, SearchField } from '@graphcommerce/magento-search' +import { StoreSwitcherButton, StoreSwitcherFab } from '@graphcommerce/magento-store' +import { WishlistFab } from '@graphcommerce/magento-wishlist' +import { + DesktopNavActions, + DesktopNavBar, + DesktopNavItem, + iconChevronDown, + iconCustomerService, + iconHeart, + IconSvg, + MobileTopRight, + PlaceholderFab, + type UseNavigationSelection, +} from '@graphcommerce/next-ui' +import { t } from '@lingui/core/macro' +import { Trans } from '@lingui/react/macro' +import { Fab } from '@mui/material' +import { productListRenderer } from '../ProductListItems/productListRenderer' +import { HeaderContainer } from './HeaderContainer' +import type { LayoutQuery } from './Layout.gql' +import { Logo } from './Logo' + +export type HeaderProps = LayoutQuery & { selection: UseNavigationSelection } + +export function Header(props: HeaderProps) { + const { menu, selection } = props + const cartEnabled = useCartEnabled() + + return ( + + + + + {menu?.items?.[0]?.children?.slice(0, 2).map((item) => ( + + {item?.name} + + ))} + + selection.set([menu?.items?.[0]?.uid || ''])} + onKeyUp={(evt) => { + if (evt.key === 'Enter') { + selection.set([menu?.items?.[0]?.uid || '']) + } + }} + tabIndex={0} + > + {menu?.items?.[0]?.name} + + + + + Blog + + + + + + + + + + } /> + + {/* The placeholder exists because the CartFab is sticky but we want to reserve the space for the */} + {cartEnabled && } + + + + + + + + ) +} diff --git a/examples/magento-graphcms/components/Layout/HeaderContainer.tsx b/examples/magento-graphcms/components/Layout/HeaderContainer.tsx new file mode 100644 index 00000000000..790de26bde8 --- /dev/null +++ b/examples/magento-graphcms/components/Layout/HeaderContainer.tsx @@ -0,0 +1,40 @@ +import type { ContainerSizingProps } from '@graphcommerce/next-ui' +import { Container, sxx } from '@graphcommerce/next-ui' + +export type HeaderContainerProps = ContainerSizingProps + +export function HeaderContainer(props: HeaderContainerProps) { + const { children, sx, ...containerProps } = props + + return ( + ({ + zIndex: theme.zIndex.appBar - 1, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + height: theme.appShell.headerHeightSm, + pointerEvents: 'none', + '& > *': { + pointerEvents: 'all', + }, + [theme.breakpoints.up('md')]: { + height: theme.appShell.headerHeightMd, + top: 0, + display: 'flex', + justifyContent: 'left', + width: '100%', + }, + }), + sx, + )} + > + {children} + + ) +} diff --git a/examples/magento-graphcms/components/Layout/LayoutDefault.tsx b/examples/magento-graphcms/components/Layout/LayoutDefault.tsx new file mode 100644 index 00000000000..e3e380ce0ab --- /dev/null +++ b/examples/magento-graphcms/components/Layout/LayoutDefault.tsx @@ -0,0 +1,134 @@ +import { useScrollOffset } from '@graphcommerce/framer-next-pages' +import { dvh } from '@graphcommerce/framer-utils' +import { + Container, + extendableComponent, + LayoutProvider, + SkipLink, + sxx, + useFabSize, +} from '@graphcommerce/next-ui' +import type { SxProps, Theme } from '@mui/material' +import { Box } from '@mui/material' +import { useScroll, useTransform } from 'motion/react' + +export type LayoutDefaultProps = { + className?: string + beforeHeader?: React.ReactNode + header: React.ReactNode + footer: React.ReactNode + menuFab?: React.ReactNode + cartFab?: React.ReactNode + children?: React.ReactNode + noSticky?: boolean + sx?: SxProps +} & OwnerState + +type OwnerState = { + noSticky?: boolean +} +const parts = ['root', 'fabs', 'header', 'children', 'footer'] as const +const { withState } = extendableComponent( + 'LayoutDefault', + parts, +) + +export function LayoutDefault(props: LayoutDefaultProps) { + const { + children, + header, + beforeHeader, + footer, + menuFab, + cartFab, + noSticky, + className, + sx = [], + } = props + + const { scrollY } = useScroll() + const scrollYOffset = useTransform( + [scrollY, useScrollOffset()], + ([y, offset]: number[]) => y + offset, + ) + + const classes = withState({ noSticky }) + const fabIconSize = useFabSize('responsive') + + return ( + ({ + minHeight: dvh(100), + '@supports (-webkit-touch-callout: none)': { + minHeight: '-webkit-fill-available', + }, + display: 'grid', + gridTemplateRows: { xs: 'auto 1fr auto', md: 'auto auto 1fr auto' }, + gridTemplateColumns: '100%', + background: theme.vars.palette.background.default, + }), + sx, + )} + > + + + {beforeHeader} + {header} + {menuFab || cartFab ? ( + ({ + display: 'flex', + justifyContent: 'space-between', + width: '100%', + height: 0, + zIndex: 'speedDial', + [theme.breakpoints.up('sm')]: { + position: 'sticky', + marginTop: `calc(${theme.appShell.headerHeightMd} * -1 - calc(${fabIconSize} / 2))`, + top: `calc(${theme.appShell.headerHeightMd} / 2 - (${fabIconSize} / 2))`, + }, + [theme.breakpoints.down('md')]: { + position: 'fixed', + top: 'unset', + bottom: `calc(20px + ${fabIconSize})`, + padding: '0 20px', + '@media (max-height: 530px) and (orientation: portrait)': { + display: 'none', + }, + }, + })} + > + {menuFab} + {cartFab && ( + ({ + display: 'flex', + flexDirection: 'row-reverse', + gap: theme.spacings.sm, + [theme.breakpoints.up('md')]: { + flexDirection: 'column', + alignItems: 'flex-end', + }, + })} + > + {cartFab} + + )} + + ) : ( +
+ )} +
+
+ {children} +
+
{footer}
+ + + ) +} diff --git a/examples/magento-graphcms/components/Layout/LayoutMinimal.tsx b/examples/magento-graphcms/components/Layout/LayoutMinimal.tsx index fd013541eaf..703b8d42d69 100644 --- a/examples/magento-graphcms/components/Layout/LayoutMinimal.tsx +++ b/examples/magento-graphcms/components/Layout/LayoutMinimal.tsx @@ -1,6 +1,7 @@ -import { LayoutDefault, LayoutDefaultProps } from '@graphcommerce/next-ui' import { Footer } from './Footer' -import { LayoutQuery } from './Layout.gql' +import { HeaderContainer } from './HeaderContainer' +import type { LayoutQuery } from './Layout.gql' +import { LayoutDefault, type LayoutDefaultProps } from './LayoutDefault' import { Logo } from './Logo' export type LayoutMinimalProps = LayoutQuery & @@ -12,7 +13,11 @@ export function LayoutMinimal(props: LayoutMinimalProps) { return ( } + header={ + + + + } footer={