create-tanqory-theme 0.0.0-stage → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +55 -2
- package/bin/create-tanqory-theme.mjs +13 -0
- package/lib/agents.mjs +118 -0
- package/lib/create.mjs +245 -0
- package/package.json +39 -4
- package/templates/blank/README.md +13 -0
- package/templates/blank/config/settings.json +3 -0
- package/templates/blank/locales/en.json +22 -0
- package/templates/blank/locales/th.json +22 -0
- package/templates/blank/package.json +34 -0
- package/templates/blank/regions/footer.json +35 -0
- package/templates/blank/regions/header.json +13 -0
- package/templates/blank/scripts/build.mjs +193 -0
- package/templates/blank/scripts/probe.ts +4 -0
- package/templates/blank/src/bundle.ts +15 -0
- package/templates/blank/src/components/parts.tsx +32 -0
- package/templates/blank/src/entry.client.tsx +6 -0
- package/templates/blank/src/entry.server.tsx +13 -0
- package/templates/blank/src/sections/chrome.tsx +132 -0
- package/templates/blank/src/sections/commerce.tsx +242 -0
- package/templates/blank/src/sections/content.tsx +111 -0
- package/templates/blank/src/sections/editorial.tsx +107 -0
- package/templates/blank/src/settings.ts +15 -0
- package/templates/blank/src/styles/theme.css +195 -0
- package/templates/blank/src/templates.ts +14 -0
- package/templates/blank/src/theme.tsx +76 -0
- package/templates/blank/template.json +24 -0
- package/templates/blank/templates/404.json +14 -0
- package/templates/blank/templates/account.json +14 -0
- package/templates/blank/templates/article.json +14 -0
- package/templates/blank/templates/blog.json +14 -0
- package/templates/blank/templates/cart.json +14 -0
- package/templates/blank/templates/collection.json +14 -0
- package/templates/blank/templates/index.json +36 -0
- package/templates/blank/templates/page.contact.json +18 -0
- package/templates/blank/templates/page.json +14 -0
- package/templates/blank/templates/product.json +18 -0
- package/templates/blank/templates/search.json +14 -0
- package/templates/blank/tests/theme.test.ts +49 -0
- package/templates/blank/tsconfig.json +17 -0
- package/templates/blank/vite.client.config.ts +17 -0
- package/templates/blank/vite.probe.config.ts +16 -0
- package/templates/blank/vite.server.config.ts +32 -0
- package/templates/blank/vitest.config.ts +9 -0
- package/templates/common/.claude/settings.json +8 -0
- package/templates/common/.codex/config.toml +4 -0
- package/templates/common/.gemini/settings.json +12 -0
- package/templates/common/.github/workflows/theme-check.yml +44 -0
- package/templates/common/.mcp.json +12 -0
- package/templates/common/.vscode/mcp.json +9 -0
- package/templates/common/_gitignore +9 -0
- package/templates/common/scripts/check.mjs +44 -0
- package/templates/common/scripts/dev.mjs +30 -0
- package/templates/common/tanqory.config.json +6 -0
- package/templates/nova/.gitattributes +3 -0
- package/templates/nova/.tanqory/contracts/LOCK.json +66 -0
- package/templates/nova/.tanqory/contracts/nova-01.json +1092 -0
- package/templates/nova/.tanqory/contracts/nova-12A.json +2674 -0
- package/templates/nova/.tanqory/contracts/nova-12B.json +2285 -0
- package/templates/nova/.tanqory/contracts/nova-12C.json +2848 -0
- package/templates/nova/.tanqory/contracts/nova-12D.json +3039 -0
- package/templates/nova/.tanqory/contracts/nova-12E.json +1473 -0
- package/templates/nova/.tanqory/contracts/nova-12F.json +1670 -0
- package/templates/nova/.tanqory/contracts/nova-12G.json +1661 -0
- package/templates/nova/.tanqory/contracts/nova-13.json +301 -0
- package/templates/nova/.tanqory/contracts/nova-14.json +172 -0
- package/templates/nova/.tanqory/legacy-settings.json +1121 -0
- package/templates/nova/README.md +150 -0
- package/templates/nova/_gitignore +28 -0
- package/templates/nova/assets/ai-tokens.css +6 -0
- package/templates/nova/assets/starter/starter-art-1200x800-0b773ac4.svg +1 -0
- package/templates/nova/assets/starter/starter-art-1200x900-59600290.svg +1 -0
- package/templates/nova/assets/starter/starter-art-1200x900-c549d496.svg +1 -0
- package/templates/nova/assets/starter/starter-art-1600x900-8f979fcb.svg +1 -0
- package/templates/nova/assets/starter/starter-art-2100x900-cbb71bfd.svg +1 -0
- package/templates/nova/config/legacy-settings.json +438 -0
- package/templates/nova/config/promotion-popup.schema.ts +29 -0
- package/templates/nova/config/settings.json +23 -0
- package/templates/nova/config/settings.schema.ts +231 -0
- package/templates/nova/entry.abi.tsx +27 -0
- package/templates/nova/groups/footer.json +39 -0
- package/templates/nova/groups/header.json +11 -0
- package/templates/nova/lib/abi/abi.css +41 -0
- package/templates/nova/lib/bundle-core.ts +35 -0
- package/templates/nova/lib/bundle.client.ts +15 -0
- package/templates/nova/lib/bundle.ts +15 -0
- package/templates/nova/lib/legacy-settings.ts +104 -0
- package/templates/nova/locales/ar.json +590 -0
- package/templates/nova/locales/en.json +590 -0
- package/templates/nova/locales/th.json +590 -0
- package/templates/nova/main.abi.tsx +12 -0
- package/templates/nova/package.json +44 -0
- package/templates/nova/scripts/abi/build.mjs +145 -0
- package/templates/nova/scripts/abi/check-content.mjs +99 -0
- package/templates/nova/scripts/abi/jcs.mjs +27 -0
- package/templates/nova/scripts/abi/local-host.mjs +294 -0
- package/templates/nova/scripts/abi/manifest.mjs +392 -0
- package/templates/nova/scripts/abi/starter-assets.mjs +32 -0
- package/templates/nova/scripts/compiler/checks/check-a11y.mjs +88 -0
- package/templates/nova/scripts/compiler/checks/check-layout-sanity.mjs +169 -0
- package/templates/nova/scripts/compiler/checks/check-page-headings.mjs +67 -0
- package/templates/nova/scripts/compiler/checks/check-product-jsonld.mjs +80 -0
- package/templates/nova/scripts/compiler/checks/theme-spec/check.mjs +88 -0
- package/templates/nova/scripts/compiler/contracts/extract.mjs +188 -0
- package/templates/nova/scripts/compiler/contracts/index.ts +125 -0
- package/templates/nova/scripts/compiler/contracts/validate.ts +347 -0
- package/templates/nova/scripts/compiler/manifest/gen-manifest.mjs +156 -0
- package/templates/nova/scripts/compiler/manifest/manifest-entry.ts +386 -0
- package/templates/nova/scripts/compiler/manifest/manifest-sections.ts +247 -0
- package/templates/nova/scripts/compiler/migrate/migrate-content.mjs +171 -0
- package/templates/nova/scripts/compiler/migrate/migrate-groups.mjs +159 -0
- package/templates/nova/scripts/parity/case-shim.ts +14 -0
- package/templates/nova/scripts/parity/emit.ts +206 -0
- package/templates/nova/scripts/parity/index.html +12 -0
- package/templates/nova/scripts/parity/main.tsx +23 -0
- package/templates/nova/scripts/parity/pages.tsx +123 -0
- package/templates/nova/scripts/parity/vite.config.ts +29 -0
- package/templates/nova/src/components/base/Accordion.css +20 -0
- package/templates/nova/src/components/base/Accordion.tsx +50 -0
- package/templates/nova/src/components/base/Badge.css +17 -0
- package/templates/nova/src/components/base/Badge.tsx +26 -0
- package/templates/nova/src/components/base/Button.css +73 -0
- package/templates/nova/src/components/base/Button.tsx +64 -0
- package/templates/nova/src/components/base/Checkbox.tsx +18 -0
- package/templates/nova/src/components/base/Chip.css +20 -0
- package/templates/nova/src/components/base/Chip.tsx +33 -0
- package/templates/nova/src/components/base/Divider.css +6 -0
- package/templates/nova/src/components/base/Divider.tsx +28 -0
- package/templates/nova/src/components/base/IconButton.css +34 -0
- package/templates/nova/src/components/base/IconButton.tsx +41 -0
- package/templates/nova/src/components/base/Input.css +21 -0
- package/templates/nova/src/components/base/Input.tsx +24 -0
- package/templates/nova/src/components/base/Link.css +15 -0
- package/templates/nova/src/components/base/Link.tsx +23 -0
- package/templates/nova/src/components/base/Radio.tsx +13 -0
- package/templates/nova/src/components/base/Select.css +18 -0
- package/templates/nova/src/components/base/Select.tsx +34 -0
- package/templates/nova/src/components/base/Skeleton.css +17 -0
- package/templates/nova/src/components/base/Skeleton.tsx +23 -0
- package/templates/nova/src/components/base/Spinner.css +13 -0
- package/templates/nova/src/components/base/Spinner.tsx +8 -0
- package/templates/nova/src/components/base/Switch.tsx +16 -0
- package/templates/nova/src/components/base/Tabs.css +24 -0
- package/templates/nova/src/components/base/Tabs.tsx +61 -0
- package/templates/nova/src/components/base/Textarea.css +1 -0
- package/templates/nova/src/components/base/Textarea.tsx +8 -0
- package/templates/nova/src/components/base/choice-props.ts +9 -0
- package/templates/nova/src/components/base/choice.css +69 -0
- package/templates/nova/src/components/commerce/AddToCart.css +4 -0
- package/templates/nova/src/components/commerce/AddToCart.tsx +77 -0
- package/templates/nova/src/components/commerce/CartLine.css +26 -0
- package/templates/nova/src/components/commerce/CartLine.tsx +82 -0
- package/templates/nova/src/components/commerce/CartSummary.css +23 -0
- package/templates/nova/src/components/commerce/CartSummary.tsx +120 -0
- package/templates/nova/src/components/commerce/CollectionCard.css +66 -0
- package/templates/nova/src/components/commerce/CollectionCard.tsx +57 -0
- package/templates/nova/src/components/commerce/ComparisonTable.css +33 -0
- package/templates/nova/src/components/commerce/ComparisonTable.tsx +113 -0
- package/templates/nova/src/components/commerce/EarnHint.css +3 -0
- package/templates/nova/src/components/commerce/EarnHint.tsx +31 -0
- package/templates/nova/src/components/commerce/Hotspot.css +16 -0
- package/templates/nova/src/components/commerce/Hotspot.tsx +64 -0
- package/templates/nova/src/components/commerce/ListingParts.css +79 -0
- package/templates/nova/src/components/commerce/ListingParts.tsx +211 -0
- package/templates/nova/src/components/commerce/LookItem.css +19 -0
- package/templates/nova/src/components/commerce/LookItem.tsx +41 -0
- package/templates/nova/src/components/commerce/MiniCartLine.css +20 -0
- package/templates/nova/src/components/commerce/MiniCartLine.tsx +93 -0
- package/templates/nova/src/components/commerce/PaymentMark.css +2 -0
- package/templates/nova/src/components/commerce/PaymentMark.tsx +55 -0
- package/templates/nova/src/components/commerce/Price.css +27 -0
- package/templates/nova/src/components/commerce/Price.tsx +55 -0
- package/templates/nova/src/components/commerce/ProductCard.css +66 -0
- package/templates/nova/src/components/commerce/ProductCard.tsx +117 -0
- package/templates/nova/src/components/commerce/ProductGallery.css +72 -0
- package/templates/nova/src/components/commerce/ProductGallery.tsx +98 -0
- package/templates/nova/src/components/commerce/QuantitySelector.css +23 -0
- package/templates/nova/src/components/commerce/QuantitySelector.tsx +45 -0
- package/templates/nova/src/components/commerce/Reviews.css +34 -0
- package/templates/nova/src/components/commerce/Reviews.tsx +112 -0
- package/templates/nova/src/components/commerce/Stars.css +7 -0
- package/templates/nova/src/components/commerce/Stars.tsx +38 -0
- package/templates/nova/src/components/commerce/VariantPicker.css +31 -0
- package/templates/nova/src/components/commerce/VariantPicker.tsx +122 -0
- package/templates/nova/src/components/commerce/blocks/Badge.css +6 -0
- package/templates/nova/src/components/commerce/blocks/Badge.tsx +33 -0
- package/templates/nova/src/components/commerce/blocks/PaymentIcons.tsx +43 -0
- package/templates/nova/src/components/commerce/blocks/Swatches.tsx +17 -0
- package/templates/nova/src/components/commerce/blocks/payment.css +2 -0
- package/templates/nova/src/components/commerce/cart-limit.ts +11 -0
- package/templates/nova/src/components/commerce/money.ts +34 -0
- package/templates/nova/src/components/commerce/swatch.ts +54 -0
- package/templates/nova/src/components/content/ArticleCard.css +22 -0
- package/templates/nova/src/components/content/ArticleCard.tsx +53 -0
- package/templates/nova/src/components/content/BeforeAfterSlider.css +38 -0
- package/templates/nova/src/components/content/BeforeAfterSlider.tsx +87 -0
- package/templates/nova/src/components/content/CardRow.css +80 -0
- package/templates/nova/src/components/content/CardRow.tsx +140 -0
- package/templates/nova/src/components/content/CarouselControls.css +61 -0
- package/templates/nova/src/components/content/CarouselControls.tsx +90 -0
- package/templates/nova/src/components/content/ContentsNav.css +16 -0
- package/templates/nova/src/components/content/ContentsNav.tsx +55 -0
- package/templates/nova/src/components/content/Countdown.css +24 -0
- package/templates/nova/src/components/content/Countdown.tsx +115 -0
- package/templates/nova/src/components/content/HeroCopy.css +92 -0
- package/templates/nova/src/components/content/HeroCopy.tsx +148 -0
- package/templates/nova/src/components/content/HeroFrame.css +75 -0
- package/templates/nova/src/components/content/HeroFrame.tsx +49 -0
- package/templates/nova/src/components/content/HeroMedia.css +40 -0
- package/templates/nova/src/components/content/HeroMedia.tsx +170 -0
- package/templates/nova/src/components/content/LongForm.css +40 -0
- package/templates/nova/src/components/content/LongForm.tsx +56 -0
- package/templates/nova/src/components/content/MediaFrame.css +5 -0
- package/templates/nova/src/components/content/MediaFrame.tsx +52 -0
- package/templates/nova/src/components/content/RichText.tsx +30 -0
- package/templates/nova/src/components/content/SectionHead.css +8 -0
- package/templates/nova/src/components/content/SectionHead.tsx +34 -0
- package/templates/nova/src/components/content/ShareButtons.css +2 -0
- package/templates/nova/src/components/content/ShareButtons.tsx +40 -0
- package/templates/nova/src/components/content/StoreCard.css +14 -0
- package/templates/nova/src/components/content/StoreCard.tsx +60 -0
- package/templates/nova/src/components/content/TestimonialCard.css +36 -0
- package/templates/nova/src/components/content/TestimonialCard.tsx +102 -0
- package/templates/nova/src/components/content/UgcTile.css +8 -0
- package/templates/nova/src/components/content/UgcTile.tsx +33 -0
- package/templates/nova/src/components/content/blocks/Button.tsx +36 -0
- package/templates/nova/src/components/content/blocks/Column.tsx +30 -0
- package/templates/nova/src/components/content/blocks/Heading.tsx +31 -0
- package/templates/nova/src/components/content/blocks/Icon.tsx +25 -0
- package/templates/nova/src/components/content/blocks/Image.tsx +42 -0
- package/templates/nova/src/components/content/blocks/Text.tsx +26 -0
- package/templates/nova/src/components/content/blocks/Video.tsx +44 -0
- package/templates/nova/src/components/content/blocks/content.css +25 -0
- package/templates/nova/src/components/content/blocks/shared.ts +5 -0
- package/templates/nova/src/components/forms/ContactForm.css +19 -0
- package/templates/nova/src/components/forms/ContactForm.tsx +139 -0
- package/templates/nova/src/components/forms/FormField.css +15 -0
- package/templates/nova/src/components/forms/FormField.tsx +77 -0
- package/templates/nova/src/components/forms/GatewayFields.tsx +79 -0
- package/templates/nova/src/components/forms/NewsletterForm.css +9 -0
- package/templates/nova/src/components/forms/NewsletterForm.tsx +141 -0
- package/templates/nova/src/components/forms/SearchField.css +7 -0
- package/templates/nova/src/components/forms/SearchField.tsx +68 -0
- package/templates/nova/src/components/forms/blocks/Newsletter.css +5 -0
- package/templates/nova/src/components/forms/blocks/Newsletter.tsx +71 -0
- package/templates/nova/src/components/forms/validate.ts +4 -0
- package/templates/nova/src/components/listing/ProductListing.tsx +200 -0
- package/templates/nova/src/components/navigation/BrandLogo.tsx +35 -0
- package/templates/nova/src/components/navigation/Breadcrumb.css +16 -0
- package/templates/nova/src/components/navigation/Breadcrumb.tsx +59 -0
- package/templates/nova/src/components/navigation/LineAddFriend.css +5 -0
- package/templates/nova/src/components/navigation/LineAddFriend.tsx +42 -0
- package/templates/nova/src/components/navigation/LocaleSelector.css +33 -0
- package/templates/nova/src/components/navigation/LocaleSelector.tsx +64 -0
- package/templates/nova/src/components/navigation/Menu.tsx +26 -0
- package/templates/nova/src/components/navigation/Pagination.css +24 -0
- package/templates/nova/src/components/navigation/Pagination.tsx +74 -0
- package/templates/nova/src/components/navigation/RecoveryLinks.css +8 -0
- package/templates/nova/src/components/navigation/RecoveryLinks.tsx +23 -0
- package/templates/nova/src/components/navigation/SocialLinks.css +5 -0
- package/templates/nova/src/components/navigation/SocialLinks.tsx +51 -0
- package/templates/nova/src/components/navigation/blocks/SocialLinks.tsx +23 -0
- package/templates/nova/src/components/overlays/AccountMenu.css +11 -0
- package/templates/nova/src/components/overlays/AccountMenu.tsx +91 -0
- package/templates/nova/src/components/overlays/CartDrawer.css +17 -0
- package/templates/nova/src/components/overlays/CartDrawer.tsx +118 -0
- package/templates/nova/src/components/overlays/ConfirmationDialog.tsx +49 -0
- package/templates/nova/src/components/overlays/CookieConsent.css +56 -0
- package/templates/nova/src/components/overlays/CookieConsent.tsx +170 -0
- package/templates/nova/src/components/overlays/Drawer.css +38 -0
- package/templates/nova/src/components/overlays/Drawer.tsx +66 -0
- package/templates/nova/src/components/overlays/FriendOfferPanel.tsx +79 -0
- package/templates/nova/src/components/overlays/MarketSelector.css +111 -0
- package/templates/nova/src/components/overlays/MarketSelector.tsx +450 -0
- package/templates/nova/src/components/overlays/Menu.css +9 -0
- package/templates/nova/src/components/overlays/Menu.tsx +124 -0
- package/templates/nova/src/components/overlays/MobileNavDrawer.css +28 -0
- package/templates/nova/src/components/overlays/MobileNavDrawer.tsx +166 -0
- package/templates/nova/src/components/overlays/Modal.css +52 -0
- package/templates/nova/src/components/overlays/Modal.tsx +88 -0
- package/templates/nova/src/components/overlays/Popover.css +4 -0
- package/templates/nova/src/components/overlays/Popover.tsx +115 -0
- package/templates/nova/src/components/overlays/ProductLightbox.css +20 -0
- package/templates/nova/src/components/overlays/ProductLightbox.tsx +70 -0
- package/templates/nova/src/components/overlays/PromoPopup.css +32 -0
- package/templates/nova/src/components/overlays/PromoPopup.tsx +198 -0
- package/templates/nova/src/components/overlays/QuickView.css +31 -0
- package/templates/nova/src/components/overlays/QuickView.tsx +127 -0
- package/templates/nova/src/components/overlays/ReferralPanel.css +16 -0
- package/templates/nova/src/components/overlays/ReferralPanel.tsx +138 -0
- package/templates/nova/src/components/overlays/RewardsLauncher.css +22 -0
- package/templates/nova/src/components/overlays/RewardsLauncher.tsx +270 -0
- package/templates/nova/src/components/overlays/SearchModal.css +48 -0
- package/templates/nova/src/components/overlays/SearchModal.tsx +302 -0
- package/templates/nova/src/components/overlays/Sheet.css +16 -0
- package/templates/nova/src/components/overlays/Sheet.tsx +48 -0
- package/templates/nova/src/components/overlays/SizeGuide.css +8 -0
- package/templates/nova/src/components/overlays/SizeGuide.tsx +74 -0
- package/templates/nova/src/components/overlays/Toast.css +20 -0
- package/templates/nova/src/components/overlays/Toast.tsx +164 -0
- package/templates/nova/src/components/overlays/Tooltip.css +6 -0
- package/templates/nova/src/components/overlays/Tooltip.tsx +59 -0
- package/templates/nova/src/components/overlays/use-dialog.ts +74 -0
- package/templates/nova/src/components/section/shared.css +42 -0
- package/templates/nova/src/components/section/shared.ts +120 -0
- package/templates/nova/src/components/section/shell.tsx +29 -0
- package/templates/nova/src/components/states/Alert.css +10 -0
- package/templates/nova/src/components/states/Alert.tsx +50 -0
- package/templates/nova/src/components/states/EditorFrame.css +31 -0
- package/templates/nova/src/components/states/EditorFrame.tsx +43 -0
- package/templates/nova/src/components/states/MediaState.css +1 -0
- package/templates/nova/src/components/states/MediaState.tsx +49 -0
- package/templates/nova/src/components/states/OfflineNotice.css +4 -0
- package/templates/nova/src/components/states/OfflineNotice.tsx +24 -0
- package/templates/nova/src/components/states/SkeletonLayout.css +22 -0
- package/templates/nova/src/components/states/SkeletonLayout.tsx +104 -0
- package/templates/nova/src/components/states/StateBlock.css +22 -0
- package/templates/nova/src/components/states/StateBlock.tsx +39 -0
- package/templates/nova/src/components/states/media/MediaError.css +6 -0
- package/templates/nova/src/components/states/media/MediaError.tsx +49 -0
- package/templates/nova/src/components/states/media/MediaPlaceholder.css +24 -0
- package/templates/nova/src/components/states/media/MediaPlaceholder.tsx +101 -0
- package/templates/nova/src/components/states/media/placeholder-art.ts +142 -0
- package/templates/nova/src/layouts/Main.tsx +80 -0
- package/templates/nova/src/sections/Account/Account.tsx +109 -0
- package/templates/nova/src/sections/Account/index.ts +22 -0
- package/templates/nova/src/sections/Account/presets.ts +6 -0
- package/templates/nova/src/sections/Account/schema.ts +29 -0
- package/templates/nova/src/sections/AnnouncementBar/AnnouncementBar.css +37 -0
- package/templates/nova/src/sections/AnnouncementBar/AnnouncementBar.tsx +151 -0
- package/templates/nova/src/sections/AnnouncementBar/index.ts +20 -0
- package/templates/nova/src/sections/AnnouncementBar/presets.ts +10 -0
- package/templates/nova/src/sections/AnnouncementBar/schema.ts +26 -0
- package/templates/nova/src/sections/ArticleBody/ArticleBody.tsx +129 -0
- package/templates/nova/src/sections/ArticleBody/index.ts +21 -0
- package/templates/nova/src/sections/ArticleBody/presets.ts +10 -0
- package/templates/nova/src/sections/ArticleBody/schema.ts +40 -0
- package/templates/nova/src/sections/BeforeAfter/BeforeAfter.tsx +47 -0
- package/templates/nova/src/sections/BeforeAfter/blocks/Comparison.tsx +20 -0
- package/templates/nova/src/sections/BeforeAfter/index.ts +28 -0
- package/templates/nova/src/sections/BeforeAfter/presets.ts +10 -0
- package/templates/nova/src/sections/BeforeAfter/schema.ts +34 -0
- package/templates/nova/src/sections/BlogPosts/BlogPosts.tsx +106 -0
- package/templates/nova/src/sections/BlogPosts/index.ts +30 -0
- package/templates/nova/src/sections/BlogPosts/presets.ts +10 -0
- package/templates/nova/src/sections/BlogPosts/schema.ts +42 -0
- package/templates/nova/src/sections/Breadcrumbs/Breadcrumbs.css +10 -0
- package/templates/nova/src/sections/Breadcrumbs/Breadcrumbs.tsx +41 -0
- package/templates/nova/src/sections/Breadcrumbs/index.ts +20 -0
- package/templates/nova/src/sections/Breadcrumbs/presets.ts +6 -0
- package/templates/nova/src/sections/Breadcrumbs/schema.ts +24 -0
- package/templates/nova/src/sections/CartItems/CartItems.tsx +170 -0
- package/templates/nova/src/sections/CartItems/blocks/CartBadge.tsx +14 -0
- package/templates/nova/src/sections/CartItems/index.ts +37 -0
- package/templates/nova/src/sections/CartItems/presets.ts +8 -0
- package/templates/nova/src/sections/CartItems/schema.ts +34 -0
- package/templates/nova/src/sections/CollectionBanner/CollectionBanner.tsx +120 -0
- package/templates/nova/src/sections/CollectionBanner/index.ts +25 -0
- package/templates/nova/src/sections/CollectionBanner/presets.ts +10 -0
- package/templates/nova/src/sections/CollectionBanner/schema.ts +37 -0
- package/templates/nova/src/sections/CollectionLinks/CollectionLinks.tsx +47 -0
- package/templates/nova/src/sections/CollectionLinks/index.ts +20 -0
- package/templates/nova/src/sections/CollectionLinks/presets.ts +8 -0
- package/templates/nova/src/sections/CollectionLinks/schema.ts +33 -0
- package/templates/nova/src/sections/CollectionList/CollectionList.tsx +89 -0
- package/templates/nova/src/sections/CollectionList/blocks/CollectionItem.tsx +25 -0
- package/templates/nova/src/sections/CollectionList/index.ts +33 -0
- package/templates/nova/src/sections/CollectionList/presets.ts +10 -0
- package/templates/nova/src/sections/CollectionList/schema.ts +41 -0
- package/templates/nova/src/sections/ComparisonTable/ComparisonTable.tsx +52 -0
- package/templates/nova/src/sections/ComparisonTable/blocks/CompareItem.tsx +26 -0
- package/templates/nova/src/sections/ComparisonTable/index.ts +31 -0
- package/templates/nova/src/sections/ComparisonTable/presets.ts +8 -0
- package/templates/nova/src/sections/ComparisonTable/schema.ts +31 -0
- package/templates/nova/src/sections/ContactForm/ContactForm.tsx +83 -0
- package/templates/nova/src/sections/ContactForm/blocks/ContactDetail.tsx +13 -0
- package/templates/nova/src/sections/ContactForm/index.ts +29 -0
- package/templates/nova/src/sections/ContactForm/presets.ts +8 -0
- package/templates/nova/src/sections/ContactForm/schema.ts +34 -0
- package/templates/nova/src/sections/Divider/Divider.css +17 -0
- package/templates/nova/src/sections/Divider/Divider.tsx +21 -0
- package/templates/nova/src/sections/Divider/index.ts +20 -0
- package/templates/nova/src/sections/Divider/presets.ts +10 -0
- package/templates/nova/src/sections/Divider/schema.ts +24 -0
- package/templates/nova/src/sections/Faq/Faq.tsx +51 -0
- package/templates/nova/src/sections/Faq/blocks/FaqItem.tsx +13 -0
- package/templates/nova/src/sections/Faq/index.ts +28 -0
- package/templates/nova/src/sections/Faq/presets.ts +8 -0
- package/templates/nova/src/sections/Faq/schema.ts +32 -0
- package/templates/nova/src/sections/FeatureGridBlocks/FeatureGridBlocks.tsx +90 -0
- package/templates/nova/src/sections/FeatureGridBlocks/index.ts +35 -0
- package/templates/nova/src/sections/FeatureGridBlocks/presets.ts +8 -0
- package/templates/nova/src/sections/FeatureGridBlocks/schema.ts +35 -0
- package/templates/nova/src/sections/FeatureHighlights/FeatureHighlights.tsx +56 -0
- package/templates/nova/src/sections/FeatureHighlights/index.ts +20 -0
- package/templates/nova/src/sections/FeatureHighlights/presets.ts +6 -0
- package/templates/nova/src/sections/FeatureHighlights/schema.ts +27 -0
- package/templates/nova/src/sections/FeaturedCollection/FeaturedCollection.tsx +67 -0
- package/templates/nova/src/sections/FeaturedCollection/index.ts +21 -0
- package/templates/nova/src/sections/FeaturedCollection/presets.ts +10 -0
- package/templates/nova/src/sections/FeaturedCollection/schema.ts +39 -0
- package/templates/nova/src/sections/FeaturedProduct/FeaturedProduct.tsx +107 -0
- package/templates/nova/src/sections/FeaturedProduct/index.ts +23 -0
- package/templates/nova/src/sections/FeaturedProduct/presets.ts +8 -0
- package/templates/nova/src/sections/FeaturedProduct/schema.ts +35 -0
- package/templates/nova/src/sections/Footer/Footer.css +81 -0
- package/templates/nova/src/sections/Footer/Footer.tsx +256 -0
- package/templates/nova/src/sections/Footer/blocks/FooterBrand.tsx +40 -0
- package/templates/nova/src/sections/Footer/blocks/FooterLine.tsx +11 -0
- package/templates/nova/src/sections/Footer/blocks/FooterMenu.tsx +14 -0
- package/templates/nova/src/sections/Footer/blocks/FooterText.tsx +8 -0
- package/templates/nova/src/sections/Footer/blocks/footer.css +7 -0
- package/templates/nova/src/sections/Footer/index.ts +38 -0
- package/templates/nova/src/sections/Footer/presets.ts +10 -0
- package/templates/nova/src/sections/Footer/schema.ts +27 -0
- package/templates/nova/src/sections/Group/Group.css +59 -0
- package/templates/nova/src/sections/Group/Group.tsx +167 -0
- package/templates/nova/src/sections/Group/blocks/Accordion.tsx +26 -0
- package/templates/nova/src/sections/Group/blocks/JumboText.tsx +20 -0
- package/templates/nova/src/sections/Group/blocks/Spacer.tsx +16 -0
- package/templates/nova/src/sections/Group/index.ts +36 -0
- package/templates/nova/src/sections/Group/presets.ts +12 -0
- package/templates/nova/src/sections/Group/schema.ts +35 -0
- package/templates/nova/src/sections/Header/Header.css +185 -0
- package/templates/nova/src/sections/Header/Header.tsx +478 -0
- package/templates/nova/src/sections/Header/index.ts +32 -0
- package/templates/nova/src/sections/Header/presets.ts +10 -0
- package/templates/nova/src/sections/Header/schema.ts +32 -0
- package/templates/nova/src/sections/Hero/Hero.tsx +128 -0
- package/templates/nova/src/sections/Hero/index.ts +24 -0
- package/templates/nova/src/sections/Hero/presets.ts +16 -0
- package/templates/nova/src/sections/Hero/schema.ts +56 -0
- package/templates/nova/src/sections/ImageGallery/ImageGallery.tsx +86 -0
- package/templates/nova/src/sections/ImageGallery/index.ts +28 -0
- package/templates/nova/src/sections/ImageGallery/presets.ts +10 -0
- package/templates/nova/src/sections/ImageGallery/schema.ts +34 -0
- package/templates/nova/src/sections/ImageWithText/ImageWithText.tsx +62 -0
- package/templates/nova/src/sections/ImageWithText/index.ts +23 -0
- package/templates/nova/src/sections/ImageWithText/presets.ts +12 -0
- package/templates/nova/src/sections/ImageWithText/schema.ts +45 -0
- package/templates/nova/src/sections/LineAddFriend/LineAddFriend.tsx +25 -0
- package/templates/nova/src/sections/LineAddFriend/index.ts +20 -0
- package/templates/nova/src/sections/LineAddFriend/presets.ts +3 -0
- package/templates/nova/src/sections/LineAddFriend/schema.ts +25 -0
- package/templates/nova/src/sections/LogoList/LogoList.tsx +40 -0
- package/templates/nova/src/sections/LogoList/blocks/Logo.tsx +18 -0
- package/templates/nova/src/sections/LogoList/index.ts +29 -0
- package/templates/nova/src/sections/LogoList/presets.ts +8 -0
- package/templates/nova/src/sections/LogoList/schema.ts +29 -0
- package/templates/nova/src/sections/MainCollection/MainCollection.tsx +51 -0
- package/templates/nova/src/sections/MainCollection/index.ts +26 -0
- package/templates/nova/src/sections/MainCollection/presets.ts +10 -0
- package/templates/nova/src/sections/MainCollection/schema.ts +29 -0
- package/templates/nova/src/sections/Marquee/Marquee.tsx +114 -0
- package/templates/nova/src/sections/Marquee/index.ts +20 -0
- package/templates/nova/src/sections/Marquee/presets.ts +10 -0
- package/templates/nova/src/sections/Marquee/schema.ts +23 -0
- package/templates/nova/src/sections/Multicolumn/Multicolumn.tsx +56 -0
- package/templates/nova/src/sections/Multicolumn/index.ts +25 -0
- package/templates/nova/src/sections/Multicolumn/presets.ts +8 -0
- package/templates/nova/src/sections/Multicolumn/schema.ts +34 -0
- package/templates/nova/src/sections/Newsletter/Newsletter.tsx +64 -0
- package/templates/nova/src/sections/Newsletter/index.ts +20 -0
- package/templates/nova/src/sections/Newsletter/presets.ts +10 -0
- package/templates/nova/src/sections/Newsletter/schema.ts +36 -0
- package/templates/nova/src/sections/NotFound/NotFound.tsx +41 -0
- package/templates/nova/src/sections/NotFound/index.ts +20 -0
- package/templates/nova/src/sections/NotFound/presets.ts +6 -0
- package/templates/nova/src/sections/NotFound/schema.ts +30 -0
- package/templates/nova/src/sections/PageBody/PageBody.tsx +35 -0
- package/templates/nova/src/sections/PageBody/index.ts +21 -0
- package/templates/nova/src/sections/PageBody/presets.ts +6 -0
- package/templates/nova/src/sections/PageBody/schema.ts +29 -0
- package/templates/nova/src/sections/PolicyPage/PolicyPage.tsx +62 -0
- package/templates/nova/src/sections/PolicyPage/index.ts +23 -0
- package/templates/nova/src/sections/PolicyPage/presets.ts +6 -0
- package/templates/nova/src/sections/PolicyPage/schema.ts +27 -0
- package/templates/nova/src/sections/ProductDetails/ProductDetails.tsx +269 -0
- package/templates/nova/src/sections/ProductDetails/blocks/AddToCartBlock.tsx +15 -0
- package/templates/nova/src/sections/ProductDetails/blocks/ProductDescription.tsx +15 -0
- package/templates/nova/src/sections/ProductDetails/blocks/ProductInventory.tsx +38 -0
- package/templates/nova/src/sections/ProductDetails/blocks/ProductPrice.tsx +19 -0
- package/templates/nova/src/sections/ProductDetails/blocks/ProductSku.tsx +15 -0
- package/templates/nova/src/sections/ProductDetails/blocks/ProductTitle.tsx +17 -0
- package/templates/nova/src/sections/ProductDetails/blocks/Quantity.tsx +14 -0
- package/templates/nova/src/sections/ProductDetails/blocks/Tab.tsx +23 -0
- package/templates/nova/src/sections/ProductDetails/blocks/VariantPickerBlock.tsx +44 -0
- package/templates/nova/src/sections/ProductDetails/blocks/commerce-blocks.css +13 -0
- package/templates/nova/src/sections/ProductDetails/index.ts +44 -0
- package/templates/nova/src/sections/ProductDetails/presets.ts +10 -0
- package/templates/nova/src/sections/ProductDetails/schema.ts +44 -0
- package/templates/nova/src/sections/ProductGrid/ProductGrid.tsx +38 -0
- package/templates/nova/src/sections/ProductGrid/index.ts +25 -0
- package/templates/nova/src/sections/ProductGrid/presets.ts +6 -0
- package/templates/nova/src/sections/ProductGrid/schema.ts +37 -0
- package/templates/nova/src/sections/ProductRecommendations/ProductRecommendations.tsx +45 -0
- package/templates/nova/src/sections/ProductRecommendations/index.ts +20 -0
- package/templates/nova/src/sections/ProductRecommendations/presets.ts +8 -0
- package/templates/nova/src/sections/ProductRecommendations/schema.ts +28 -0
- package/templates/nova/src/sections/ProductReviews/ProductReviews.tsx +136 -0
- package/templates/nova/src/sections/ProductReviews/index.ts +22 -0
- package/templates/nova/src/sections/ProductReviews/presets.ts +6 -0
- package/templates/nova/src/sections/ProductReviews/schema.ts +31 -0
- package/templates/nova/src/sections/PromoBanner/PromoBanner.tsx +78 -0
- package/templates/nova/src/sections/PromoBanner/index.ts +20 -0
- package/templates/nova/src/sections/PromoBanner/presets.ts +10 -0
- package/templates/nova/src/sections/PromoBanner/schema.ts +38 -0
- package/templates/nova/src/sections/RecentlyViewed/RecentlyViewed.tsx +53 -0
- package/templates/nova/src/sections/RecentlyViewed/index.ts +20 -0
- package/templates/nova/src/sections/RecentlyViewed/presets.ts +6 -0
- package/templates/nova/src/sections/RecentlyViewed/schema.ts +26 -0
- package/templates/nova/src/sections/RichText/RichText.tsx +38 -0
- package/templates/nova/src/sections/RichText/index.ts +20 -0
- package/templates/nova/src/sections/RichText/presets.ts +10 -0
- package/templates/nova/src/sections/RichText/schema.ts +37 -0
- package/templates/nova/src/sections/SearchResults/SearchResults.tsx +112 -0
- package/templates/nova/src/sections/SearchResults/index.ts +26 -0
- package/templates/nova/src/sections/SearchResults/presets.ts +8 -0
- package/templates/nova/src/sections/SearchResults/schema.ts +30 -0
- package/templates/nova/src/sections/ShopTheLook/ShopTheLook.tsx +112 -0
- package/templates/nova/src/sections/ShopTheLook/blocks/Hotspot.tsx +22 -0
- package/templates/nova/src/sections/ShopTheLook/index.ts +33 -0
- package/templates/nova/src/sections/ShopTheLook/presets.ts +8 -0
- package/templates/nova/src/sections/ShopTheLook/schema.ts +31 -0
- package/templates/nova/src/sections/Slideshow/Slideshow.tsx +199 -0
- package/templates/nova/src/sections/Slideshow/blocks/Slide.tsx +93 -0
- package/templates/nova/src/sections/Slideshow/index.ts +30 -0
- package/templates/nova/src/sections/Slideshow/presets.ts +10 -0
- package/templates/nova/src/sections/Slideshow/schema.ts +36 -0
- package/templates/nova/src/sections/StoreLocator/StoreLocator.tsx +66 -0
- package/templates/nova/src/sections/StoreLocator/index.ts +20 -0
- package/templates/nova/src/sections/StoreLocator/presets.ts +6 -0
- package/templates/nova/src/sections/StoreLocator/schema.ts +34 -0
- package/templates/nova/src/sections/TeamFounders/TeamFounders.tsx +74 -0
- package/templates/nova/src/sections/TeamFounders/blocks/Person.tsx +28 -0
- package/templates/nova/src/sections/TeamFounders/index.ts +28 -0
- package/templates/nova/src/sections/TeamFounders/presets.ts +10 -0
- package/templates/nova/src/sections/TeamFounders/schema.ts +36 -0
- package/templates/nova/src/sections/Testimonials/Testimonials.tsx +83 -0
- package/templates/nova/src/sections/Testimonials/blocks/Testimonial.tsx +30 -0
- package/templates/nova/src/sections/Testimonials/index.ts +29 -0
- package/templates/nova/src/sections/Testimonials/presets.ts +10 -0
- package/templates/nova/src/sections/Testimonials/schema.ts +35 -0
- package/templates/nova/src/sections/Timeline/Timeline.tsx +43 -0
- package/templates/nova/src/sections/Timeline/blocks/Step.tsx +19 -0
- package/templates/nova/src/sections/Timeline/index.ts +28 -0
- package/templates/nova/src/sections/Timeline/presets.ts +8 -0
- package/templates/nova/src/sections/Timeline/schema.ts +31 -0
- package/templates/nova/src/sections/TrustBadges/TrustBadges.tsx +42 -0
- package/templates/nova/src/sections/TrustBadges/index.ts +29 -0
- package/templates/nova/src/sections/TrustBadges/presets.ts +8 -0
- package/templates/nova/src/sections/TrustBadges/schema.ts +29 -0
- package/templates/nova/src/sections/UgcGallery/UgcGallery.tsx +58 -0
- package/templates/nova/src/sections/UgcGallery/blocks/UgcImage.tsx +27 -0
- package/templates/nova/src/sections/UgcGallery/index.ts +31 -0
- package/templates/nova/src/sections/UgcGallery/presets.ts +8 -0
- package/templates/nova/src/sections/UgcGallery/schema.ts +35 -0
- package/templates/nova/src/sections/VideoHero/VideoHero.tsx +75 -0
- package/templates/nova/src/sections/VideoHero/index.ts +22 -0
- package/templates/nova/src/sections/VideoHero/presets.ts +8 -0
- package/templates/nova/src/sections/VideoHero/schema.ts +43 -0
- package/templates/nova/src/sections/data.ts +115 -0
- package/templates/nova/src/sections/shipped-copy.ts +25 -0
- package/templates/nova/src/sections/starter.ts +49 -0
- package/templates/nova/src/styles/Container.css +6 -0
- package/templates/nova/src/styles/Container.tsx +13 -0
- package/templates/nova/src/styles/Icon.css +2 -0
- package/templates/nova/src/styles/Icon.tsx +101 -0
- package/templates/nova/src/styles/NovaProvider.tsx +91 -0
- package/templates/nova/src/styles/base.css +142 -0
- package/templates/nova/src/styles/blocks.css +6 -0
- package/templates/nova/src/styles/fonts/OFL.txt +93 -0
- package/templates/nova/src/styles/fonts/geist-cyrillic-ext.woff2 +0 -0
- package/templates/nova/src/styles/fonts/geist-cyrillic.woff2 +0 -0
- package/templates/nova/src/styles/fonts/geist-latin-ext.woff2 +0 -0
- package/templates/nova/src/styles/fonts/geist-latin.woff2 +0 -0
- package/templates/nova/src/styles/fonts/geist-mono-cyrillic-ext.woff2 +0 -0
- package/templates/nova/src/styles/fonts/geist-mono-cyrillic.woff2 +0 -0
- package/templates/nova/src/styles/fonts/geist-mono-latin-ext.woff2 +0 -0
- package/templates/nova/src/styles/fonts/geist-mono-latin.woff2 +0 -0
- package/templates/nova/src/styles/fonts/geist-mono-vietnamese.woff2 +0 -0
- package/templates/nova/src/styles/fonts/geist-vietnamese.woff2 +0 -0
- package/templates/nova/src/styles/fonts.css +95 -0
- package/templates/nova/src/styles/global-settings.css +88 -0
- package/templates/nova/src/styles/index.css +6 -0
- package/templates/nova/src/styles/motion.ts +53 -0
- package/templates/nova/src/styles/scroll.ts +24 -0
- package/templates/nova/src/styles/sections/commerce.css +147 -0
- package/templates/nova/src/styles/sections/content.css +304 -0
- package/templates/nova/src/styles/sections/editorial.css +131 -0
- package/templates/nova/src/styles/sections/promotion.css +336 -0
- package/templates/nova/src/styles/sections/trust.css +117 -0
- package/templates/nova/src/styles/sections/utility.css +190 -0
- package/templates/nova/src/styles/strings.ts +492 -0
- package/templates/nova/src/styles/text.ts +4 -0
- package/templates/nova/src/styles/theme.ts +171 -0
- package/templates/nova/src/styles/tokens.css +600 -0
- package/templates/nova/src/styles/viewport.ts +23 -0
- package/templates/nova/template.json +94 -0
- package/templates/nova/templates/404.json +30 -0
- package/templates/nova/templates/account.json +15 -0
- package/templates/nova/templates/article.json +41 -0
- package/templates/nova/templates/article.longform.json +17 -0
- package/templates/nova/templates/blog.featured.json +22 -0
- package/templates/nova/templates/blog.json +29 -0
- package/templates/nova/templates/cart.json +67 -0
- package/templates/nova/templates/collection.featured.json +43 -0
- package/templates/nova/templates/collection.json +30 -0
- package/templates/nova/templates/contact.json +65 -0
- package/templates/nova/templates/index.json +167 -0
- package/templates/nova/templates/list-collections.json +19 -0
- package/templates/nova/templates/page.about.json +134 -0
- package/templates/nova/templates/page.contact.json +27 -0
- package/templates/nova/templates/page.json +27 -0
- package/templates/nova/templates/policy.json +23 -0
- package/templates/nova/templates/product.bundle.json +145 -0
- package/templates/nova/templates/product.json +119 -0
- package/templates/nova/templates/search.json +17 -0
- package/templates/nova/tests/abi-ai-contract.test.ts +99 -0
- package/templates/nova/tests/abi-forms.test.tsx +269 -0
- package/templates/nova/tests/abi-inventory.test.tsx +197 -0
- package/templates/nova/tests/abi-legacy-settings.test.tsx +105 -0
- package/templates/nova/tests/abi-opt-in.test.tsx +100 -0
- package/templates/nova/tests/abi-parity.test.tsx +95 -0
- package/templates/nova/tests/abi-r5-store-settings.test.tsx +337 -0
- package/templates/nova/tests/abi-render.test.tsx +178 -0
- package/templates/nova/tests/abi-shop-links.test.tsx +141 -0
- package/templates/nova/tests/abi-storefront-basics.test.tsx +233 -0
- package/templates/nova/tests/abi-variant-url.test.tsx +73 -0
- package/templates/nova/tests/add-refused-no-success.test.tsx +193 -0
- package/templates/nova/tests/architecture.test.ts +63 -0
- package/templates/nova/tests/architecture.ts +160 -0
- package/templates/nova/tests/audit-guards.test.ts +31 -0
- package/templates/nova/tests/bundle-split.test.ts +29 -0
- package/templates/nova/tests/cart-limit-message.test.tsx +212 -0
- package/templates/nova/tests/cart-link-message.test.tsx +98 -0
- package/templates/nova/tests/cases/components/Overview.cases.tsx +8 -0
- package/templates/nova/tests/cases/components/base/Accordion.cases.tsx +40 -0
- package/templates/nova/tests/cases/components/base/Badge.cases.tsx +30 -0
- package/templates/nova/tests/cases/components/base/Button.cases.tsx +73 -0
- package/templates/nova/tests/cases/components/base/Checkbox.cases.tsx +27 -0
- package/templates/nova/tests/cases/components/base/Chip.cases.tsx +37 -0
- package/templates/nova/tests/cases/components/base/Divider.cases.tsx +26 -0
- package/templates/nova/tests/cases/components/base/IconButton.cases.tsx +28 -0
- package/templates/nova/tests/cases/components/base/Input.cases.tsx +28 -0
- package/templates/nova/tests/cases/components/base/Link.cases.tsx +27 -0
- package/templates/nova/tests/cases/components/base/Radio.cases.tsx +27 -0
- package/templates/nova/tests/cases/components/base/Select.cases.tsx +26 -0
- package/templates/nova/tests/cases/components/base/Skeleton.cases.tsx +29 -0
- package/templates/nova/tests/cases/components/base/Spinner.cases.tsx +16 -0
- package/templates/nova/tests/cases/components/base/Switch.cases.tsx +26 -0
- package/templates/nova/tests/cases/components/base/Tabs.cases.tsx +39 -0
- package/templates/nova/tests/cases/components/base/Textarea.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/commerce/AddToCart.cases.tsx +36 -0
- package/templates/nova/tests/cases/components/commerce/CartLine.cases.tsx +20 -0
- package/templates/nova/tests/cases/components/commerce/CartSummary.cases.tsx +16 -0
- package/templates/nova/tests/cases/components/commerce/CollectionCard.cases.tsx +19 -0
- package/templates/nova/tests/cases/components/commerce/ComparisonTable.cases.tsx +19 -0
- package/templates/nova/tests/cases/components/commerce/Hotspot.cases.tsx +25 -0
- package/templates/nova/tests/cases/components/commerce/LookItem.cases.tsx +19 -0
- package/templates/nova/tests/cases/components/commerce/PaymentMark.cases.tsx +16 -0
- package/templates/nova/tests/cases/components/commerce/Price.cases.tsx +27 -0
- package/templates/nova/tests/cases/components/commerce/ProductCard.cases.tsx +67 -0
- package/templates/nova/tests/cases/components/commerce/ProductGallery.cases.tsx +39 -0
- package/templates/nova/tests/cases/components/commerce/QuantitySelector.cases.tsx +31 -0
- package/templates/nova/tests/cases/components/commerce/Reviews.cases.tsx +35 -0
- package/templates/nova/tests/cases/components/commerce/Stars.cases.tsx +16 -0
- package/templates/nova/tests/cases/components/commerce/VariantPicker.cases.tsx +38 -0
- package/templates/nova/tests/cases/components/commerce/blocks/Badge.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/commerce/blocks/PaymentIcons.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/commerce/blocks/Swatches.cases.tsx +22 -0
- package/templates/nova/tests/cases/components/content/ArticleCard.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/content/BeforeAfterSlider.cases.tsx +18 -0
- package/templates/nova/tests/cases/components/content/CardRow.cases.tsx +23 -0
- package/templates/nova/tests/cases/components/content/CarouselControls.cases.tsx +48 -0
- package/templates/nova/tests/cases/components/content/ContentsNav.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/content/Countdown.cases.tsx +28 -0
- package/templates/nova/tests/cases/components/content/HeroCopy.cases.tsx +42 -0
- package/templates/nova/tests/cases/components/content/HeroFrame.cases.tsx +22 -0
- package/templates/nova/tests/cases/components/content/HeroMedia.cases.tsx +18 -0
- package/templates/nova/tests/cases/components/content/LongForm.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/content/MediaFrame.cases.tsx +32 -0
- package/templates/nova/tests/cases/components/content/RichText.cases.tsx +19 -0
- package/templates/nova/tests/cases/components/content/SectionHead.cases.tsx +19 -0
- package/templates/nova/tests/cases/components/content/ShareButtons.cases.tsx +24 -0
- package/templates/nova/tests/cases/components/content/StoreCard.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/content/TestimonialCard.cases.tsx +19 -0
- package/templates/nova/tests/cases/components/content/UgcTile.cases.tsx +18 -0
- package/templates/nova/tests/cases/components/content/blocks/Button.cases.tsx +20 -0
- package/templates/nova/tests/cases/components/content/blocks/Column.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/content/blocks/Heading.cases.tsx +18 -0
- package/templates/nova/tests/cases/components/content/blocks/Icon.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/content/blocks/Image.cases.tsx +22 -0
- package/templates/nova/tests/cases/components/content/blocks/Text.cases.tsx +18 -0
- package/templates/nova/tests/cases/components/content/blocks/Video.cases.tsx +18 -0
- package/templates/nova/tests/cases/components/forms/ContactForm.cases.tsx +29 -0
- package/templates/nova/tests/cases/components/forms/FormField.cases.tsx +61 -0
- package/templates/nova/tests/cases/components/forms/NewsletterForm.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/forms/SearchField.cases.tsx +25 -0
- package/templates/nova/tests/cases/components/forms/blocks/Newsletter.cases.tsx +19 -0
- package/templates/nova/tests/cases/components/navigation/BrandLogo.cases.tsx +29 -0
- package/templates/nova/tests/cases/components/navigation/Breadcrumb.cases.tsx +19 -0
- package/templates/nova/tests/cases/components/navigation/LocaleSelector.cases.tsx +32 -0
- package/templates/nova/tests/cases/components/navigation/Menu.cases.tsx +27 -0
- package/templates/nova/tests/cases/components/navigation/Pagination.cases.tsx +25 -0
- package/templates/nova/tests/cases/components/navigation/RecoveryLinks.cases.tsx +16 -0
- package/templates/nova/tests/cases/components/navigation/SocialLinks.cases.tsx +18 -0
- package/templates/nova/tests/cases/components/navigation/blocks/SocialLinks.cases.tsx +17 -0
- package/templates/nova/tests/cases/components/overlays/AccountMenu.cases.tsx +28 -0
- package/templates/nova/tests/cases/components/overlays/CartDrawer.cases.tsx +30 -0
- package/templates/nova/tests/cases/components/overlays/ConfirmationDialog.cases.tsx +16 -0
- package/templates/nova/tests/cases/components/overlays/CookieConsent.cases.tsx +23 -0
- package/templates/nova/tests/cases/components/overlays/CookiePreferences.cases.tsx +16 -0
- package/templates/nova/tests/cases/components/overlays/Drawer.cases.tsx +52 -0
- package/templates/nova/tests/cases/components/overlays/MarketSelector.cases.tsx +82 -0
- package/templates/nova/tests/cases/components/overlays/Menu.cases.tsx +27 -0
- package/templates/nova/tests/cases/components/overlays/MobileNavDrawer.cases.tsx +32 -0
- package/templates/nova/tests/cases/components/overlays/Modal.cases.tsx +71 -0
- package/templates/nova/tests/cases/components/overlays/Popover.cases.tsx +50 -0
- package/templates/nova/tests/cases/components/overlays/PromoPopup.cases.tsx +19 -0
- package/templates/nova/tests/cases/components/overlays/QuickView.cases.tsx +18 -0
- package/templates/nova/tests/cases/components/overlays/SearchModal.cases.tsx +60 -0
- package/templates/nova/tests/cases/components/overlays/Sheet.cases.tsx +32 -0
- package/templates/nova/tests/cases/components/overlays/SizeGuide.cases.tsx +27 -0
- package/templates/nova/tests/cases/components/overlays/Toast.cases.tsx +48 -0
- package/templates/nova/tests/cases/components/overlays/Tooltip.cases.tsx +33 -0
- package/templates/nova/tests/cases/components/states/Alert.cases.tsx +27 -0
- package/templates/nova/tests/cases/components/states/EditorFrame.cases.tsx +36 -0
- package/templates/nova/tests/cases/components/states/Empty.cases.tsx +30 -0
- package/templates/nova/tests/cases/components/states/Error.cases.tsx +38 -0
- package/templates/nova/tests/cases/components/states/Loading.cases.tsx +15 -0
- package/templates/nova/tests/cases/components/states/MediaState.cases.tsx +29 -0
- package/templates/nova/tests/cases/components/states/SkeletonLayout.cases.tsx +20 -0
- package/templates/nova/tests/cases/components/states/Unavailable.cases.tsx +16 -0
- package/templates/nova/tests/cases/components/states/media/MediaError.cases.tsx +18 -0
- package/templates/nova/tests/cases/components/states/media/MediaPlaceholder.cases.tsx +87 -0
- package/templates/nova/tests/cases/sections/Overview.cases.tsx +8 -0
- package/templates/nova/tests/cases/sections/commerce/collection-list/CollectionList.cases.tsx +46 -0
- package/templates/nova/tests/cases/sections/commerce/collection-list/blocks/CollectionItem.cases.tsx +18 -0
- package/templates/nova/tests/cases/sections/commerce/featured-collection/FeaturedCollection.cases.tsx +46 -0
- package/templates/nova/tests/cases/sections/commerce/featured-product/FeaturedProduct.cases.tsx +40 -0
- package/templates/nova/tests/cases/sections/commerce/main-collection/MainCollection.cases.tsx +81 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/ProductDetails.cases.tsx +110 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/blocks/AddToCartBlock.cases.tsx +21 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/blocks/ProductDescription.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/blocks/ProductInventory.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/blocks/ProductPrice.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/blocks/ProductSku.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/blocks/ProductTitle.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/blocks/Quantity.cases.tsx +20 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/blocks/Tab.cases.tsx +29 -0
- package/templates/nova/tests/cases/sections/commerce/product-details/blocks/VariantPickerBlock.cases.tsx +32 -0
- package/templates/nova/tests/cases/sections/commerce/product-grid/ProductGrid.cases.tsx +48 -0
- package/templates/nova/tests/cases/sections/commerce/product-recommendations/ProductRecommendations.cases.tsx +27 -0
- package/templates/nova/tests/cases/sections/commerce/recently-viewed/RecentlyViewed.cases.tsx +36 -0
- package/templates/nova/tests/cases/sections/content/article-body/ArticleBody.cases.tsx +32 -0
- package/templates/nova/tests/cases/sections/content/before-after/BeforeAfter.cases.tsx +40 -0
- package/templates/nova/tests/cases/sections/content/before-after/blocks/Comparison.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/content/blog-posts/BlogPosts.cases.tsx +47 -0
- package/templates/nova/tests/cases/sections/content/collection-links/CollectionLinks.cases.tsx +36 -0
- package/templates/nova/tests/cases/sections/content/faq/Faq.cases.tsx +38 -0
- package/templates/nova/tests/cases/sections/content/faq/blocks/FaqItem.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/content/feature-grid-blocks/FeatureGridBlocks.cases.tsx +31 -0
- package/templates/nova/tests/cases/sections/content/feature-highlights/FeatureHighlights.cases.tsx +26 -0
- package/templates/nova/tests/cases/sections/content/image-gallery/ImageGallery.cases.tsx +31 -0
- package/templates/nova/tests/cases/sections/content/image-with-text/ImageWithText.cases.tsx +35 -0
- package/templates/nova/tests/cases/sections/content/multicolumn/Multicolumn.cases.tsx +32 -0
- package/templates/nova/tests/cases/sections/content/page-body/PageBody.cases.tsx +31 -0
- package/templates/nova/tests/cases/sections/content/rich-text/RichTextSection.cases.tsx +33 -0
- package/templates/nova/tests/cases/sections/content/team-founders/TeamFounders.cases.tsx +31 -0
- package/templates/nova/tests/cases/sections/content/team-founders/blocks/Person.cases.tsx +18 -0
- package/templates/nova/tests/cases/sections/content/timeline/Timeline.cases.tsx +27 -0
- package/templates/nova/tests/cases/sections/content/timeline/blocks/Step.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/layout/announcement-bar/AnnouncementBar.cases.tsx +119 -0
- package/templates/nova/tests/cases/sections/layout/breadcrumbs/Breadcrumbs.cases.tsx +73 -0
- package/templates/nova/tests/cases/sections/layout/divider/Divider.cases.tsx +81 -0
- package/templates/nova/tests/cases/sections/layout/footer/Footer.cases.tsx +116 -0
- package/templates/nova/tests/cases/sections/layout/footer/blocks/FooterBrand.cases.tsx +27 -0
- package/templates/nova/tests/cases/sections/layout/footer/blocks/FooterMenu.cases.tsx +22 -0
- package/templates/nova/tests/cases/sections/layout/footer/blocks/FooterText.cases.tsx +20 -0
- package/templates/nova/tests/cases/sections/layout/group/Group.cases.tsx +185 -0
- package/templates/nova/tests/cases/sections/layout/group/blocks/Accordion.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/layout/group/blocks/JumboText.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/layout/group/blocks/Spacer.cases.tsx +33 -0
- package/templates/nova/tests/cases/sections/layout/header/Header.cases.tsx +277 -0
- package/templates/nova/tests/cases/sections/marketing/collection-banner/CollectionBanner.cases.tsx +62 -0
- package/templates/nova/tests/cases/sections/marketing/hero/Hero.cases.tsx +138 -0
- package/templates/nova/tests/cases/sections/marketing/marquee/Marquee.cases.tsx +63 -0
- package/templates/nova/tests/cases/sections/marketing/promo-banner/PromoBanner.cases.tsx +87 -0
- package/templates/nova/tests/cases/sections/marketing/slideshow/Slideshow.cases.tsx +113 -0
- package/templates/nova/tests/cases/sections/marketing/slideshow/blocks/Slide.cases.tsx +26 -0
- package/templates/nova/tests/cases/sections/marketing/video-hero/VideoHero.cases.tsx +72 -0
- package/templates/nova/tests/cases/sections/trust/comparison-table/ComparisonTableSection.cases.tsx +42 -0
- package/templates/nova/tests/cases/sections/trust/comparison-table/blocks/CompareItem.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/trust/logo-list/LogoList.cases.tsx +29 -0
- package/templates/nova/tests/cases/sections/trust/logo-list/blocks/Logo.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/trust/product-reviews/ProductReviews.cases.tsx +51 -0
- package/templates/nova/tests/cases/sections/trust/shop-the-look/ShopTheLook.cases.tsx +51 -0
- package/templates/nova/tests/cases/sections/trust/shop-the-look/blocks/Hotspot.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/trust/testimonials/Testimonials.cases.tsx +61 -0
- package/templates/nova/tests/cases/sections/trust/testimonials/blocks/Testimonial.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/trust/trust-badges/TrustBadges.cases.tsx +30 -0
- package/templates/nova/tests/cases/sections/trust/ugc-gallery/UgcGallery.cases.tsx +32 -0
- package/templates/nova/tests/cases/sections/trust/ugc-gallery/blocks/UgcImage.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/utility/account/Account.cases.tsx +44 -0
- package/templates/nova/tests/cases/sections/utility/cart-items/CartItems.cases.tsx +43 -0
- package/templates/nova/tests/cases/sections/utility/cart-items/blocks/CartBadge.cases.tsx +16 -0
- package/templates/nova/tests/cases/sections/utility/contact-form/ContactFormSection.cases.tsx +52 -0
- package/templates/nova/tests/cases/sections/utility/contact-form/blocks/ContactDetail.cases.tsx +17 -0
- package/templates/nova/tests/cases/sections/utility/newsletter/NewsletterSection.cases.tsx +109 -0
- package/templates/nova/tests/cases/sections/utility/not-found/NotFound.cases.tsx +28 -0
- package/templates/nova/tests/cases/sections/utility/policy-page/PolicyPage.cases.tsx +29 -0
- package/templates/nova/tests/cases/sections/utility/search-results/SearchResultsSection.cases.tsx +39 -0
- package/templates/nova/tests/cases/sections/utility/store-locator/StoreLocator.cases.tsx +40 -0
- package/templates/nova/tests/cases/styles/Borders.cases.tsx +10 -0
- package/templates/nova/tests/cases/styles/Breakpoints.cases.tsx +10 -0
- package/templates/nova/tests/cases/styles/Colors.cases.tsx +10 -0
- package/templates/nova/tests/cases/styles/Elevation.cases.tsx +10 -0
- package/templates/nova/tests/cases/styles/Icon.cases.tsx +23 -0
- package/templates/nova/tests/cases/styles/Layout.cases.tsx +8 -0
- package/templates/nova/tests/cases/styles/Motion.cases.tsx +10 -0
- package/templates/nova/tests/cases/styles/Overview.cases.tsx +8 -0
- package/templates/nova/tests/cases/styles/Radius.cases.tsx +10 -0
- package/templates/nova/tests/cases/styles/SharedThemeSettings.cases.tsx +19 -0
- package/templates/nova/tests/cases/styles/Spacing.cases.tsx +10 -0
- package/templates/nova/tests/cases/styles/Typography.cases.tsx +10 -0
- package/templates/nova/tests/cases.test.tsx +38 -0
- package/templates/nova/tests/components/PromoPopup.test.ts +21 -0
- package/templates/nova/tests/components/RichText.test.tsx +65 -0
- package/templates/nova/tests/components/formatDate.test.ts +10 -0
- package/templates/nova/tests/contract-locks.test.ts +23 -0
- package/templates/nova/tests/contracts.test.ts +153 -0
- package/templates/nova/tests/cookie-consent-privacy.test.tsx +128 -0
- package/templates/nova/tests/empty-store.test.tsx +81 -0
- package/templates/nova/tests/fixtures/commerce.ts +128 -0
- package/templates/nova/tests/fixtures/content.ts +58 -0
- package/templates/nova/tests/fixtures/index.ts +8 -0
- package/templates/nova/tests/fixtures/merch.ts +161 -0
- package/templates/nova/tests/fixtures/navigation.ts +125 -0
- package/templates/nova/tests/fixtures/promotion.ts +43 -0
- package/templates/nova/tests/fixtures/sample-store.json +1674 -0
- package/templates/nova/tests/fixtures/shop.ts +88 -0
- package/templates/nova/tests/fixtures/stress.ts +21 -0
- package/templates/nova/tests/inert.test.tsx +285 -0
- package/templates/nova/tests/line-add-friend.test.tsx +108 -0
- package/templates/nova/tests/localized-copy.test.ts +330 -0
- package/templates/nova/tests/product-template-blocks.test.ts +28 -0
- package/templates/nova/tests/rewards-launcher.test.tsx +401 -0
- package/templates/nova/tests/schema.test.ts +65 -0
- package/templates/nova/tests/schema.typetest.ts +7 -0
- package/templates/nova/tests/section-groups.test.ts +189 -0
- package/templates/nova/tests/sections/Group.test.tsx +37 -0
- package/templates/nova/tests/setup.ts +30 -0
- package/templates/nova/tests/starter.test.ts +56 -0
- package/templates/nova/tests/storefront-click-path.test.tsx +157 -0
- package/templates/nova/tests/styles/button-brand.test.ts +24 -0
- package/templates/nova/tests/styles/theme.test.ts +43 -0
- package/templates/nova/tests/styles/tokens.test.ts +35 -0
- package/templates/nova/tests/support/abi-ctx.ts +136 -0
- package/templates/nova/tests/support/block-stories.tsx +13 -0
- package/templates/nova/tests/support/case.tsx +102 -0
- package/templates/nova/tests/support/contracts.ts +30 -0
- package/templates/nova/tests/support/foundation-pages.tsx +260 -0
- package/templates/nova/tests/support/ia-pages.tsx +154 -0
- package/templates/nova/tests/support/listing-demo.tsx +29 -0
- package/templates/nova/tests/support/presets.ts +14 -0
- package/templates/nova/tests/support/sections.ts +36 -0
- package/templates/nova/tests/support/story-content.ts +321 -0
- package/templates/nova/tests/support/story-helpers.tsx +37 -0
- package/templates/nova/tests/support/with-nova.tsx +26 -0
- package/templates/nova/tests/theme-config.test.ts +82 -0
- package/templates/nova/tests/theme-integrity.test.ts +315 -0
- package/templates/nova/theme.config.ts +134 -0
- package/templates/nova/theme.manifest.json +17495 -0
- package/templates/nova/tsconfig.json +19 -0
- package/templates/nova/vite.abi-ssr.config.ts +37 -0
- package/templates/nova/vite.abi.config.ts +26 -0
- package/templates/nova/vitest.config.ts +20 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { useEffect, useId, useRef, useState, type ReactNode } from 'react'
|
|
2
|
+
import { sx, useReferrals, useRewards } from '@tanqory/theme-kit'
|
|
3
|
+
import type { RewardsReward, RewardsState, RewardsWay } from '@tanqory/theme-kit'
|
|
4
|
+
import { Button } from '../base/Button'
|
|
5
|
+
import { Tabs, type TabItem } from '../base/Tabs'
|
|
6
|
+
import { formatMoney } from '../commerce/money'
|
|
7
|
+
import { Icon } from '../../styles/Icon'
|
|
8
|
+
import { useNova } from '../../styles/NovaProvider'
|
|
9
|
+
import { fmt, type NovaStrings } from '../../styles/strings'
|
|
10
|
+
import { Drawer } from './Drawer'
|
|
11
|
+
import { ReferralPanel } from './ReferralPanel'
|
|
12
|
+
import './RewardsLauncher.css'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The rewards launcher (army #7749): a floating "Rewards" button that opens the program in a
|
|
16
|
+
* drawer (full screen at 390, focus trapped, Escape closes and focus returns to the button).
|
|
17
|
+
*
|
|
18
|
+
* guest the program, ways to earn, Join now / Sign in
|
|
19
|
+
* signed in Join now when not a member yet
|
|
20
|
+
* member balance, pending, tier and progress, rewards with Get a code, unused codes with
|
|
21
|
+
* Copy and Apply to cart, ways to earn (done ones marked), View my rewards
|
|
22
|
+
*
|
|
23
|
+
* Renders nothing until the loyalty or referral state is known (browser only) and with both off; the
|
|
24
|
+
* Referral tab (army #7751) is the whole panel with loyalty off. `extraTabs` adds more tabs.
|
|
25
|
+
*/
|
|
26
|
+
export interface RewardsLauncherProps {
|
|
27
|
+
extraTabs?: readonly TabItem[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function RewardsLauncher({ extraTabs = [] }: RewardsLauncherProps): JSX.Element | null {
|
|
31
|
+
const { state } = useRewards()
|
|
32
|
+
const referral = useReferrals().state
|
|
33
|
+
const { strings } = useNova()
|
|
34
|
+
const [open, setOpen] = useState(false)
|
|
35
|
+
if (!state && !referral) return null
|
|
36
|
+
const tabs: TabItem[] = [
|
|
37
|
+
...(state ? [{ id: 'rewards', label: strings.rewards, content: <RewardsPanel state={state} /> }] : []),
|
|
38
|
+
...(referral ? [{ id: 'referral', label: strings.referral, content: <ReferralPanel state={referral} /> }] : []),
|
|
39
|
+
...extraTabs,
|
|
40
|
+
]
|
|
41
|
+
const title = state ? strings.rewards : strings.referral
|
|
42
|
+
return (
|
|
43
|
+
<>
|
|
44
|
+
<button type="button" className="nv-rewards-launcher" aria-label={state ? strings.openRewards : strings.openReferral} aria-haspopup="dialog" aria-expanded={open} onClick={() => setOpen(true)}>
|
|
45
|
+
<Icon name="gift" />
|
|
46
|
+
<span aria-hidden="true">{title}</span>
|
|
47
|
+
</button>
|
|
48
|
+
<Drawer open={open} onClose={() => setOpen(false)} title={title} className="nv-rewards" initialFocus="title">
|
|
49
|
+
{tabs.length > 1 ? <Tabs variant="segmented" label={title} items={tabs} /> : tabs[0].content}
|
|
50
|
+
</Drawer>
|
|
51
|
+
</>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function RewardsPanel({ state }: { state: RewardsState }): JSX.Element {
|
|
56
|
+
const { strings } = useNova()
|
|
57
|
+
const member = state.signedIn && state.member
|
|
58
|
+
return (
|
|
59
|
+
<div className="nv-rewards__panel">
|
|
60
|
+
{member ? (
|
|
61
|
+
<MemberView state={state} />
|
|
62
|
+
) : (
|
|
63
|
+
<section className="nv-rewards__card">
|
|
64
|
+
<h3 className="nv-rewards__title">{state.program.name || strings.rewards}</h3>
|
|
65
|
+
<p>{strings.rewardsGuestIntro}</p>
|
|
66
|
+
{state.signedIn ? <JoinButton /> : (
|
|
67
|
+
<div className="nv-rewards__actions">
|
|
68
|
+
<Button href="/account/register">{strings.rewardsJoin}</Button>
|
|
69
|
+
<Button href="/account/login" variant="secondary">{strings.rewardsSignIn}</Button>
|
|
70
|
+
</div>
|
|
71
|
+
)}
|
|
72
|
+
</section>
|
|
73
|
+
)}
|
|
74
|
+
<Ways state={state} />
|
|
75
|
+
{member && (
|
|
76
|
+
<a className="nv-rewards__more" href="/account/rewards">{strings.rewardsViewAll}</a>
|
|
77
|
+
)}
|
|
78
|
+
</div>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function JoinButton(): JSX.Element {
|
|
83
|
+
const { join } = useRewards()
|
|
84
|
+
const { strings } = useNova()
|
|
85
|
+
const [busy, setBusy] = useState(false)
|
|
86
|
+
const [failed, setFailed] = useState(false)
|
|
87
|
+
const onJoin = async () => {
|
|
88
|
+
setBusy(true)
|
|
89
|
+
setFailed(false)
|
|
90
|
+
const ok = await join()
|
|
91
|
+
setBusy(false)
|
|
92
|
+
setFailed(!ok)
|
|
93
|
+
}
|
|
94
|
+
return (
|
|
95
|
+
<div className="nv-rewards__actions">
|
|
96
|
+
<Button onClick={() => void onJoin()} loading={busy}>{strings.rewardsJoin}</Button>
|
|
97
|
+
{failed && <p role="alert">{strings.rewardsJoinFailed}</p>}
|
|
98
|
+
</div>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function MemberView({ state }: { state: RewardsState }): JSX.Element {
|
|
103
|
+
const { strings, locale } = useNova()
|
|
104
|
+
const { redeem } = useRewards()
|
|
105
|
+
const n = (v: number) => new Intl.NumberFormat(locale).format(v)
|
|
106
|
+
const [busy, setBusy] = useState<string | null>(null)
|
|
107
|
+
const [message, setMessage] = useState<{ tone: 'ok' | 'error'; text: string } | null>(null)
|
|
108
|
+
const onRedeem = async (r: RewardsReward) => {
|
|
109
|
+
setBusy(r.id)
|
|
110
|
+
setMessage(null)
|
|
111
|
+
const out = await redeem(r.id)
|
|
112
|
+
setBusy(null)
|
|
113
|
+
setMessage(out.ok ? { tone: 'ok', text: fmt(strings.rewardsCodeReady, { code: out.code }) } : { tone: 'error', text: out.error === 'insufficient' ? strings.rewardsRedeemInsufficient : strings.rewardsRedeemFailed })
|
|
114
|
+
}
|
|
115
|
+
const balance = state.balance ?? { available: 0, pending: 0, lifetimeEarned: 0 }
|
|
116
|
+
const rewards = state.rewards ?? []
|
|
117
|
+
const codes = state.codes ?? []
|
|
118
|
+
return (
|
|
119
|
+
<>
|
|
120
|
+
<section className="nv-rewards__card">
|
|
121
|
+
<p className="nv-rewards__big nv-tabular">{fmt(strings.rewardsPoints, { points: n(balance.available) })}</p>
|
|
122
|
+
{balance.pending > 0 && <p className="nv-rewards__meta">{fmt(strings.rewardsPending, { points: n(balance.pending) })}</p>}
|
|
123
|
+
<TierProgress state={state} />
|
|
124
|
+
</section>
|
|
125
|
+
<p className="nv-rewards__status" role="status">{message?.tone === 'ok' ? message.text : ''}</p>
|
|
126
|
+
{message?.tone === 'error' && <p className="nv-rewards__error" role="alert">{message.text}</p>}
|
|
127
|
+
{rewards.length > 0 && (
|
|
128
|
+
<Group title={strings.rewardsRedeemHeading}>
|
|
129
|
+
{rewards.map((r) => (
|
|
130
|
+
<li key={r.id} className="nv-rewards__row">
|
|
131
|
+
<span>
|
|
132
|
+
<strong>{r.name}</strong>
|
|
133
|
+
<span className="nv-rewards__meta">{fmt(strings.rewardsPoints, { points: n(r.pointsCost) })}</span>
|
|
134
|
+
</span>
|
|
135
|
+
{r.affordable ? (
|
|
136
|
+
<Button size="sm" variant="secondary" loading={busy === r.id} disabled={busy !== null && busy !== r.id} onClick={() => void onRedeem(r)}>
|
|
137
|
+
{strings.rewardsGetCode}
|
|
138
|
+
</Button>
|
|
139
|
+
) : (
|
|
140
|
+
<span className="nv-rewards__meta">{r.tierLocked ? strings.rewardsTierLocked : r.limitReached ? strings.rewardsLimitReached : fmt(strings.rewardsPointsNeeded, { points: n(r.pointsNeeded) })}</span>
|
|
141
|
+
)}
|
|
142
|
+
</li>
|
|
143
|
+
))}
|
|
144
|
+
</Group>
|
|
145
|
+
)}
|
|
146
|
+
{codes.length > 0 && (
|
|
147
|
+
<Group title={strings.rewardsYourCodes}>
|
|
148
|
+
{codes.map((c) => (
|
|
149
|
+
<li key={c.code} className="nv-rewards__row nv-rewards__code">
|
|
150
|
+
<span>
|
|
151
|
+
<strong>{c.rewardName}</strong>
|
|
152
|
+
<code>{c.code}</code>
|
|
153
|
+
</span>
|
|
154
|
+
<span className="nv-rewards__actions">
|
|
155
|
+
<CopyButton code={c.code} />
|
|
156
|
+
<Button size="sm" href={`/discount/${encodeURIComponent(c.code)}?redirect=%2Fcart`}>{strings.rewardsApply}</Button>
|
|
157
|
+
</span>
|
|
158
|
+
</li>
|
|
159
|
+
))}
|
|
160
|
+
</Group>
|
|
161
|
+
)}
|
|
162
|
+
</>
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function TierProgress({ state }: { state: RewardsState }): JSX.Element | null {
|
|
167
|
+
const { strings, locale } = useNova()
|
|
168
|
+
const id = useId()
|
|
169
|
+
const tier = state.tier
|
|
170
|
+
if (!tier || (!tier.current && !tier.next)) return null
|
|
171
|
+
const { next, progress } = tier
|
|
172
|
+
const spend = tier.basis === 'SPEND' && tier.currency
|
|
173
|
+
const remaining = progress?.remaining
|
|
174
|
+
return (
|
|
175
|
+
<div className="nv-rewards__tier">
|
|
176
|
+
{tier.current && (
|
|
177
|
+
<p>
|
|
178
|
+
<span className="nv-rewards__meta">{strings.rewardsTier} </span>
|
|
179
|
+
<strong>{tier.current.name}</strong>
|
|
180
|
+
</p>
|
|
181
|
+
)}
|
|
182
|
+
{next && progress && remaining != null && (
|
|
183
|
+
<>
|
|
184
|
+
<div className="nv-rewards__bar" role="progressbar" aria-valuemin={0} aria-valuemax={next.threshold} aria-valuenow={progress.qualifying} aria-labelledby={id}>
|
|
185
|
+
<span className={sx({ width: `${Math.min(100, Math.round((progress.qualifying / Math.max(next.threshold, 1)) * 100))}%` })} />
|
|
186
|
+
</div>
|
|
187
|
+
<p className="nv-rewards__meta" id={id}>
|
|
188
|
+
{fmt(spend ? strings.rewardsNextTierSpend : strings.rewardsNextTier, {
|
|
189
|
+
remaining: spend ? formatMoney({ amount: remaining, currencyCode: tier.currency! }, locale) : new Intl.NumberFormat(locale).format(remaining),
|
|
190
|
+
tier: next.name,
|
|
191
|
+
})}
|
|
192
|
+
</p>
|
|
193
|
+
</>
|
|
194
|
+
)}
|
|
195
|
+
</div>
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function Ways({ state }: { state: RewardsState }): JSX.Element | null {
|
|
200
|
+
const { strings, locale } = useNova()
|
|
201
|
+
if (!state.ways.length) return null
|
|
202
|
+
return (
|
|
203
|
+
<Group title={strings.rewardsWaysToEarn}>
|
|
204
|
+
{state.ways.map((w) => (
|
|
205
|
+
<li key={w.id} className="nv-rewards__row" data-done={w.completed ? '' : undefined}>
|
|
206
|
+
<span>
|
|
207
|
+
<strong>{w.name}</strong>
|
|
208
|
+
<span className="nv-rewards__meta">{wayPoints(w, state, strings, locale)}</span>
|
|
209
|
+
</span>
|
|
210
|
+
{w.completed && (
|
|
211
|
+
<span className="nv-rewards__done">
|
|
212
|
+
<Icon name="check" size="sm" />
|
|
213
|
+
{strings.rewardsDone}
|
|
214
|
+
</span>
|
|
215
|
+
)}
|
|
216
|
+
</li>
|
|
217
|
+
))}
|
|
218
|
+
</Group>
|
|
219
|
+
)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** "50 points", or for an order "10 points for every ฿100 spent" (the smallest round amount earning 10). */
|
|
223
|
+
export function wayPoints(w: RewardsWay, state: RewardsState, strings: NovaStrings, locale: string): string {
|
|
224
|
+
const n = (v: number) => new Intl.NumberFormat(locale).format(v)
|
|
225
|
+
if (w.points !== null) return fmt(strings.rewardsPoints, { points: n(w.points) })
|
|
226
|
+
const [currency, rate] = Object.entries(state.program.earnRates)[0] ?? []
|
|
227
|
+
if (w.kind !== 'PLACE_ORDER' || !currency || !(Number(rate) > 0)) return ''
|
|
228
|
+
let amount = 1
|
|
229
|
+
while (Number(rate) * amount < 10 && amount < 1e6) amount *= 10
|
|
230
|
+
return fmt(strings.rewardsOrderRate, { points: n(Math.floor(Number(rate) * amount)), amount: formatMoney({ amount, currencyCode: currency }, locale) })
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function Group({ title, children }: { title: string; children: ReactNode }): JSX.Element {
|
|
234
|
+
const id = useId()
|
|
235
|
+
return (
|
|
236
|
+
<section className="nv-rewards__group" aria-labelledby={id}>
|
|
237
|
+
<h3 className="nv-rewards__heading" id={id}>{title}</h3>
|
|
238
|
+
<ul className="nv-rewards__list" aria-labelledby={id}>
|
|
239
|
+
{children}
|
|
240
|
+
</ul>
|
|
241
|
+
</section>
|
|
242
|
+
)
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function CopyButton({ code }: { code: string }): JSX.Element {
|
|
246
|
+
const { strings } = useNova()
|
|
247
|
+
const [copied, setCopied] = useState(false)
|
|
248
|
+
const timer = useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
249
|
+
useEffect(() => () => {
|
|
250
|
+
if (timer.current) clearTimeout(timer.current)
|
|
251
|
+
}, [])
|
|
252
|
+
const onCopy = async () => {
|
|
253
|
+
try {
|
|
254
|
+
await navigator.clipboard.writeText(code)
|
|
255
|
+
setCopied(true)
|
|
256
|
+
if (timer.current) clearTimeout(timer.current)
|
|
257
|
+
timer.current = setTimeout(() => setCopied(false), 2000)
|
|
258
|
+
} catch {
|
|
259
|
+
setCopied(false)
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return (
|
|
263
|
+
<>
|
|
264
|
+
<Button size="sm" variant="ghost" aria-label={fmt(strings.rewardsCopyNamed, { code })} onClick={() => void onCopy()}>
|
|
265
|
+
{copied ? strings.rewardsCopied : strings.rewardsCopy}
|
|
266
|
+
</Button>
|
|
267
|
+
<span className="nv-visually-hidden" aria-live="polite">{copied ? strings.rewardsCopied : ''}</span>
|
|
268
|
+
</>
|
|
269
|
+
)
|
|
270
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* Nova 13 · 4 search — a top dialog 840 wide; full screen at 390. */
|
|
2
|
+
.nv-search-modal-layer { z-index: var(--z-overlay); }
|
|
3
|
+
.nv-search-modal { position: absolute; inset-block-start: var(--space-5); inset-inline: 0; margin-inline: auto; display: flex; flex-direction: column; width: min(840px, calc(100% - 2 * var(--space-5))); max-height: calc(100svh - 2 * var(--space-5)); border: var(--overlay-hairline); border-radius: var(--overlay-radius-dialog); background: var(--color-bg-elevated); color: var(--color-fg); box-shadow: var(--overlay-shadow); opacity: 0; transform: translateY(-8px); transition: opacity var(--overlay-dialog-in) var(--ease-standard), transform var(--overlay-dialog-in) var(--ease-standard); outline: none; }
|
|
4
|
+
.nv-overlay[data-open] .nv-search-modal { opacity: 1; transform: none; }
|
|
5
|
+
.nv-search-modal__bar { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4); }
|
|
6
|
+
.nv-search-modal__field { flex: 1; display: flex; align-items: center; gap: var(--space-3); min-height: 52px; padding-inline: var(--space-4); border: 1.5px solid var(--color-focus); border-radius: var(--input-radius); }
|
|
7
|
+
.nv-search-modal__field input { flex: 1; min-width: 0; height: 48px; padding: 0; border: 0; background: none; color: inherit; font: inherit; font-size: 1rem; }
|
|
8
|
+
.nv-search-modal__field input:focus { outline: none; }
|
|
9
|
+
.nv-search-modal__field input::-webkit-search-cancel-button { display: none; }
|
|
10
|
+
.nv-search-modal__text-btn { min-height: 32px; padding: 0 var(--space-1); border: 0; background: none; color: var(--color-fg-muted); font: inherit; font-size: var(--type-caption); cursor: pointer; }
|
|
11
|
+
.nv-search-modal__cancel { min-height: var(--touch-target); padding: 0; border: 0; background: none; color: var(--color-fg); font: inherit; font-size: 0.875rem; font-weight: var(--weight-medium); text-decoration: underline; text-underline-offset: var(--underline-offset); cursor: pointer; }
|
|
12
|
+
.nv-search-modal__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--space-4) var(--space-4); }
|
|
13
|
+
.nv-search-modal__label { margin-block: var(--space-2); color: var(--color-fg-muted); font-size: var(--type-caption); }
|
|
14
|
+
.nv-search-modal__label-row { display: flex; align-items: center; justify-content: space-between; }
|
|
15
|
+
.nv-search-modal__results { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 0 var(--space-6); }
|
|
16
|
+
.nv-search-modal__results[data-stale] { opacity: 0.6; }
|
|
17
|
+
.nv-search-modal__group[data-group='products'] { grid-row: span 2; }
|
|
18
|
+
.nv-search-modal__row { display: flex; align-items: center; gap: var(--space-3); min-height: 52px; padding: var(--space-1) var(--space-2); border-radius: var(--radius-md); color: var(--color-fg); font-size: 0.875rem; text-decoration: none; outline: 1.5px solid transparent; }
|
|
19
|
+
.nv-search-modal__row[aria-selected='true'] { background: var(--color-bg-muted); outline-color: var(--color-focus); }
|
|
20
|
+
.nv-search-modal__row--text { min-height: 40px; }
|
|
21
|
+
.nv-search-modal__thumb { flex: none; width: 44px; height: 44px; border-radius: var(--radius-sm); overflow: hidden; background: var(--color-media-bg); }
|
|
22
|
+
.nv-search-modal__thumb img { width: 100%; height: 100%; object-fit: cover; }
|
|
23
|
+
.nv-search-modal__title { flex: 1; min-width: 0; }
|
|
24
|
+
.nv-search-modal__title b { font-weight: var(--weight-strong, 600); }
|
|
25
|
+
.nv-search-modal__price { flex: none; }
|
|
26
|
+
.nv-search-modal__price[data-sale] { color: var(--color-sale); }
|
|
27
|
+
.nv-search-modal__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-3) var(--space-4); border-block-start: var(--overlay-hairline); font-size: var(--type-caption); }
|
|
28
|
+
.nv-search-modal__keys { color: var(--color-fg-muted); }
|
|
29
|
+
.nv-search-modal__foot a { color: var(--color-fg); font-weight: var(--weight-medium); text-decoration: underline; text-underline-offset: var(--underline-offset); }
|
|
30
|
+
.nv-search-modal__start { display: grid; gap: var(--space-5); }
|
|
31
|
+
.nv-search-modal__chips { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; margin: 0; padding: 0; }
|
|
32
|
+
.nv-search-modal__chips li { display: inline-flex; align-items: center; border: 1px solid var(--color-border-input); border-radius: var(--radius-pill); }
|
|
33
|
+
.nv-search-modal__chip { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 36px; padding-inline: var(--space-3) var(--space-1); border: 0; background: none; color: var(--color-fg); font: inherit; font-size: 0.875rem; cursor: pointer; }
|
|
34
|
+
.nv-search-modal__chip-x { display: grid; place-items: center; width: 28px; height: 28px; margin-inline-end: 4px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--color-fg-muted); cursor: pointer; }
|
|
35
|
+
.nv-search-modal__browse { list-style: none; margin: 0; padding: 0; }
|
|
36
|
+
.nv-search-modal__browse a { display: flex; align-items: center; min-height: 52px; border-block-end: 1px solid var(--color-border); color: var(--color-fg); font-size: 1rem; text-decoration: none; }
|
|
37
|
+
.nv-search-modal__skeleton { display: grid; gap: var(--space-3); list-style: none; margin: var(--space-3) 0; padding: 0; }
|
|
38
|
+
.nv-search-modal__skeleton li { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: var(--space-3); align-items: center; }
|
|
39
|
+
.nv-search-modal__skeleton span { height: 44px; border-radius: var(--radius-sm); background: var(--color-bg-muted); }
|
|
40
|
+
.nv-search-modal__skeleton span + span { height: 12px; width: 60%; }
|
|
41
|
+
.nv-search-modal__none { display: grid; gap: var(--space-2); padding-block: var(--space-4); color: var(--color-fg-muted); font-size: 0.875rem; }
|
|
42
|
+
.nv-search-modal__none-title { color: var(--color-fg); font-size: 1rem; font-weight: var(--weight-medium); }
|
|
43
|
+
@media (max-width: 639.98px) {
|
|
44
|
+
.nv-search-modal { inset: 0; width: auto; max-height: none; border: 0; border-radius: 0; transform: none; }
|
|
45
|
+
.nv-search-modal__results { grid-template-columns: minmax(0, 1fr); }
|
|
46
|
+
.nv-search-modal__foot { display: none; }
|
|
47
|
+
}
|
|
48
|
+
@media (prefers-reduced-motion: reduce) { .nv-search-modal { transform: none !important; } }
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { Fragment, useEffect, useId, useMemo, useRef, useState, type KeyboardEvent, type ReactNode } from 'react'
|
|
2
|
+
import type { NovaLink, Product } from '@tanqory/theme-kit'
|
|
3
|
+
import { formatMoney, hasPriceRange } from '../commerce/money'
|
|
4
|
+
import { RecoveryLinks } from '../navigation/RecoveryLinks'
|
|
5
|
+
import { Icon } from '../../styles/Icon'
|
|
6
|
+
import { useNova } from '../../styles/NovaProvider'
|
|
7
|
+
import { fmt } from '../../styles/strings'
|
|
8
|
+
import { inertWhen, useDialog } from './use-dialog'
|
|
9
|
+
import './SearchModal.css'
|
|
10
|
+
|
|
11
|
+
export interface SearchSuggestions {
|
|
12
|
+
products: Product[]
|
|
13
|
+
collections: NovaLink[]
|
|
14
|
+
articles: NovaLink[]
|
|
15
|
+
/** All matches (the results page count). */
|
|
16
|
+
total: number
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface SearchModalProps {
|
|
20
|
+
open: boolean
|
|
21
|
+
onClose: () => void
|
|
22
|
+
/** Called 150ms after typing pauses; the host fetches and passes results back. */
|
|
23
|
+
onQuery?: (query: string) => void
|
|
24
|
+
results?: SearchSuggestions | null
|
|
25
|
+
loading?: boolean
|
|
26
|
+
/** The results page (12G); Enter with no row, and "See all", go there. */
|
|
27
|
+
searchUrl?: string
|
|
28
|
+
/** The Browse menu shown before typing. */
|
|
29
|
+
browse?: readonly NovaLink[]
|
|
30
|
+
/** Merchant-chosen collections for no results. */
|
|
31
|
+
noResultsLinks?: readonly NovaLink[]
|
|
32
|
+
initialQuery?: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const RECENT_KEY = 'nova:recent-searches'
|
|
36
|
+
const RECENT_MAX = 5
|
|
37
|
+
const DEBOUNCE = 150
|
|
38
|
+
|
|
39
|
+
function readRecent(): string[] {
|
|
40
|
+
try {
|
|
41
|
+
return JSON.parse(sessionStorage.getItem(RECENT_KEY) ?? '[]') as string[]
|
|
42
|
+
} catch {
|
|
43
|
+
return []
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function writeRecent(list: string[]) {
|
|
47
|
+
try {
|
|
48
|
+
sessionStorage.setItem(RECENT_KEY, JSON.stringify(list))
|
|
49
|
+
} catch {
|
|
50
|
+
/* storage blocked: recent searches simply don't persist */
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The matched words in bold (rows show why they matched). */
|
|
55
|
+
export function highlight(text: string, query: string): ReactNode {
|
|
56
|
+
const q = query.trim()
|
|
57
|
+
if (!q) return text
|
|
58
|
+
const words = q.split(/\s+/).filter(Boolean).map((w) => w.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
|
|
59
|
+
const parts = text.split(new RegExp(`(${words.join('|')})`, 'gi'))
|
|
60
|
+
return parts.map((p, i) => (i % 2 ? <b key={i}>{p}</b> : <Fragment key={i}>{p}</Fragment>))
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Nova 13 · 4 search — commerce results with images and prices, not a
|
|
65
|
+
* command palette. Desktop: a top dialog 840 wide under the header; phone:
|
|
66
|
+
* full screen. A combobox + grouped listbox: ↑ ↓ move, Enter opens (no row →
|
|
67
|
+
* the results page), Esc clears then closes. Results update after a 150ms
|
|
68
|
+
* pause; previous results stay until new ones arrive. Recent searches are
|
|
69
|
+
* this session only (max 5, removable); popular searches and typo
|
|
70
|
+
* correction need platform data and are not shown.
|
|
71
|
+
*/
|
|
72
|
+
export function SearchModal({ open, onClose, onQuery, results, loading, searchUrl = '/search', browse = [], noResultsLinks = [], initialQuery = '' }: SearchModalProps): JSX.Element {
|
|
73
|
+
const { strings, locale } = useNova()
|
|
74
|
+
const panel = useRef<HTMLDivElement>(null)
|
|
75
|
+
const input = useRef<HTMLInputElement>(null)
|
|
76
|
+
const listId = useId()
|
|
77
|
+
const [query, setQuery] = useState(initialQuery)
|
|
78
|
+
const [active, setActive] = useState(-1)
|
|
79
|
+
const [recent, setRecent] = useState<string[]>([])
|
|
80
|
+
useDialog(open, onClose, panel, input)
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (open) setRecent(readRecent())
|
|
83
|
+
}, [open])
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (!onQuery) return
|
|
86
|
+
const t = window.setTimeout(() => onQuery(query.trim()), DEBOUNCE)
|
|
87
|
+
return () => window.clearTimeout(t)
|
|
88
|
+
}, [query, onQuery])
|
|
89
|
+
|
|
90
|
+
const q = query.trim()
|
|
91
|
+
const rows = useMemo(() => {
|
|
92
|
+
if (!q || !results) return [] as { id: string; href: string; group: 'products' | 'collections' | 'articles' }[]
|
|
93
|
+
return [
|
|
94
|
+
...results.products.slice(0, 6).map((p) => ({ id: `${listId}-p-${p.id}`, href: p.url, group: 'products' as const })),
|
|
95
|
+
...results.collections.slice(0, 4).map((c) => ({ id: `${listId}-c-${c.url}`, href: c.url, group: 'collections' as const })),
|
|
96
|
+
...results.articles.slice(0, 4).map((a) => ({ id: `${listId}-a-${a.url}`, href: a.url, group: 'articles' as const })),
|
|
97
|
+
]
|
|
98
|
+
}, [q, results, listId])
|
|
99
|
+
useEffect(() => setActive(-1), [results, q])
|
|
100
|
+
|
|
101
|
+
const resultsUrl = `${searchUrl}?q=${encodeURIComponent(q)}`
|
|
102
|
+
const remember = (term: string) => {
|
|
103
|
+
const next = [term, ...readRecent().filter((r) => r !== term)].slice(0, RECENT_MAX)
|
|
104
|
+
writeRecent(next)
|
|
105
|
+
setRecent(next)
|
|
106
|
+
}
|
|
107
|
+
const go = (href: string) => {
|
|
108
|
+
if (q) remember(q)
|
|
109
|
+
window.location.assign(href)
|
|
110
|
+
}
|
|
111
|
+
const onKey = (e: KeyboardEvent<HTMLInputElement>) => {
|
|
112
|
+
if (e.key === 'ArrowDown' && rows.length) {
|
|
113
|
+
e.preventDefault()
|
|
114
|
+
setActive((a) => (a + 1) % rows.length)
|
|
115
|
+
} else if (e.key === 'ArrowUp' && rows.length) {
|
|
116
|
+
e.preventDefault()
|
|
117
|
+
setActive((a) => (a <= 0 ? rows.length - 1 : a - 1))
|
|
118
|
+
} else if (e.key === 'Enter' && q) {
|
|
119
|
+
e.preventDefault()
|
|
120
|
+
go(active >= 0 ? rows[active].href : resultsUrl)
|
|
121
|
+
} else if (e.key === 'Escape' && query) {
|
|
122
|
+
// Esc clears first; a second Esc closes (useDialog).
|
|
123
|
+
e.stopPropagation()
|
|
124
|
+
e.nativeEvent.stopImmediatePropagation()
|
|
125
|
+
setQuery('')
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const rowIndex = (id: string) => rows.findIndex((r) => r.id === id)
|
|
129
|
+
const option = (id: string, href: string, body: ReactNode, cls: string) => (
|
|
130
|
+
<a key={id} id={id} role="option" aria-selected={rows[active]?.id === id} href={href} tabIndex={-1} className={cls} onMouseEnter={() => setActive(rowIndex(id))} onClick={() => q && remember(q)}>
|
|
131
|
+
{body}
|
|
132
|
+
</a>
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
let body: ReactNode
|
|
136
|
+
if (!q) {
|
|
137
|
+
body = (
|
|
138
|
+
<div className="nv-search-modal__start">
|
|
139
|
+
{recent.length > 0 && (
|
|
140
|
+
<div className="nv-search-modal__recent">
|
|
141
|
+
<div className="nv-search-modal__label-row">
|
|
142
|
+
<p className="nv-search-modal__label">{strings.recentSearches}</p>
|
|
143
|
+
<button
|
|
144
|
+
type="button"
|
|
145
|
+
className="nv-search-modal__text-btn"
|
|
146
|
+
onClick={() => {
|
|
147
|
+
writeRecent([])
|
|
148
|
+
setRecent([])
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
{strings.clear}
|
|
152
|
+
</button>
|
|
153
|
+
</div>
|
|
154
|
+
<ul className="nv-search-modal__chips">
|
|
155
|
+
{recent.map((r) => (
|
|
156
|
+
<li key={r}>
|
|
157
|
+
<button type="button" className="nv-search-modal__chip" onClick={() => setQuery(r)}>
|
|
158
|
+
<Icon name="clock" size="sm" />
|
|
159
|
+
{r}
|
|
160
|
+
</button>
|
|
161
|
+
<button
|
|
162
|
+
type="button"
|
|
163
|
+
className="nv-search-modal__chip-x"
|
|
164
|
+
aria-label={fmt(strings.removeRecent, { query: r })}
|
|
165
|
+
onClick={() => {
|
|
166
|
+
const next = recent.filter((x) => x !== r)
|
|
167
|
+
writeRecent(next)
|
|
168
|
+
setRecent(next)
|
|
169
|
+
}}
|
|
170
|
+
>
|
|
171
|
+
<Icon name="close" size={12} />
|
|
172
|
+
</button>
|
|
173
|
+
</li>
|
|
174
|
+
))}
|
|
175
|
+
</ul>
|
|
176
|
+
</div>
|
|
177
|
+
)}
|
|
178
|
+
{browse.length > 0 && (
|
|
179
|
+
<nav aria-label={strings.browse}>
|
|
180
|
+
<p className="nv-search-modal__label">{strings.browse}</p>
|
|
181
|
+
<ul className="nv-search-modal__browse">
|
|
182
|
+
{browse.map((l) => (
|
|
183
|
+
<li key={l.url}>
|
|
184
|
+
<a href={l.url}><bdi>{l.title}</bdi></a>
|
|
185
|
+
</li>
|
|
186
|
+
))}
|
|
187
|
+
</ul>
|
|
188
|
+
</nav>
|
|
189
|
+
)}
|
|
190
|
+
</div>
|
|
191
|
+
)
|
|
192
|
+
} else if (!results) {
|
|
193
|
+
body = (
|
|
194
|
+
<ul className="nv-search-modal__skeleton" aria-hidden>
|
|
195
|
+
{[0, 1, 2].map((i) => (
|
|
196
|
+
<li key={i}>
|
|
197
|
+
<span />
|
|
198
|
+
<span />
|
|
199
|
+
</li>
|
|
200
|
+
))}
|
|
201
|
+
</ul>
|
|
202
|
+
)
|
|
203
|
+
} else if (results.total === 0) {
|
|
204
|
+
body = (
|
|
205
|
+
<div className="nv-search-modal__none">
|
|
206
|
+
<p className="nv-search-modal__none-title">{fmt(strings.noResultsFor, { query: q })}</p>
|
|
207
|
+
<p>{strings.spellingTip}</p>
|
|
208
|
+
<RecoveryLinks links={noResultsLinks} label={strings.suggestedLinks} align="left" />
|
|
209
|
+
</div>
|
|
210
|
+
)
|
|
211
|
+
} else {
|
|
212
|
+
const groupLabel = { products: strings.products, collections: strings.collections, articles: strings.articles }
|
|
213
|
+
body = (
|
|
214
|
+
<div id={listId} role="listbox" aria-label={fmt(strings.searchResultsFor, { query: q })} className="nv-search-modal__results" data-stale={loading ? '' : undefined}>
|
|
215
|
+
{results.products.length > 0 && (
|
|
216
|
+
<div role="group" aria-label={groupLabel.products} className="nv-search-modal__group" data-group="products">
|
|
217
|
+
<p className="nv-search-modal__label" aria-hidden>
|
|
218
|
+
{groupLabel.products}
|
|
219
|
+
</p>
|
|
220
|
+
{results.products.slice(0, 6).map((p) => {
|
|
221
|
+
const price = formatMoney(p.priceRange.min, locale)
|
|
222
|
+
const sale = Boolean(p.compareAtPriceRange && p.compareAtPriceRange.min.amount > p.priceRange.min.amount)
|
|
223
|
+
return option(
|
|
224
|
+
`${listId}-p-${p.id}`,
|
|
225
|
+
p.url,
|
|
226
|
+
<>
|
|
227
|
+
<span className="nv-search-modal__thumb">{p.featuredImage && <img src={p.featuredImage.src} alt="" width={p.featuredImage.width} height={p.featuredImage.height} loading="lazy" />}</span>
|
|
228
|
+
<span className="nv-search-modal__title">{highlight(p.title, q)}</span>
|
|
229
|
+
<span className="nv-search-modal__price nv-tabular" data-sale={sale ? '' : undefined}>
|
|
230
|
+
{hasPriceRange(p) ? fmt(strings.priceFrom, { price }) : price}
|
|
231
|
+
</span>
|
|
232
|
+
</>,
|
|
233
|
+
'nv-search-modal__row',
|
|
234
|
+
)
|
|
235
|
+
})}
|
|
236
|
+
</div>
|
|
237
|
+
)}
|
|
238
|
+
{(['collections', 'articles'] as const).map((g) =>
|
|
239
|
+
results[g].length ? (
|
|
240
|
+
<div key={g} role="group" aria-label={groupLabel[g]} className="nv-search-modal__group" data-group={g}>
|
|
241
|
+
<p className="nv-search-modal__label" aria-hidden>
|
|
242
|
+
{groupLabel[g]}
|
|
243
|
+
</p>
|
|
244
|
+
{results[g].slice(0, 4).map((l) => option(`${listId}-${g[0]}-${l.url}`, l.url, <span className="nv-search-modal__title">{highlight(l.title, q)}</span>, 'nv-search-modal__row nv-search-modal__row--text'))}
|
|
245
|
+
</div>
|
|
246
|
+
) : null,
|
|
247
|
+
)}
|
|
248
|
+
</div>
|
|
249
|
+
)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return (
|
|
253
|
+
<div className="nv-overlay nv-search-modal-layer" data-open={open ? '' : undefined} {...inertWhen(!open)} aria-hidden={open ? undefined : true}>
|
|
254
|
+
<div className="nv-overlay__scrim" onClick={onClose} aria-hidden />
|
|
255
|
+
<div ref={panel} className="nv-search-modal" role="dialog" aria-modal="true" aria-label={strings.search} tabIndex={-1}>
|
|
256
|
+
<div className="nv-search-modal__bar">
|
|
257
|
+
<div className="nv-search-modal__field">
|
|
258
|
+
<Icon name="search" size="sm" />
|
|
259
|
+
<input
|
|
260
|
+
ref={input}
|
|
261
|
+
type="search"
|
|
262
|
+
role="combobox"
|
|
263
|
+
aria-expanded={rows.length > 0}
|
|
264
|
+
aria-controls={listId}
|
|
265
|
+
aria-autocomplete="list"
|
|
266
|
+
aria-activedescendant={active >= 0 ? rows[active]?.id : undefined}
|
|
267
|
+
aria-label={strings.search}
|
|
268
|
+
placeholder={strings.searchEverything}
|
|
269
|
+
value={query}
|
|
270
|
+
onChange={(e) => setQuery(e.target.value)}
|
|
271
|
+
onKeyDown={onKey}
|
|
272
|
+
autoComplete="off"
|
|
273
|
+
enterKeyHint="search"
|
|
274
|
+
/>
|
|
275
|
+
{query && (
|
|
276
|
+
<button type="button" className="nv-search-modal__text-btn" onClick={() => { setQuery(''); input.current?.focus() }}>
|
|
277
|
+
{strings.clear}
|
|
278
|
+
</button>
|
|
279
|
+
)}
|
|
280
|
+
</div>
|
|
281
|
+
<button type="button" className="nv-search-modal__cancel" onClick={onClose}>
|
|
282
|
+
{strings.cancel}
|
|
283
|
+
</button>
|
|
284
|
+
</div>
|
|
285
|
+
<p className="nv-visually-hidden" aria-live="polite">
|
|
286
|
+
{q && results && !loading ? fmt(strings.resultsCount, { count: results.total }) : ''}
|
|
287
|
+
</p>
|
|
288
|
+
<div className="nv-search-modal__body">{body}</div>
|
|
289
|
+
{q && results && results.total > 0 && (
|
|
290
|
+
<div className="nv-search-modal__foot">
|
|
291
|
+
<p className="nv-search-modal__keys" aria-hidden>
|
|
292
|
+
{strings.searchKeysHint}
|
|
293
|
+
</p>
|
|
294
|
+
<a href={resultsUrl} onClick={() => remember(q)}>
|
|
295
|
+
{fmt(strings.seeAllResults, { count: results.total })}
|
|
296
|
+
</a>
|
|
297
|
+
</div>
|
|
298
|
+
)}
|
|
299
|
+
</div>
|
|
300
|
+
</div>
|
|
301
|
+
)
|
|
302
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.nv-sheet-layer { z-index: var(--z-modal); }
|
|
2
|
+
.nv-sheet { position: absolute; inset-inline: 0; inset-block-end: 0; display: flex; flex-direction: column; max-height: 90svh; border: var(--overlay-hairline); border-block-end: 0; border-radius: var(--overlay-radius-sheet) var(--overlay-radius-sheet) 0 0; background: var(--color-bg-elevated); color: var(--color-fg); box-shadow: var(--overlay-shadow); transform: translateY(100%); transition: transform var(--duration-base) var(--ease-exit); outline: none; }
|
|
3
|
+
.nv-sheet[data-max='70'] { max-height: 70svh; }
|
|
4
|
+
.nv-overlay[data-open] .nv-sheet { transform: none; transition: transform var(--overlay-slide-in) var(--ease-standard); }
|
|
5
|
+
.nv-sheet__grabber { width: 36px; height: 4px; margin: var(--space-2) auto 0; border-radius: var(--radius-pill); background: var(--color-border); }
|
|
6
|
+
.nv-sheet__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 56px; padding: 0 var(--space-1) 0 var(--space-4); border-block-end: var(--overlay-hairline); }
|
|
7
|
+
.nv-sheet__title:focus { outline: none; }
|
|
8
|
+
.nv-sheet__title { font-size: 1.125rem; font-weight: var(--weight-medium); letter-spacing: 0; }
|
|
9
|
+
.nv-sheet__close { width: 44px; height: 44px; }
|
|
10
|
+
.nv-sheet__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: var(--space-2) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); }
|
|
11
|
+
.nv-sheet__foot { display: flex; flex-direction: column-reverse; gap: var(--space-2); padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom)); border-block-start: var(--overlay-hairline); }
|
|
12
|
+
.nv-sheet__foot > * { width: 100%; }
|
|
13
|
+
@media (prefers-reduced-motion: reduce) {
|
|
14
|
+
.nv-sheet, .nv-overlay[data-open] .nv-sheet { transform: none; opacity: 0; transition: opacity var(--overlay-dialog-in) linear; }
|
|
15
|
+
.nv-overlay[data-open] .nv-sheet { opacity: 1; }
|
|
16
|
+
}
|