@faststore/core 22.42.6
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/.babelrc +4 -0
- package/.editorconfig +13 -0
- package/.eslintignore +8 -0
- package/.eslintrc +21 -0
- package/.github/CODEOWNERS +2 -0
- package/.github/workflows/release.yml +40 -0
- package/.husky/pre-commit +4 -0
- package/.prettierignore +8 -0
- package/.prettierrc +1 -0
- package/.release-it.json +31 -0
- package/.storybook/components/BestPractices.tsx +18 -0
- package/.storybook/components/BestPracticesRule.tsx +43 -0
- package/.storybook/components/Callout.tsx +12 -0
- package/.storybook/components/SectionItem.tsx +44 -0
- package/.storybook/components/SectionList.tsx +27 -0
- package/.storybook/components/TokenDivider.tsx +12 -0
- package/.storybook/components/TokenRow.tsx +32 -0
- package/.storybook/components/TokenTable.tsx +33 -0
- package/.storybook/components/index.ts +8 -0
- package/.storybook/main.js +59 -0
- package/.storybook/manager-head.html +9 -0
- package/.storybook/manager.js +6 -0
- package/.storybook/mocks/cart-sidebar.js +40 -0
- package/.storybook/mocks/filter-slider.js +59 -0
- package/.storybook/mocks/index.ts +5 -0
- package/.storybook/mocks/product.ts +67 -0
- package/.storybook/mocks/productGridItems.ts +334 -0
- package/.storybook/mocks/searchHistory.ts +8 -0
- package/.storybook/mocks/searchTerms.ts +5 -0
- package/.storybook/preview-head.html +1 -0
- package/.storybook/preview.js +89 -0
- package/.storybook/storybook.css +550 -0
- package/.storybook/theme.js +21 -0
- package/.stylelintignore +1 -0
- package/.vscode/settings.json +7 -0
- package/@generated/graphql/index.ts +1133 -0
- package/@generated/graphql/persisted.json +12 -0
- package/CHANGELOG.md +730 -0
- package/LICENSE +21 -0
- package/README.md +437 -0
- package/bun.lockb +0 -0
- package/cms/content-types.json +52 -0
- package/cms/sections.json +350 -0
- package/cms/translation-keys.json +1 -0
- package/cms-webhook-urls.json +5 -0
- package/codegen.yml +22 -0
- package/cypress/fixtures/example.json +5 -0
- package/cypress/global.js +15 -0
- package/cypress/integration/a11y.test.js +45 -0
- package/cypress/integration/analytics.test.js +381 -0
- package/cypress/integration/cart.test.js +100 -0
- package/cypress/integration/performance.test.js +65 -0
- package/cypress/integration/plp.test.js +224 -0
- package/cypress/integration/search.test.js +38 -0
- package/cypress/integration/seo.test.js +318 -0
- package/cypress/plugins/index.js +41 -0
- package/cypress/support/commands.js +70 -0
- package/cypress/support/index.js +3 -0
- package/cypress.json +9 -0
- package/lighthouserc.js +22 -0
- package/next-env.d.ts +5 -0
- package/next.config.js +35 -0
- package/package.json +114 -0
- package/postcss.config.js +5 -0
- package/public/brandless-negative.png +0 -0
- package/public/brandless-neutral.png +0 -0
- package/public/brandless-positive.png +0 -0
- package/public/brandless-storybook.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/icons.svg +58 -0
- package/public/logo.svg +42 -0
- package/public/mockServiceWorker.js +367 -0
- package/public/robots.txt +5 -0
- package/pull_request_template.md +37 -0
- package/renovate.json +5 -0
- package/src/Layout.tsx +51 -0
- package/src/components/ThirdPartyScripts/GoogleTagManager.tsx +61 -0
- package/src/components/ThirdPartyScripts/ThirdPartyScripts.tsx +37 -0
- package/src/components/ThirdPartyScripts/index.ts +1 -0
- package/src/components/ThirdPartyScripts/vtex.tsx +23 -0
- package/src/components/cart/CartItem/CartItem.stories.mdx +134 -0
- package/src/components/cart/CartItem/CartItem.tsx +158 -0
- package/src/components/cart/CartItem/cart-item.module.scss +68 -0
- package/src/components/cart/CartItem/index.ts +1 -0
- package/src/components/cart/CartSidebar/CartSidebar.stories.mdx +119 -0
- package/src/components/cart/CartSidebar/CartSidebar.tsx +140 -0
- package/src/components/cart/CartSidebar/cart-sidebar.module.scss +69 -0
- package/src/components/cart/CartSidebar/index.ts +1 -0
- package/src/components/cart/CartToggle/CartToggle.tsx +20 -0
- package/src/components/cart/CartToggle/index.ts +1 -0
- package/src/components/cart/EmptyCart/EmptyCart.tsx +26 -0
- package/src/components/cart/EmptyCart/index.ts +1 -0
- package/src/components/cart/OrderSummary/OrderSummary.tsx +39 -0
- package/src/components/cart/OrderSummary/index.ts +1 -0
- package/src/components/cart/OrderSummary/order-summary.module.scss +22 -0
- package/src/components/cms/RenderPageSections.tsx +52 -0
- package/src/components/cms/SectionBoundary.tsx +34 -0
- package/src/components/common/Alert/Alert.tsx +53 -0
- package/src/components/common/Alert/index.ts +1 -0
- package/src/components/common/Footer/Footer.stories.mdx +158 -0
- package/src/components/common/Footer/Footer.tsx +160 -0
- package/src/components/common/Footer/FooterLinks.tsx +155 -0
- package/src/components/common/Footer/footer.module.scss +246 -0
- package/src/components/common/Footer/index.ts +2 -0
- package/src/components/common/Navbar/NavLinks.stories.mdx +122 -0
- package/src/components/common/Navbar/NavLinks.tsx +58 -0
- package/src/components/common/Navbar/Navbar.stories.mdx +179 -0
- package/src/components/common/Navbar/Navbar.tsx +97 -0
- package/src/components/common/Navbar/NavbarSlider.stories.mdx +108 -0
- package/src/components/common/Navbar/NavbarSlider.tsx +62 -0
- package/src/components/common/Navbar/index.ts +3 -0
- package/src/components/common/Navbar/navbar-slider.module.scss +60 -0
- package/src/components/common/Navbar/navbar.module.scss +204 -0
- package/src/components/common/Navbar/navlinks.module.scss +96 -0
- package/src/components/common/Toast/Toast.tsx +40 -0
- package/src/components/common/Toast/index.ts +1 -0
- package/src/components/product/OutOfStock/OutOfStock.stories.mdx +127 -0
- package/src/components/product/OutOfStock/OutOfStock.tsx +134 -0
- package/src/components/product/OutOfStock/index.ts +2 -0
- package/src/components/product/OutOfStock/out-of-stock.module.scss +55 -0
- package/src/components/product/ProductCard/ProductCard.stories.mdx +412 -0
- package/src/components/product/ProductCard/ProductCard.tsx +170 -0
- package/src/components/product/ProductCard/index.ts +2 -0
- package/src/components/product/ProductCard/product-card.module.scss +254 -0
- package/src/components/product/ProductGrid/ProductGrid.stories.mdx +97 -0
- package/src/components/product/ProductGrid/ProductGrid.tsx +37 -0
- package/src/components/product/ProductGrid/index.ts +1 -0
- package/src/components/product/ProductGrid/product-grid.module.scss +39 -0
- package/src/components/regionalization/Regionalization.stories.mdx +182 -0
- package/src/components/regionalization/RegionalizationBar/RegionalizationBar.stories.mdx +116 -0
- package/src/components/regionalization/RegionalizationBar/RegionalizationBar.tsx +40 -0
- package/src/components/regionalization/RegionalizationBar/index.ts +1 -0
- package/src/components/regionalization/RegionalizationBar/regionalization-bar.module.scss +56 -0
- package/src/components/regionalization/RegionalizationButton/RegionalizationButton.tsx +24 -0
- package/src/components/regionalization/RegionalizationButton/index.ts +1 -0
- package/src/components/regionalization/RegionalizationInput/RegionalizationInput.tsx +61 -0
- package/src/components/regionalization/RegionalizationInput/index.ts +1 -0
- package/src/components/regionalization/RegionalizationModal/RegionalizationModal.stories.mdx +161 -0
- package/src/components/regionalization/RegionalizationModal/RegionalizationModal.tsx +13 -0
- package/src/components/regionalization/RegionalizationModal/RegionalizationModalContent.tsx +48 -0
- package/src/components/regionalization/RegionalizationModal/index.ts +2 -0
- package/src/components/regionalization/RegionalizationModal/regionalization-modal-content.module.scss +79 -0
- package/src/components/search/Filter/Facets.stories.mdx +284 -0
- package/src/components/search/Filter/Facets.tsx +136 -0
- package/src/components/search/Filter/Filter.stories.mdx +209 -0
- package/src/components/search/Filter/Filter.tsx +91 -0
- package/src/components/search/Filter/FilterSlider.stories.mdx +226 -0
- package/src/components/search/Filter/FilterSlider.tsx +109 -0
- package/src/components/search/Filter/facets.module.scss +117 -0
- package/src/components/search/Filter/filter-slider.module.scss +63 -0
- package/src/components/search/Filter/index.ts +2 -0
- package/src/components/search/Filter/useFilter.ts +131 -0
- package/src/components/search/Search.stories.mdx +169 -0
- package/src/components/search/SearchDropdown/SearchDropdown.stories.mdx +62 -0
- package/src/components/search/SearchDropdown/SearchDropdown.tsx +44 -0
- package/src/components/search/SearchDropdown/index.ts +2 -0
- package/src/components/search/SearchHistory/SearchHistory.stories.mdx +59 -0
- package/src/components/search/SearchHistory/SearchHistory.tsx +51 -0
- package/src/components/search/SearchHistory/index.ts +1 -0
- package/src/components/search/SearchInput/SearchInput.stories.mdx +205 -0
- package/src/components/search/SearchInput/SearchInput.tsx +128 -0
- package/src/components/search/SearchInput/index.ts +2 -0
- package/src/components/search/SearchInput/search-input.module.scss +153 -0
- package/src/components/search/SearchProductCard/SearchProductCard.stories.mdx +96 -0
- package/src/components/search/SearchProductCard/SearchProductCard.tsx +103 -0
- package/src/components/search/SearchProductCard/index.ts +1 -0
- package/src/components/search/SearchProductCard/search-product-card.module.scss +54 -0
- package/src/components/search/SearchSharedTokenTable.mdx +98 -0
- package/src/components/search/SearchSuggestions/SearchSuggestions.stories.mdx +58 -0
- package/src/components/search/SearchSuggestions/SearchSuggestions.tsx +136 -0
- package/src/components/search/SearchSuggestions/index.ts +2 -0
- package/src/components/search/SearchTop/SearchTop.stories.mdx +58 -0
- package/src/components/search/SearchTop/SearchTop.tsx +78 -0
- package/src/components/search/SearchTop/index.ts +2 -0
- package/src/components/search/Sort/Sort.tsx +42 -0
- package/src/components/search/Sort/index.ts +1 -0
- package/src/components/search/search.module.scss +101 -0
- package/src/components/search/searchMock.ts +48 -0
- package/src/components/sections/BannerNewsletter/BannerNewsletter.tsx +28 -0
- package/src/components/sections/BannerNewsletter/banner-newsletter.module.scss +23 -0
- package/src/components/sections/BannerText/BannerText.stories.mdx +270 -0
- package/src/components/sections/BannerText/BannerText.tsx +87 -0
- package/src/components/sections/BannerText/banner-text.module.scss +127 -0
- package/src/components/sections/BannerText/index.ts +2 -0
- package/src/components/sections/Breadcrumb/Breadcrumb.tsx +24 -0
- package/src/components/sections/Breadcrumb/index.ts +1 -0
- package/src/components/sections/Hero/Hero.stories.mdx +277 -0
- package/src/components/sections/Hero/Hero.tsx +109 -0
- package/src/components/sections/Hero/hero.module.scss +180 -0
- package/src/components/sections/Hero/index.ts +2 -0
- package/src/components/sections/Incentives/Incentives.stories.mdx +159 -0
- package/src/components/sections/Incentives/Incentives.tsx +69 -0
- package/src/components/sections/Incentives/IncentivesFooter.tsx +8 -0
- package/src/components/sections/Incentives/IncentivesHeader.tsx +23 -0
- package/src/components/sections/Incentives/incentives.module.scss +122 -0
- package/src/components/sections/Incentives/incentivesMock.ts +55 -0
- package/src/components/sections/Incentives/index.ts +2 -0
- package/src/components/sections/Newsletter/Newsletter.stories.mdx +139 -0
- package/src/components/sections/Newsletter/Newsletter.tsx +151 -0
- package/src/components/sections/Newsletter/index.ts +2 -0
- package/src/components/sections/Newsletter/newsletter.module.scss +135 -0
- package/src/components/sections/ProducDetailsContent/ProductDetailsContent.stories.mdx +66 -0
- package/src/components/sections/ProducDetailsContent/ProductDetailsContent.tsx +278 -0
- package/src/components/sections/ProducDetailsContent/index.ts +1 -0
- package/src/components/sections/ProducDetailsContent/product-details-content.module.scss +50 -0
- package/src/components/sections/ProductDetails/ProductDetails.tsx +316 -0
- package/src/components/sections/ProductDetails/index.ts +1 -0
- package/src/components/sections/ProductDetails/product-details.module.scss +194 -0
- package/src/components/sections/ProductGallery/EmptyGallery.tsx +38 -0
- package/src/components/sections/ProductGallery/ProductGallery.tsx +186 -0
- package/src/components/sections/ProductGallery/ProductGalleryPage.tsx +70 -0
- package/src/components/sections/ProductGallery/index.ts +1 -0
- package/src/components/sections/ProductGallery/product-gallery.module.scss +184 -0
- package/src/components/sections/ProductGallery/useDelayedFacets.ts +18 -0
- package/src/components/sections/ProductGallery/useDelayedPagination.ts +16 -0
- package/src/components/sections/ProductGallery/useGalleryQuery.ts +58 -0
- package/src/components/sections/ProductGallery/usePageProducts.ts +48 -0
- package/src/components/sections/ProductShelf/ProductShelf.tsx +68 -0
- package/src/components/sections/ProductShelf/index.ts +1 -0
- package/src/components/sections/ProductShelf/product-shelf.module.scss +41 -0
- package/src/components/sections/ProductTiles/ProductTiles.tsx +83 -0
- package/src/components/sections/ProductTiles/index.ts +1 -0
- package/src/components/sections/ScrollToTopButton/ScrollToTopButton.tsx +45 -0
- package/src/components/sections/ScrollToTopButton/index.ts +1 -0
- package/src/components/sections/ScrollToTopButton/scroll-to-top-button.module.scss +12 -0
- package/src/components/sections/Section/Section.tsx +15 -0
- package/src/components/sections/Section/index.ts +1 -0
- package/src/components/sections/Section/section.scss +16 -0
- package/src/components/skeletons/FilterSkeleton/FilterSkeleton.stories.mdx +97 -0
- package/src/components/skeletons/FilterSkeleton/FilterSkeleton.tsx +34 -0
- package/src/components/skeletons/FilterSkeleton/filter-skeleton.module.scss +51 -0
- package/src/components/skeletons/FilterSkeleton/index.ts +1 -0
- package/src/components/skeletons/ProductCardSkeleton/ProductCardSkeleton.stories.mdx +176 -0
- package/src/components/skeletons/ProductCardSkeleton/ProductCardSkeleton.tsx +52 -0
- package/src/components/skeletons/ProductCardSkeleton/index.ts +1 -0
- package/src/components/skeletons/ProductCardSkeleton/product-card-skeleton.module.scss +97 -0
- package/src/components/skeletons/ProductGridSkeleton/ProductGridSkeleton.tsx +29 -0
- package/src/components/skeletons/ProductGridSkeleton/index.ts +1 -0
- package/src/components/skeletons/ProductShelfSkeleton/ProductShelfSkeleton.tsx +32 -0
- package/src/components/skeletons/ProductShelfSkeleton/index.ts +1 -0
- package/src/components/skeletons/ProductTilesSkeleton/ProductTileSkeleton/ProductTileSkeleton.tsx +57 -0
- package/src/components/skeletons/ProductTilesSkeleton/ProductTileSkeleton/index.ts +1 -0
- package/src/components/skeletons/ProductTilesSkeleton/ProductTileSkeleton/product-tile-skeleton.module.scss +218 -0
- package/src/components/skeletons/ProductTilesSkeleton/ProductTilesSkeleton.tsx +33 -0
- package/src/components/skeletons/ProductTilesSkeleton/index.ts +2 -0
- package/src/components/skeletons/Shimmer/Shimmer.tsx +11 -0
- package/src/components/skeletons/Shimmer/index.ts +1 -0
- package/src/components/skeletons/Shimmer/shimmer.module.scss +43 -0
- package/src/components/skeletons/Skeleton/Skeleton.tsx +49 -0
- package/src/components/skeletons/Skeleton/index.ts +1 -0
- package/src/components/skeletons/Skeleton/skeleton.module.scss +77 -0
- package/src/components/skeletons/Skeletons.stories.mdx +178 -0
- package/src/components/ui/Accordion/Accordion.stories.mdx +219 -0
- package/src/components/ui/Accordion/Accordion.tsx +39 -0
- package/src/components/ui/Accordion/AccordionItem.stories.mdx +116 -0
- package/src/components/ui/Accordion/AccordionItem.tsx +82 -0
- package/src/components/ui/Accordion/accordion.module.scss +65 -0
- package/src/components/ui/Accordion/index.ts +2 -0
- package/src/components/ui/Alert/Alert.stories.mdx +164 -0
- package/src/components/ui/Alert/Alert.tsx +78 -0
- package/src/components/ui/Alert/alert.module.scss +93 -0
- package/src/components/ui/Alert/index.ts +1 -0
- package/src/components/ui/Badge/Badge.stories.mdx +465 -0
- package/src/components/ui/Badge/Badge.tsx +76 -0
- package/src/components/ui/Badge/DiscountBadge.stories.mdx +191 -0
- package/src/components/ui/Badge/DiscountBadge.tsx +57 -0
- package/src/components/ui/Badge/badge.module.scss +252 -0
- package/src/components/ui/Badge/index.ts +4 -0
- package/src/components/ui/Breadcrumb/Breadcrumb.stories.mdx +197 -0
- package/src/components/ui/Breadcrumb/Breadcrumb.tsx +122 -0
- package/src/components/ui/Breadcrumb/breadcrumb.module.scss +144 -0
- package/src/components/ui/Breadcrumb/index.ts +2 -0
- package/src/components/ui/Button/Button.stories.mdx +685 -0
- package/src/components/ui/Button/Button.tsx +85 -0
- package/src/components/ui/Button/ButtonBuy/ButtonBuy.tsx +24 -0
- package/src/components/ui/Button/ButtonBuy/index.ts +1 -0
- package/src/components/ui/Button/ButtonLink/ButtonLink.tsx +49 -0
- package/src/components/ui/Button/ButtonLink/ButtonSignIn/ButtonSignIn.tsx +22 -0
- package/src/components/ui/Button/ButtonLink/ButtonSignIn/ButtonSignInFallback/ButtonSignInFallback.tsx +18 -0
- package/src/components/ui/Button/ButtonLink/ButtonSignIn/ButtonSignInFallback/index.ts +1 -0
- package/src/components/ui/Button/ButtonLink/ButtonSignIn/index.ts +1 -0
- package/src/components/ui/Button/ButtonLink/index.ts +1 -0
- package/src/components/ui/Button/button.module.scss +392 -0
- package/src/components/ui/Button/index.ts +6 -0
- package/src/components/ui/Checkbox/Checkbox.stories.mdx +268 -0
- package/src/components/ui/Checkbox/Checkbox.tsx +20 -0
- package/src/components/ui/Checkbox/checkbox.module.scss +157 -0
- package/src/components/ui/Checkbox/index.ts +2 -0
- package/src/components/ui/Dropdown/Dropdown.stories.mdx +232 -0
- package/src/components/ui/Dropdown/Dropdown.tsx +12 -0
- package/src/components/ui/Dropdown/DropdownButton.tsx +20 -0
- package/src/components/ui/Dropdown/DropdownItem.stories.mdx +139 -0
- package/src/components/ui/Dropdown/DropdownItem.tsx +26 -0
- package/src/components/ui/Dropdown/DropdownMenu.stories.mdx +115 -0
- package/src/components/ui/Dropdown/DropdownMenu.tsx +34 -0
- package/src/components/ui/Dropdown/dropdown.module.scss +101 -0
- package/src/components/ui/Dropdown/index.ts +4 -0
- package/src/components/ui/EmptyState/EmptyState.stories.mdx +146 -0
- package/src/components/ui/EmptyState/EmptyState.tsx +26 -0
- package/src/components/ui/EmptyState/empty-state.module.scss +63 -0
- package/src/components/ui/EmptyState/index.ts +1 -0
- package/src/components/ui/Gift/Gift.stories.mdx +99 -0
- package/src/components/ui/Gift/Gift.tsx +76 -0
- package/src/components/ui/Gift/gift.module.scss +94 -0
- package/src/components/ui/Gift/index.ts +2 -0
- package/src/components/ui/Icon/Icon.tsx +35 -0
- package/src/components/ui/Icon/index.ts +1 -0
- package/src/components/ui/Image/Image.tsx +59 -0
- package/src/components/ui/Image/index.ts +1 -0
- package/src/components/ui/Image/thumborUrlBuilder.ts +101 -0
- package/src/components/ui/Image/useImage.ts +46 -0
- package/src/components/ui/ImageGallery/ImageGallery.stories.mdx +173 -0
- package/src/components/ui/ImageGallery/ImageGallery.tsx +51 -0
- package/src/components/ui/ImageGallery/ImageGallerySelector.tsx +116 -0
- package/src/components/ui/ImageGallery/ImageZoom.tsx +12 -0
- package/src/components/ui/ImageGallery/image-gallery-selector.module.scss +131 -0
- package/src/components/ui/ImageGallery/image-gallery.module.scss +56 -0
- package/src/components/ui/ImageGallery/index.ts +4 -0
- package/src/components/ui/InputText/InputText.stories.mdx +311 -0
- package/src/components/ui/InputText/InputText.tsx +128 -0
- package/src/components/ui/InputText/index.ts +2 -0
- package/src/components/ui/InputText/input-text.module.scss +168 -0
- package/src/components/ui/Link/Link.stories.mdx +272 -0
- package/src/components/ui/Link/Link.tsx +68 -0
- package/src/components/ui/Link/index.ts +2 -0
- package/src/components/ui/Link/link.module.scss +98 -0
- package/src/components/ui/Logo/Logo.tsx +14 -0
- package/src/components/ui/Logo/index.ts +1 -0
- package/src/components/ui/Logo/logo.module.scss +12 -0
- package/src/components/ui/Modal/Modal.stories.mdx +142 -0
- package/src/components/ui/Modal/Modal.tsx +43 -0
- package/src/components/ui/Modal/index.ts +1 -0
- package/src/components/ui/Modal/modal.module.scss +46 -0
- package/src/components/ui/Price/Price.stories.mdx +194 -0
- package/src/components/ui/Price/Price.tsx +32 -0
- package/src/components/ui/Price/index.ts +1 -0
- package/src/components/ui/Price/price.module.scss +27 -0
- package/src/components/ui/PriceRange/PriceRange.stories.mdx +192 -0
- package/src/components/ui/PriceRange/PriceRange.tsx +138 -0
- package/src/components/ui/PriceRange/index.ts +1 -0
- package/src/components/ui/PriceRange/price-range.module.scss +176 -0
- package/src/components/ui/ProductTitle/ProductTitle.stories.mdx +107 -0
- package/src/components/ui/ProductTitle/ProductTitle.tsx +11 -0
- package/src/components/ui/ProductTitle/index.ts +1 -0
- package/src/components/ui/ProductTitle/product-title.module.scss +48 -0
- package/src/components/ui/QuantitySelector/QuantitySelector.stories.mdx +246 -0
- package/src/components/ui/QuantitySelector/QuantitySelector.tsx +103 -0
- package/src/components/ui/QuantitySelector/index.ts +1 -0
- package/src/components/ui/QuantitySelector/quantity-selector.module.scss +160 -0
- package/src/components/ui/Radio/Radio.stories.mdx +237 -0
- package/src/components/ui/Radio/Radio.tsx +36 -0
- package/src/components/ui/Radio/index.ts +2 -0
- package/src/components/ui/Radio/radio.module.scss +122 -0
- package/src/components/ui/SROnly/SROnly.tsx +20 -0
- package/src/components/ui/SROnly/index.ts +1 -0
- package/src/components/ui/SROnly/sr-only.module.scss +15 -0
- package/src/components/ui/Select/Select.stories.mdx +168 -0
- package/src/components/ui/Select/Select.tsx +70 -0
- package/src/components/ui/Select/index.ts +2 -0
- package/src/components/ui/Select/select.module.scss +85 -0
- package/src/components/ui/ShippingSimulation/ShippingSimulation.stories.mdx +140 -0
- package/src/components/ui/ShippingSimulation/ShippingSimulation.tsx +109 -0
- package/src/components/ui/ShippingSimulation/index.ts +1 -0
- package/src/components/ui/ShippingSimulation/shipping-simulation.module.scss +96 -0
- package/src/components/ui/ShippingSimulation/useShippingSimulation.ts +225 -0
- package/src/components/ui/SkuSelector/Selectors.stories.mdx +82 -0
- package/src/components/ui/SkuSelector/Selectors.tsx +87 -0
- package/src/components/ui/SkuSelector/SkuSelector.stories.mdx +345 -0
- package/src/components/ui/SkuSelector/SkuSelector.tsx +46 -0
- package/src/components/ui/SkuSelector/index.ts +3 -0
- package/src/components/ui/SkuSelector/sku-selector.module.scss +172 -0
- package/src/components/ui/SkuSelector/skuVariants.ts +59 -0
- package/src/components/ui/SlideOver/SlideOver.stories.mdx +285 -0
- package/src/components/ui/SlideOver/SlideOver.tsx +58 -0
- package/src/components/ui/SlideOver/index.ts +1 -0
- package/src/components/ui/SlideOver/overlay.scss +14 -0
- package/src/components/ui/SlideOver/slide-over.module.scss +63 -0
- package/src/components/ui/Tiles/Tiles.stories.mdx +153 -0
- package/src/components/ui/Tiles/Tiles.tsx +14 -0
- package/src/components/ui/Tiles/index.ts +5 -0
- package/src/components/ui/Tiles/tiles.module.scss +60 -0
- package/src/components/ui/Toast/Toast.stories.mdx +158 -0
- package/src/components/ui/Toast/Toast.tsx +56 -0
- package/src/components/ui/Toast/index.ts +1 -0
- package/src/components/ui/Toast/toast.module.scss +112 -0
- package/src/components/ui/Toggle/Toggle.stories.mdx +604 -0
- package/src/components/ui/Toggle/Toggle.tsx +75 -0
- package/src/components/ui/Toggle/index.ts +2 -0
- package/src/components/ui/Toggle/toggle.module.scss +200 -0
- package/src/constants.ts +2 -0
- package/src/fonts/WebFonts.tsx +15 -0
- package/src/images/icon.png +0 -0
- package/src/pages/404.tsx +27 -0
- package/src/pages/500.tsx +31 -0
- package/src/pages/[...slug].tsx +186 -0
- package/src/pages/[slug]/p.tsx +209 -0
- package/src/pages/_app.tsx +38 -0
- package/src/pages/_document.tsx +22 -0
- package/src/pages/account.tsx +20 -0
- package/src/pages/api/graphql.ts +72 -0
- package/src/pages/api/preview.ts +61 -0
- package/src/pages/checkout.tsx +20 -0
- package/src/pages/index.tsx +72 -0
- package/src/pages/login.tsx +20 -0
- package/src/pages/s.tsx +83 -0
- package/src/sdk/analytics/hooks/useViewItemListEvent.ts +51 -0
- package/src/sdk/analytics/index.tsx +30 -0
- package/src/sdk/analytics/platform/vtex/index.ts +11 -0
- package/src/sdk/analytics/platform/vtex/search.ts +102 -0
- package/src/sdk/analytics/types.ts +22 -0
- package/src/sdk/cart/index.ts +187 -0
- package/src/sdk/cart/useBuyButton.ts +62 -0
- package/src/sdk/cart/useCartToggleButton.ts +23 -0
- package/src/sdk/cart/useCheckoutButton.ts +22 -0
- package/src/sdk/cart/useRemoveButton.ts +56 -0
- package/src/sdk/error/ErrorBoundary/ErrorBoundary.tsx +67 -0
- package/src/sdk/error/ErrorBoundary/index.ts +1 -0
- package/src/sdk/graphql/prefetchQuery.ts +20 -0
- package/src/sdk/graphql/request.ts +25 -0
- package/src/sdk/graphql/useLazyQuery.ts +29 -0
- package/src/sdk/graphql/useQuery.ts +40 -0
- package/src/sdk/newsletter/useNewsletter.ts +31 -0
- package/src/sdk/product/useDiscountPercent.ts +10 -0
- package/src/sdk/product/useFormattedPrice.ts +27 -0
- package/src/sdk/product/useProduct.ts +46 -0
- package/src/sdk/product/useProductLink.ts +69 -0
- package/src/sdk/product/useProductsQuery.ts +107 -0
- package/src/sdk/search/Sentinel.tsx +78 -0
- package/src/sdk/search/state.ts +11 -0
- package/src/sdk/search/useSearchHistory.ts +40 -0
- package/src/sdk/search/useSearchInput.tsx +43 -0
- package/src/sdk/search/useSuggestions.ts +49 -0
- package/src/sdk/search/useTopSearch.ts +49 -0
- package/src/sdk/session/index.ts +71 -0
- package/src/sdk/tests/mark.tsx +10 -0
- package/src/sdk/ui/Provider.tsx +151 -0
- package/src/sdk/ui/useFadeEffect.ts +21 -0
- package/src/sdk/ui/useOnClickOutside.ts +39 -0
- package/src/sdk/ui/useScrollDirection.ts +31 -0
- package/src/sdk/useStore.ts +24 -0
- package/src/server/cms.ts +66 -0
- package/src/server/index.ts +105 -0
- package/src/stories/brandless.stories.mdx +85 -0
- package/src/stories/changelog-template.stories.mdx +10 -0
- package/src/stories/colors.stories.mdx +306 -0
- package/src/stories/customizing.stories.mdx +113 -0
- package/src/stories/getting-started.stories.mdx +65 -0
- package/src/stories/grid-layout.stories.mdx +53 -0
- package/src/stories/icons.stories.mdx +237 -0
- package/src/stories/interactive-controls.stories.mdx +50 -0
- package/src/stories/midnight.stories.mdx +56 -0
- package/src/stories/refinements.stories.mdx +96 -0
- package/src/stories/soft-blue.stories.mdx +56 -0
- package/src/stories/spacing.stories.mdx +38 -0
- package/src/stories/typography.stories.mdx +224 -0
- package/src/styles/global/components.scss +5 -0
- package/src/styles/global/layout.scss +80 -0
- package/src/styles/global/resets.scss +48 -0
- package/src/styles/global/storybook-components.scss +5 -0
- package/src/styles/global/tokens.scss +276 -0
- package/src/styles/global/typography.scss +66 -0
- package/src/styles/global/utilities.scss +69 -0
- package/src/styles/scaffold.scss +7 -0
- package/src/styles/themes/custom-theme.scss +36 -0
- package/src/styles/themes/midnight.scss +123 -0
- package/src/styles/themes/soft-blue.scss +79 -0
- package/src/styles/vendors/include-media.scss +4 -0
- package/src/styles/vendors/include-media_overwrite.scss +9 -0
- package/src/styles/vendors/modern-normalize.css +270 -0
- package/src/typings/global.d.ts +6 -0
- package/src/typings/module.css.d.ts +7 -0
- package/store.config.js +69 -0
- package/stylelint.config.js +82 -0
- package/tsconfig.json +25 -0
- package/vtex.env +14 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
lazy,
|
|
4
|
+
Suspense,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
useDeferredValue,
|
|
8
|
+
useImperativeHandle,
|
|
9
|
+
} from 'react'
|
|
10
|
+
import type { CSSProperties } from 'react'
|
|
11
|
+
import { useRouter } from 'next/router'
|
|
12
|
+
import { sendAnalyticsEvent } from '@faststore/sdk'
|
|
13
|
+
import type { SearchEvent } from '@faststore/sdk'
|
|
14
|
+
import { SearchInput as UISearchInput } from '@faststore/ui'
|
|
15
|
+
import type {
|
|
16
|
+
SearchInputProps as UISearchInputProps,
|
|
17
|
+
SearchInputRef as UISearchInputRef,
|
|
18
|
+
} from '@faststore/ui'
|
|
19
|
+
|
|
20
|
+
import Icon from 'src/components/ui/Icon'
|
|
21
|
+
import useSearchHistory from 'src/sdk/search/useSearchHistory'
|
|
22
|
+
import {
|
|
23
|
+
formatSearchPath,
|
|
24
|
+
SearchInputProvider,
|
|
25
|
+
} from 'src/sdk/search/useSearchInput'
|
|
26
|
+
import type { SearchInputContextValue } from 'src/sdk/search/useSearchInput'
|
|
27
|
+
import useOnClickOutside from 'src/sdk/ui/useOnClickOutside'
|
|
28
|
+
|
|
29
|
+
import styles from './search-input.module.scss'
|
|
30
|
+
|
|
31
|
+
const SearchDropdown = lazy(
|
|
32
|
+
() => import('src/components/search/SearchDropdown')
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
export type SearchInputProps = {
|
|
36
|
+
onSearchClick?: () => void
|
|
37
|
+
buttonTestId?: string
|
|
38
|
+
containerStyle?: CSSProperties
|
|
39
|
+
} & Omit<UISearchInputProps, 'onSubmit'>
|
|
40
|
+
|
|
41
|
+
export type SearchInputRef = UISearchInputRef & { resetSearchInput: () => void }
|
|
42
|
+
|
|
43
|
+
const sendAnalytics = async (term: string) => {
|
|
44
|
+
sendAnalyticsEvent<SearchEvent>({
|
|
45
|
+
name: 'search',
|
|
46
|
+
params: { search_term: term },
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const SearchInput = forwardRef<SearchInputRef, SearchInputProps>(
|
|
51
|
+
function SearchInput(
|
|
52
|
+
{
|
|
53
|
+
onSearchClick,
|
|
54
|
+
buttonTestId = 'store-search-button',
|
|
55
|
+
containerStyle,
|
|
56
|
+
...otherProps
|
|
57
|
+
},
|
|
58
|
+
ref
|
|
59
|
+
) {
|
|
60
|
+
const [searchQuery, setSearchQuery] = useState<string>('')
|
|
61
|
+
const searchQueryDeferred = useDeferredValue(searchQuery)
|
|
62
|
+
const [searchDropdownVisible, setSearchDropdownVisible] =
|
|
63
|
+
useState<boolean>(false)
|
|
64
|
+
|
|
65
|
+
const searchRef = useRef<HTMLDivElement>(null)
|
|
66
|
+
const { addToSearchHistory } = useSearchHistory()
|
|
67
|
+
const router = useRouter()
|
|
68
|
+
|
|
69
|
+
useImperativeHandle(ref, () => ({
|
|
70
|
+
resetSearchInput: () => setSearchQuery(''),
|
|
71
|
+
}))
|
|
72
|
+
|
|
73
|
+
const onSearchInputSelection: SearchInputContextValue['onSearchInputSelection'] =
|
|
74
|
+
(term, path) => {
|
|
75
|
+
addToSearchHistory({ term, path })
|
|
76
|
+
sendAnalytics(term)
|
|
77
|
+
setSearchDropdownVisible(false)
|
|
78
|
+
setSearchQuery(term)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
useOnClickOutside(searchRef, () => setSearchDropdownVisible(false))
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<div
|
|
85
|
+
ref={searchRef}
|
|
86
|
+
data-fs-search-input-wrapper
|
|
87
|
+
className={styles.fsSearchInput}
|
|
88
|
+
data-fs-search-input-dropdown-visible={searchDropdownVisible}
|
|
89
|
+
style={containerStyle}
|
|
90
|
+
>
|
|
91
|
+
<SearchInputProvider onSearchInputSelection={onSearchInputSelection}>
|
|
92
|
+
<UISearchInput
|
|
93
|
+
data-fs-search-input
|
|
94
|
+
ref={ref}
|
|
95
|
+
icon={
|
|
96
|
+
<Icon
|
|
97
|
+
name="MagnifyingGlass"
|
|
98
|
+
onClick={onSearchClick}
|
|
99
|
+
data-testid={buttonTestId}
|
|
100
|
+
/>
|
|
101
|
+
}
|
|
102
|
+
placeholder="Search everything at the store"
|
|
103
|
+
onChange={(e) => setSearchQuery(e.target.value)}
|
|
104
|
+
onSubmit={(term) => {
|
|
105
|
+
const path = formatSearchPath(term)
|
|
106
|
+
|
|
107
|
+
onSearchInputSelection(term, path)
|
|
108
|
+
router.push(path)
|
|
109
|
+
}}
|
|
110
|
+
onFocus={() => setSearchDropdownVisible(true)}
|
|
111
|
+
value={searchQuery}
|
|
112
|
+
{...otherProps}
|
|
113
|
+
/>
|
|
114
|
+
|
|
115
|
+
{searchDropdownVisible && (
|
|
116
|
+
<Suspense fallback={null}>
|
|
117
|
+
<div data-fs-search-input-dropdown-wrapper>
|
|
118
|
+
<SearchDropdown term={searchQueryDeferred} />
|
|
119
|
+
</div>
|
|
120
|
+
</Suspense>
|
|
121
|
+
)}
|
|
122
|
+
</SearchInputProvider>
|
|
123
|
+
</div>
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
export default SearchInput
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
@import "src/styles/scaffold";
|
|
2
|
+
|
|
3
|
+
.fs-search-input {
|
|
4
|
+
// --------------------------------------------------------
|
|
5
|
+
// Design Tokens for Search Input
|
|
6
|
+
// --------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
// Default properties
|
|
9
|
+
--fs-search-input-padding : var(--fs-spacing-1) var(--fs-spacing-7) var(--fs-spacing-1) var(--fs-spacing-2);
|
|
10
|
+
--fs-search-input-bkg-color : var(--fs-color-body-bkg);
|
|
11
|
+
--fs-search-input-box-shadow : 0 0 0 var(--fs-border-width) var(--fs-border-color-active);
|
|
12
|
+
|
|
13
|
+
--fs-search-input-height-mobile : var(--fs-control-tap-size);
|
|
14
|
+
--fs-search-input-height-desktop : var(--fs-spacing-6);
|
|
15
|
+
|
|
16
|
+
--fs-search-input-border-width : var(--fs-border-width);
|
|
17
|
+
--fs-search-input-border-radius : var(--fs-border-radius);
|
|
18
|
+
--fs-search-input-border-color : var(--fs-border-color);
|
|
19
|
+
--fs-search-input-border-color-hover : var(--fs-border-color-active);
|
|
20
|
+
|
|
21
|
+
--fs-search-input-transition-timing : var(--fs-transition-timing);
|
|
22
|
+
--fs-search-input-transition-function : ease;
|
|
23
|
+
|
|
24
|
+
// Button
|
|
25
|
+
--fs-search-input-button-width : var(--fs-spacing-7);
|
|
26
|
+
--fs-search-input-button-min-height : var(--fs-search-input-height-desktop);
|
|
27
|
+
--fs-search-input-button-bkg-color : transparent;
|
|
28
|
+
|
|
29
|
+
--fs-search-input-button-height-mobile : var(--fs-search-input-button-width);
|
|
30
|
+
--fs-search-input-button-height-desktop : var(--fs-search-input-height-desktop);
|
|
31
|
+
|
|
32
|
+
// Icon
|
|
33
|
+
--fs-search-input-icon-width : var(--fs-spacing-4);
|
|
34
|
+
--fs-search-input-icon-height : var(--fs-search-input-icon-width);
|
|
35
|
+
--fs-search-input-icon-color : var(--fs-color-neutral-7);
|
|
36
|
+
|
|
37
|
+
// Dropdown
|
|
38
|
+
--fs-search-input-dropdown-padding : var(--fs-spacing-3);
|
|
39
|
+
--fs-search-input-dropdown-bkg-color : var(--fs-color-neutral-0);
|
|
40
|
+
--fs-search-input-dropdown-box-shadow : var(--fs-shadow);
|
|
41
|
+
|
|
42
|
+
--fs-search-input-dropdown-width-mobile : 100vw;
|
|
43
|
+
--fs-search-input-dropdown-width-desktop : 100%;
|
|
44
|
+
|
|
45
|
+
--fs-search-input-dropdown-border-width : var(--fs-border-width);
|
|
46
|
+
--fs-search-input-dropdown-border-color : var(--fs-border-color);
|
|
47
|
+
--fs-search-input-dropdown-border-radius : 0 0 var(--fs-border-radius) var(--fs-border-radius);
|
|
48
|
+
|
|
49
|
+
--fs-search-input-dropdown-position-left-mobile : calc(-1 * var(--fs-control-tap-size));
|
|
50
|
+
--fs-search-input-dropdown-position-left-tablet : calc(var(--fs-search-input-dropdown-position-left-mobile) - var(--fs-spacing-1));
|
|
51
|
+
--fs-search-input-dropdown-position-top-tablet : calc(var(--fs-control-tap-size) + var(--fs-spacing-2) + var(--fs-border-width));
|
|
52
|
+
--fs-search-input-dropdown-position-top-mobile : calc(var(--fs-search-input-dropdown-position-top-tablet) + 1px);
|
|
53
|
+
--fs-search-input-dropdown-position-top-desktop : var(--fs-search-input-height-desktop);
|
|
54
|
+
|
|
55
|
+
// --------------------------------------------------------
|
|
56
|
+
// Structural Styles
|
|
57
|
+
// --------------------------------------------------------
|
|
58
|
+
|
|
59
|
+
position: relative;
|
|
60
|
+
|
|
61
|
+
[data-fs-search-input-form] {
|
|
62
|
+
position: relative;
|
|
63
|
+
display: inline-flex;
|
|
64
|
+
width: 100%;
|
|
65
|
+
height: var(--fs-search-input-height-mobile);
|
|
66
|
+
|
|
67
|
+
@include media(">=notebook") { height: var(--fs-search-input-height-desktop); }
|
|
68
|
+
|
|
69
|
+
[data-fs-search-input] {
|
|
70
|
+
width: 100%;
|
|
71
|
+
padding: var(--fs-search-input-padding);
|
|
72
|
+
background-color: var(--fs-search-input-bkg-color);
|
|
73
|
+
border: var(--fs-search-input-border-width) solid var(--fs-search-input-border-color);
|
|
74
|
+
border-radius: var(--fs-search-input-border-radius);
|
|
75
|
+
transition: box-shadow var(--fs-search-input-transition-timing) var(--fs-search-input-transition-timing), border var(--fs-search-input-transition-timing) var(--fs-search-input-transition-function);
|
|
76
|
+
|
|
77
|
+
&:hover {
|
|
78
|
+
border-color: var(--fs-search-input-border-color-hover);
|
|
79
|
+
box-shadow: var(--fs-search-input-box-shadow);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@include input-focus-ring;
|
|
83
|
+
|
|
84
|
+
[data-fs-search-input-dropdown-visible="true"] & {
|
|
85
|
+
@include media(">=notebook") {
|
|
86
|
+
border-bottom-right-radius: 0;
|
|
87
|
+
border-bottom-left-radius: 0;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
[data-fs-button] {
|
|
93
|
+
position: absolute;
|
|
94
|
+
right: var(--fs-spacing-0);
|
|
95
|
+
width: var(--fs-search-input-button-width);
|
|
96
|
+
height: var(--fs-search-input-button-height-mobile);
|
|
97
|
+
padding: 0;
|
|
98
|
+
background-color: var(--fs-search-input-button-bkg-color);
|
|
99
|
+
border: 0;
|
|
100
|
+
|
|
101
|
+
@include media(">=notebook") {
|
|
102
|
+
height: var(--fs-search-input-button-height-desktop);
|
|
103
|
+
min-height: var(--fs-search-input-button-min-height);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
[data-fs-icon] { display: block; }
|
|
108
|
+
|
|
109
|
+
[data-fs-button] svg {
|
|
110
|
+
width: var(--fs-search-input-icon-width);
|
|
111
|
+
height: var(--fs-search-input-icon-height);
|
|
112
|
+
color: var(--fs-search-input-icon-color);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
[data-fs-search-product-card-link] {
|
|
117
|
+
color: var(--fs-color-neutral-7);
|
|
118
|
+
text-decoration: none;
|
|
119
|
+
|
|
120
|
+
&:hover { text-decoration: none; }
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
[data-fs-search-input-dropdown-wrapper] {
|
|
124
|
+
position: absolute;
|
|
125
|
+
top: var(--fs-search-input-dropdown-position-top-mobile);
|
|
126
|
+
left: var(--fs-search-input-dropdown-position-left-mobile);
|
|
127
|
+
z-index: 1;
|
|
128
|
+
width: var(--fs-search-input-dropdown-width-mobile);
|
|
129
|
+
padding: var(--fs-search-input-dropdown-padding);
|
|
130
|
+
padding-top: 0;
|
|
131
|
+
background-color: var(--fs-search-input-dropdown-bkg-color);
|
|
132
|
+
|
|
133
|
+
&:empty { display: none; }
|
|
134
|
+
|
|
135
|
+
@include media(">=tablet") {
|
|
136
|
+
top: var(--fs-search-input-dropdown-position-top-tablet);
|
|
137
|
+
left: var(--fs-search-input-dropdown-position-left-tablet);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@include media(">=notebook") {
|
|
141
|
+
top: var(--fs-search-input-dropdown-position-top-desktop);
|
|
142
|
+
left: 0;
|
|
143
|
+
width: var(--fs-search-input-dropdown-width-desktop);
|
|
144
|
+
overflow: hidden;
|
|
145
|
+
border: var(--fs-search-input-dropdown-border-width) solid var(--fs-search-input-dropdown-border-color);
|
|
146
|
+
border-top: none;
|
|
147
|
+
border-radius: var(--fs-search-input-dropdown-border-radius);
|
|
148
|
+
box-shadow: var(--fs-search-input-dropdown-box-shadow);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
[data-fs-search-input-loading-text] { padding-top: var(--fs-spacing-3); }
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs'
|
|
2
|
+
import { SearchInputProvider } from 'src/sdk/search/useSearchInput'
|
|
3
|
+
import storeConfig from 'store.config'
|
|
4
|
+
import {
|
|
5
|
+
TokenTable,
|
|
6
|
+
TokenRow,
|
|
7
|
+
TokenDivider,
|
|
8
|
+
} from 'src/../.storybook/components'
|
|
9
|
+
import { product } from 'src/../.storybook/mocks'
|
|
10
|
+
|
|
11
|
+
import SearchProductCard from '.'
|
|
12
|
+
|
|
13
|
+
<Meta
|
|
14
|
+
title="Features/Search/SearchProductCard"
|
|
15
|
+
component={SearchProductCard}
|
|
16
|
+
args={{
|
|
17
|
+
product,
|
|
18
|
+
index: 1
|
|
19
|
+
}}
|
|
20
|
+
/>
|
|
21
|
+
|
|
22
|
+
export const Template = (args) => (
|
|
23
|
+
<SearchInputProvider>
|
|
24
|
+
<SuggestionProductCard {...args} />
|
|
25
|
+
</SearchInputProvider>
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
<header>
|
|
29
|
+
|
|
30
|
+
# Search Product Card
|
|
31
|
+
|
|
32
|
+
Card to show details of the product and suggest in `SearchDropdown`.
|
|
33
|
+
|
|
34
|
+
</header>
|
|
35
|
+
|
|
36
|
+
## Overview
|
|
37
|
+
|
|
38
|
+
The `SearchProductCard` differs from `ProductCard` because it is used in the `Search` feature and is called by the `SearchSuggestions` component.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
`import SearchProductCard from 'src/components/search/SearchProductCard'`
|
|
45
|
+
|
|
46
|
+
<Canvas>
|
|
47
|
+
<Story name="SearchProductCard">{Template.bind({})}</Story>
|
|
48
|
+
</Canvas>
|
|
49
|
+
|
|
50
|
+
<ArgsTable story="SearchProductCard" />
|
|
51
|
+
|
|
52
|
+
## Nested Elements
|
|
53
|
+
|
|
54
|
+
### Link
|
|
55
|
+
|
|
56
|
+
<TokenTable>
|
|
57
|
+
<TokenRow
|
|
58
|
+
token="--fs-suggestion-product-card-link-padding"
|
|
59
|
+
value="var(--fs-spacing-1) var(--fs-spacing-3)"
|
|
60
|
+
/>
|
|
61
|
+
</TokenTable>
|
|
62
|
+
|
|
63
|
+
### Image
|
|
64
|
+
|
|
65
|
+
<TokenTable>
|
|
66
|
+
<TokenRow
|
|
67
|
+
token="--fs-suggestion-product-card-image-border-radius"
|
|
68
|
+
value="var(--fs-border-radius)"
|
|
69
|
+
/>
|
|
70
|
+
<TokenRow
|
|
71
|
+
token="--fs-suggestion-product-card-image-margin-right"
|
|
72
|
+
value="var(--fs-spacing-3)"
|
|
73
|
+
/>
|
|
74
|
+
<TokenRow
|
|
75
|
+
token="--fs-suggestion-product-card-image-height"
|
|
76
|
+
value="3.5rem"
|
|
77
|
+
/>
|
|
78
|
+
</TokenTable>
|
|
79
|
+
|
|
80
|
+
### Title
|
|
81
|
+
|
|
82
|
+
<TokenTable>
|
|
83
|
+
<TokenRow
|
|
84
|
+
token="--fs-suggestion-product-card-title-margin-bottom"
|
|
85
|
+
value="var(--fs-spacing-0)"
|
|
86
|
+
/>
|
|
87
|
+
<TokenRow
|
|
88
|
+
token="--fs-suggestion-product-card-title-line-height"
|
|
89
|
+
value="1.2"
|
|
90
|
+
/>
|
|
91
|
+
<TokenRow
|
|
92
|
+
token="--fs-suggestion-product-card-title-color"
|
|
93
|
+
value="var(--fs-color-text)"
|
|
94
|
+
isColor
|
|
95
|
+
/>
|
|
96
|
+
</TokenTable>
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Card, CardContent, CardImage } from '@faststore/ui'
|
|
2
|
+
|
|
3
|
+
import { Image } from 'src/components/ui/Image'
|
|
4
|
+
import Link from 'src/components/ui/Link'
|
|
5
|
+
import Price from 'src/components/ui/Price'
|
|
6
|
+
import { useFormattedPrice } from 'src/sdk/product/useFormattedPrice'
|
|
7
|
+
import { useProductLink } from 'src/sdk/product/useProductLink'
|
|
8
|
+
import useSearchInput from 'src/sdk/search/useSearchInput'
|
|
9
|
+
import type { ProductSummary_ProductFragment } from '@generated/graphql'
|
|
10
|
+
|
|
11
|
+
import styles from './search-product-card.module.scss'
|
|
12
|
+
|
|
13
|
+
type SearchProductCardProps = {
|
|
14
|
+
/**
|
|
15
|
+
* Product to be showed in `SearchProductCard`.
|
|
16
|
+
*/
|
|
17
|
+
product: ProductSummary_ProductFragment
|
|
18
|
+
/**
|
|
19
|
+
* Index to generate product link.
|
|
20
|
+
*/
|
|
21
|
+
index: number
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function SearchProductCard({
|
|
25
|
+
product,
|
|
26
|
+
index,
|
|
27
|
+
...otherProps
|
|
28
|
+
}: SearchProductCardProps) {
|
|
29
|
+
const { onSearchInputSelection } = useSearchInput()
|
|
30
|
+
const { onClick, href, ...linkProps } = useProductLink({
|
|
31
|
+
product,
|
|
32
|
+
selectedOffer: 0,
|
|
33
|
+
index,
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const {
|
|
37
|
+
isVariantOf: { name },
|
|
38
|
+
image: [img],
|
|
39
|
+
offers: {
|
|
40
|
+
lowPrice: spotPrice,
|
|
41
|
+
offers: [{ listPrice }],
|
|
42
|
+
},
|
|
43
|
+
} = product
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Card
|
|
47
|
+
data-fs-search-product-card
|
|
48
|
+
className={styles.fsSearchProductCard}
|
|
49
|
+
data-testid="search-product-card"
|
|
50
|
+
{...otherProps}
|
|
51
|
+
>
|
|
52
|
+
<Link
|
|
53
|
+
{...linkProps}
|
|
54
|
+
data-fs-search-product-card-link
|
|
55
|
+
href={href}
|
|
56
|
+
title={name}
|
|
57
|
+
variant="display"
|
|
58
|
+
onClick={() => {
|
|
59
|
+
onClick()
|
|
60
|
+
onSearchInputSelection?.(name, href)
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
<CardContent data-fs-search-product-card-content>
|
|
64
|
+
<CardImage data-fs-search-product-card-image>
|
|
65
|
+
<Image
|
|
66
|
+
src={img.url}
|
|
67
|
+
alt={img.alternateName}
|
|
68
|
+
width={56}
|
|
69
|
+
height={56}
|
|
70
|
+
/>
|
|
71
|
+
</CardImage>
|
|
72
|
+
<div data-fs-search-product-card-summary>
|
|
73
|
+
<p className="text__title-mini" data-fs-search-product-card-title>
|
|
74
|
+
{name}
|
|
75
|
+
</p>
|
|
76
|
+
<span data-fs-search-product-card-prices>
|
|
77
|
+
<Price
|
|
78
|
+
value={listPrice}
|
|
79
|
+
formatter={useFormattedPrice}
|
|
80
|
+
testId="list-price"
|
|
81
|
+
data-value={listPrice}
|
|
82
|
+
variant="listing"
|
|
83
|
+
classes="text__legend"
|
|
84
|
+
SRText="Original price:"
|
|
85
|
+
/>
|
|
86
|
+
<Price
|
|
87
|
+
value={spotPrice}
|
|
88
|
+
formatter={useFormattedPrice}
|
|
89
|
+
testId="price"
|
|
90
|
+
data-value={spotPrice}
|
|
91
|
+
variant="spot"
|
|
92
|
+
classes="text__title-mini"
|
|
93
|
+
SRText="Price:"
|
|
94
|
+
/>
|
|
95
|
+
</span>
|
|
96
|
+
</div>
|
|
97
|
+
</CardContent>
|
|
98
|
+
</Link>
|
|
99
|
+
</Card>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export default SearchProductCard
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './SearchProductCard'
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
@import "src/styles/scaffold";
|
|
2
|
+
|
|
3
|
+
.fs-search-product-card {
|
|
4
|
+
// --------------------------------------------------------
|
|
5
|
+
// Design Tokens for Search Product Card
|
|
6
|
+
// --------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
// Search Product Card Link
|
|
9
|
+
--fs-search-product-card-link-padding : var(--fs-spacing-1) var(--fs-spacing-3);
|
|
10
|
+
|
|
11
|
+
// Search Product Card Image
|
|
12
|
+
--fs-search-product-card-image-border-radius : var(--fs-border-radius);
|
|
13
|
+
--fs-search-product-card-image-margin-right : var(--fs-spacing-3);
|
|
14
|
+
--fs-search-product-card-image-size : 3.5rem;
|
|
15
|
+
|
|
16
|
+
// Search Product Card Title
|
|
17
|
+
--fs-search-product-card-title-margin-bottom : var(--fs-spacing-0);
|
|
18
|
+
--fs-search-product-card-title-line-height : 1.2;
|
|
19
|
+
--fs-search-product-card-title-color : var(--fs-color-text);
|
|
20
|
+
|
|
21
|
+
[data-fs-search-product-card-image] {
|
|
22
|
+
display: flex;
|
|
23
|
+
width: var(--fs-search-product-card-image-size);
|
|
24
|
+
height: var(--fs-search-product-card-image-size);
|
|
25
|
+
margin-right: var(--fs-search-product-card-image-margin-right);
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
border-radius: var(--fs-search-product-card-image-border-radius);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
[data-fs-search-product-card-content] {
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
[data-fs-search-product-card-title] {
|
|
36
|
+
margin-bottom: var(--fs-search-product-card-title-margin-bottom);
|
|
37
|
+
line-height: var(--fs-search-product-card-title-line-height);
|
|
38
|
+
color: var(--fs-search-product-card-title-color);
|
|
39
|
+
text-decoration: none;
|
|
40
|
+
outline: none;
|
|
41
|
+
|
|
42
|
+
@include truncate-title;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[data-fs-search-product-card-prices] {
|
|
46
|
+
display: flex;
|
|
47
|
+
align-items: baseline;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
[data-fs-search-product-card-link] {
|
|
51
|
+
padding: var(--fs-search-product-card-link-padding);
|
|
52
|
+
text-decoration: none;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TokenTable,
|
|
3
|
+
TokenRow,
|
|
4
|
+
TokenDivider,
|
|
5
|
+
} from 'src/../.storybook/components'
|
|
6
|
+
|
|
7
|
+
*These tokens are shared between
|
|
8
|
+
[SearchDropdown](?path=/docs/features-search-searchdropdown--default-story),
|
|
9
|
+
[SearchHistory](?path=/docs/features-search-searchhistory--default-story),
|
|
10
|
+
[SearchInput](?path=/docs/features-search-searchinput--default-story),
|
|
11
|
+
[SearchSuggestions](?path=/docs/features-search-searchsuggestions--default-story),
|
|
12
|
+
[SearchTop](?path=/docs/features-search-searchtop--default-story).
|
|
13
|
+
|
|
14
|
+
<TokenTable>
|
|
15
|
+
<TokenRow
|
|
16
|
+
token="--fs-search-min-height"
|
|
17
|
+
value="var(--fs-spacing-7)"
|
|
18
|
+
/>
|
|
19
|
+
</TokenTable>
|
|
20
|
+
|
|
21
|
+
### Title
|
|
22
|
+
<TokenTable>
|
|
23
|
+
<TokenRow
|
|
24
|
+
token="--fs-search-title-size"
|
|
25
|
+
value="var(--fs-text-size-lead)"
|
|
26
|
+
/>
|
|
27
|
+
<TokenRow
|
|
28
|
+
token="--fs-search-title-line-height"
|
|
29
|
+
value="1.5"
|
|
30
|
+
/>
|
|
31
|
+
</TokenTable>
|
|
32
|
+
|
|
33
|
+
### Section
|
|
34
|
+
<TokenTable>
|
|
35
|
+
<TokenRow
|
|
36
|
+
token="--fs-search-section-padding"
|
|
37
|
+
value="var(--fs-spacing-1) 0"
|
|
38
|
+
/>
|
|
39
|
+
<TokenRow
|
|
40
|
+
token="--fs-search-section-border-bottom"
|
|
41
|
+
value="var(--fs-border-width) solid var(--fs-border-color-light)"
|
|
42
|
+
/>
|
|
43
|
+
</TokenTable>
|
|
44
|
+
|
|
45
|
+
### Link
|
|
46
|
+
<TokenTable>
|
|
47
|
+
<TokenRow
|
|
48
|
+
token="--fs-search-item-link-color "
|
|
49
|
+
value="var(--fs-color-text-light)"
|
|
50
|
+
isColor
|
|
51
|
+
/>
|
|
52
|
+
<TokenRow
|
|
53
|
+
token="--fs-search-item-link-padding-right"
|
|
54
|
+
value="var(--fs-spacing-3)"
|
|
55
|
+
/>
|
|
56
|
+
<TokenRow
|
|
57
|
+
token="--fs-search-item-link-padding-left"
|
|
58
|
+
value="var(--fs-search-item-link-padding-right)"
|
|
59
|
+
/>
|
|
60
|
+
</TokenTable>
|
|
61
|
+
|
|
62
|
+
### Item
|
|
63
|
+
<TokenTable>
|
|
64
|
+
<TokenRow
|
|
65
|
+
token="--fs-search-item-text-size"
|
|
66
|
+
value="var(--fs-text-size-2)"
|
|
67
|
+
/>
|
|
68
|
+
<TokenRow
|
|
69
|
+
token="--fs-search-item-line-height"
|
|
70
|
+
value="1.25"
|
|
71
|
+
/>
|
|
72
|
+
<TokenRow
|
|
73
|
+
token="--fs-search-item-bkg-color-hover"
|
|
74
|
+
value="var(--fs-color-tertiary-bkg-hover)"
|
|
75
|
+
isColor
|
|
76
|
+
/>
|
|
77
|
+
</TokenTable>
|
|
78
|
+
|
|
79
|
+
### Icon
|
|
80
|
+
<TokenTable>
|
|
81
|
+
<TokenRow
|
|
82
|
+
token="--fs-search-item-icon-color"
|
|
83
|
+
value="var(--fs-color-neutral-4)"
|
|
84
|
+
isColor
|
|
85
|
+
/>
|
|
86
|
+
<TokenRow
|
|
87
|
+
token="--fs-search-item-icon-margin-right"
|
|
88
|
+
value="var(--fs-spacing-1)"
|
|
89
|
+
/>
|
|
90
|
+
</TokenTable>
|
|
91
|
+
|
|
92
|
+
### Badge
|
|
93
|
+
<TokenTable>
|
|
94
|
+
<TokenRow
|
|
95
|
+
token="--fs-search-badge-margin-right"
|
|
96
|
+
value="var(--fs-spacing-1)"
|
|
97
|
+
/>
|
|
98
|
+
</TokenTable>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Meta, Canvas, Story, ArgsTable } from '@storybook/addon-docs'
|
|
2
|
+
import {
|
|
3
|
+
TokenTable,
|
|
4
|
+
TokenRow,
|
|
5
|
+
TokenDivider,
|
|
6
|
+
} from 'src/../.storybook/components'
|
|
7
|
+
import { SearchInputProvider } from 'src/sdk/search/useSearchInput'
|
|
8
|
+
import { productGridItems, searchTerms } from 'src/../.storybook/mocks'
|
|
9
|
+
import { products } from '../searchMock'
|
|
10
|
+
|
|
11
|
+
import SearchSuggestions from '.'
|
|
12
|
+
|
|
13
|
+
<Meta component={SearchSuggestions} title="Features/Search/SearchSuggestions" />
|
|
14
|
+
|
|
15
|
+
export const Template = (args) => (
|
|
16
|
+
<div
|
|
17
|
+
style={{
|
|
18
|
+
maxWidth: '600px',
|
|
19
|
+
margin: '0 auto',
|
|
20
|
+
padding: '0 16px',
|
|
21
|
+
background: 'white',
|
|
22
|
+
}}
|
|
23
|
+
>
|
|
24
|
+
<SearchInputProvider>
|
|
25
|
+
<SearchSuggestions {...args} />
|
|
26
|
+
</SearchInputProvider>
|
|
27
|
+
</div>
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
<header>
|
|
31
|
+
|
|
32
|
+
# SearchSuggestions
|
|
33
|
+
|
|
34
|
+
Displays a set of navigation links that self-adapts on mobile or desktop screens.
|
|
35
|
+
|
|
36
|
+
</header>
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
`import SearchSuggestions from 'src/components/search/SearchSuggestions'`
|
|
41
|
+
|
|
42
|
+
<Canvas>
|
|
43
|
+
<Story
|
|
44
|
+
name="default"
|
|
45
|
+
parameters={{
|
|
46
|
+
backgrounds: { default: 'dark' },
|
|
47
|
+
}}
|
|
48
|
+
args={{
|
|
49
|
+
term: 'Ste',
|
|
50
|
+
terms: searchTerms,
|
|
51
|
+
products,
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
{Template.bind({})}
|
|
55
|
+
</Story>
|
|
56
|
+
</Canvas>
|
|
57
|
+
|
|
58
|
+
<ArgsTable story="default" />
|