diff --git a/.storybook/mocks/cart-sidebar.js b/.storybook/mocks/cart-sidebar.js new file mode 100644 index 00000000..fa932155 --- /dev/null +++ b/.storybook/mocks/cart-sidebar.js @@ -0,0 +1,40 @@ +export const cartItem = { + id: '39542524', + price: 656.5, + listPrice: 892.43, + seller: { + identifier: '1', + }, + quantity: 1, + itemOffered: { + sku: '39542524', + name: 'pink', + gtin: '0001078884042', + image: [ + { + url: 'https://storeframework.vtexassets.com/arquivos/ids/165082/sed.jpg?v=637752996157770000', + alternateName: 'accusamus', + }, + { + url: 'https://storeframework.vtexassets.com/arquivos/ids/165079/quis.jpg?v=637752996135400000', + alternateName: 'dolorem', + }, + { + url: 'https://storeframework.vtexassets.com/arquivos/ids/165080/tempora.jpg?v=637752996141030000', + alternateName: 'enim', + }, + { + url: 'https://storeframework.vtexassets.com/arquivos/ids/165081/est.jpg?v=637752996144600000', + alternateName: 'ea', + }, + ], + brand: { + name: 'iRobot', + }, + isVariantOf: { + productGroupID: '99483893', + name: 'Tasty Concrete Computer', + }, + additionalProperty: [], + }, +} diff --git a/.storybook/mocks/filter-slider.js b/.storybook/mocks/filter-slider.js new file mode 100644 index 00000000..bde45095 --- /dev/null +++ b/.storybook/mocks/filter-slider.js @@ -0,0 +1,59 @@ +export const facets = [ + { + key: 'price', + label: 'Preço', + min: { + selected: 1.67, + absolute: 1.67, + }, + max: { + selected: 889.53, + absolute: 889.53, + }, + __typename: 'StoreFacetRange', + }, + { + key: 'category-2', + label: 'Categoria', + values: [ + { + label: 'Chairs', + value: 'chairs', + selected: true, + quantity: 138, + }, + { + label: 'Desks', + value: 'desks', + selected: false, + quantity: 125, + }, + ], + __typename: 'StoreFacetBoolean', + }, + { + key: 'brand', + label: 'Marca', + values: [ + { + label: 'Acer', + value: 'acer', + selected: true, + quantity: 138, + }, + { + label: 'Adidas', + value: 'adidas', + selected: false, + quantity: 121, + }, + { + label: 'Nike', + value: 'nike', + selected: false, + quantity: 150, + }, + ], + __typename: 'StoreFacetBoolean', + }, +] diff --git a/CHANGELOG.md b/CHANGELOG.md index de41aac5..d849c004 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Applies new local tokens to `SlideOver` ([#142](https://github.com/vtex-sites/gatsby.store/pull/142)) +- Applies new local tokens to `CartSidebar` ([#142](https://github.com/vtex-sites/gatsby.store/pull/142)) - Adds [MSW Addon](https://storybook.js.org/addons/msw-storybook-addon) ([#143](https://github.com/vtex-sites/gatsby.store/pull/143)) - Global tokens doc page on storybook ([#140](https://github.com/vtex-sites/gatsby.store/pull/140)) - Uses new cross selling API on PDP ([#137](https://github.com/vtex-sites/gatsby.store/pull/137)) diff --git a/src/components/cart/CartSidebar/CartSidebar.stories.mdx b/src/components/cart/CartSidebar/CartSidebar.stories.mdx new file mode 100644 index 00000000..9603123a --- /dev/null +++ b/src/components/cart/CartSidebar/CartSidebar.stories.mdx @@ -0,0 +1,118 @@ +import { Meta, Canvas, Story, ArgsTable } from '@storybook/addon-docs' + +import { CartProvider, SessionProvider } from '@faststore/sdk' +import UIProvider, { useUI } from 'src/sdk/ui/Provider' +import { useCart } from 'src/sdk/cart/useCart' + +import CartToggle from 'src/components/cart/CartToggle' +import CartSidebar from '.' + +import { cartItem } from 'src/../.storybook/mocks/cart-sidebar' +import { ButtonBuy } from 'src/components/ui/Button' + +import { + TokenTable, + TokenRow, + TokenDivider, +} from 'src/../.storybook/components' + + + +export const Template = () => { + const { cart: displayCart } = useUI() + const { addItem } = useCart() + return ( +
+ + addItem(cartItem)} + > + Add item to Cart + + {displayCart && } +
+ ) +} + +export const TemplateProvider = () => { + return ( + + + +