@faststore/ui 2.0.32-alpha.0 → 2.0.34-alpha.0

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.
Files changed (100) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/components/molecules/Accordion/AccordionItem.d.ts +1 -7
  3. package/dist/components/molecules/Accordion/AccordionItem.js +1 -7
  4. package/dist/components/molecules/Accordion/AccordionItem.js.map +1 -1
  5. package/package.json +6 -19
  6. package/src/components/molecules/Accordion/AccordionItem.tsx +42 -42
  7. package/dist/components/atoms/Incentive/stories/assets/Icons.d.ts +0 -2
  8. package/dist/components/atoms/Incentive/stories/assets/Icons.js +0 -6
  9. package/dist/components/atoms/Incentive/stories/assets/Icons.js.map +0 -1
  10. package/dist/components/molecules/Dropdown/stories/assets/Caret.d.ts +0 -2
  11. package/dist/components/molecules/Dropdown/stories/assets/Caret.js +0 -4
  12. package/dist/components/molecules/Dropdown/stories/assets/Caret.js.map +0 -1
  13. package/dist/components/molecules/PaymentMethods/stories/assets/Icons.d.ts +0 -9
  14. package/dist/components/molecules/PaymentMethods/stories/assets/Icons.js +0 -26
  15. package/dist/components/molecules/PaymentMethods/stories/assets/Icons.js.map +0 -1
  16. package/dist/components/molecules/QuantitySelector/stories/assets/Icons.d.ts +0 -7
  17. package/dist/components/molecules/QuantitySelector/stories/assets/Icons.js +0 -11
  18. package/dist/components/molecules/QuantitySelector/stories/assets/Icons.js.map +0 -1
  19. package/dist/components/molecules/SearchInput/stories/assets/CustomIcon.d.ts +0 -3
  20. package/dist/components/molecules/SearchInput/stories/assets/CustomIcon.js +0 -7
  21. package/dist/components/molecules/SearchInput/stories/assets/CustomIcon.js.map +0 -1
  22. package/src/components/atoms/Badge/Badge.stories.mdx +0 -156
  23. package/src/components/atoms/Incentive/stories/Incentive.mdx +0 -24
  24. package/src/components/atoms/Incentive/stories/Incentive.stories.tsx +0 -26
  25. package/src/components/atoms/Incentive/stories/assets/Icons.tsx +0 -14
  26. package/src/components/atoms/Input/Input.stories.mdx +0 -34
  27. package/src/components/atoms/Label/Label.stories.mdx +0 -65
  28. package/src/components/atoms/Link/Link.stories.mdx +0 -134
  29. package/src/components/atoms/Popover/stories/Popover.mdx +0 -18
  30. package/src/components/atoms/Popover/stories/Popover.stories.tsx +0 -50
  31. package/src/components/atoms/Radio/Radio.stories.mdx +0 -101
  32. package/src/components/atoms/Skeleton/stories/Skeleton.mdx +0 -18
  33. package/src/components/atoms/Skeleton/stories/Skeleton.stories.tsx +0 -21
  34. package/src/components/atoms/Slider/stories/Slider.mdx +0 -29
  35. package/src/components/atoms/Slider/stories/Slider.stories.tsx +0 -32
  36. package/src/components/atoms/Spinner/stories/Spinner.mdx +0 -18
  37. package/src/components/atoms/Spinner/stories/Spinner.stories.tsx +0 -21
  38. package/src/components/atoms/TextArea/stories/TextArea.mdx +0 -22
  39. package/src/components/atoms/TextArea/stories/TextArea.stories.tsx +0 -49
  40. package/src/components/molecules/Accordion/stories/Accordion.mdx +0 -62
  41. package/src/components/molecules/Accordion/stories/Accordion.stories.tsx +0 -160
  42. package/src/components/molecules/AggregateRating/stories/AggregateRating.mdx +0 -33
  43. package/src/components/molecules/AggregateRating/stories/AggregateRating.stories.tsx +0 -111
  44. package/src/components/molecules/Alert/stories/Alert.mdx +0 -26
  45. package/src/components/molecules/Alert/stories/Alert.stories.tsx +0 -36
  46. package/src/components/molecules/Banner/stories/Banner.mdx +0 -63
  47. package/src/components/molecules/Banner/stories/Banner.stories.tsx +0 -66
  48. package/src/components/molecules/Breadcrumb/stories/Breadcrumb.mdx +0 -27
  49. package/src/components/molecules/Breadcrumb/stories/Breadcrumb.stories.tsx +0 -55
  50. package/src/components/molecules/Bullets/stories/Bullets.mdx +0 -25
  51. package/src/components/molecules/Bullets/stories/Bullets.stories.tsx +0 -64
  52. package/src/components/molecules/Card/stories/Card.mdx +0 -54
  53. package/src/components/molecules/Card/stories/Card.stories.tsx +0 -63
  54. package/src/components/molecules/Carousel/stories/Carousel.mdx +0 -35
  55. package/src/components/molecules/Carousel/stories/Carousel.stories.tsx +0 -56
  56. package/src/components/molecules/CartItem/stories/CartItem.mdx +0 -79
  57. package/src/components/molecules/CartItem/stories/CartItem.stories.tsx +0 -70
  58. package/src/components/molecules/CheckboxField/CheckboxField.stories.mdx +0 -38
  59. package/src/components/molecules/DiscountBadge/DiscountBadge.stories.mdx +0 -38
  60. package/src/components/molecules/Dropdown/stories/Dropdown.mdx +0 -63
  61. package/src/components/molecules/Dropdown/stories/Dropdown.stories.tsx +0 -94
  62. package/src/components/molecules/Dropdown/stories/assets/Caret.tsx +0 -19
  63. package/src/components/molecules/Form/stories/Form.mdx +0 -23
  64. package/src/components/molecules/Form/stories/Form.stories.tsx +0 -65
  65. package/src/components/molecules/Gift/stories/Gift.mdx +0 -40
  66. package/src/components/molecules/Gift/stories/Gift.stories.tsx +0 -66
  67. package/src/components/molecules/IconButton/IconButton.stories.mdx +0 -46
  68. package/src/components/molecules/InputField/InputField.stories.mdx +0 -116
  69. package/src/components/molecules/LoadingButton/stories/LoadingButton.mdx +0 -20
  70. package/src/components/molecules/LoadingButton/stories/LoadingButton.stories.tsx +0 -36
  71. package/src/components/molecules/Modal/stories/Modal.mdx +0 -18
  72. package/src/components/molecules/Modal/stories/Modal.stories.tsx +0 -45
  73. package/src/components/molecules/OrderSummary/stories/OrderSummary.mdx +0 -29
  74. package/src/components/molecules/OrderSummary/stories/OrderSummary.stories.tsx +0 -29
  75. package/src/components/molecules/PaymentMethods/stories/PaymentMethods.mdx +0 -19
  76. package/src/components/molecules/PaymentMethods/stories/PaymentMethods.stories.tsx +0 -41
  77. package/src/components/molecules/PaymentMethods/stories/assets/Icons.tsx +0 -89
  78. package/src/components/molecules/PriceRange/stories/PriceRange.mdx +0 -28
  79. package/src/components/molecules/PriceRange/stories/PriceRange.stories.tsx +0 -45
  80. package/src/components/molecules/ProductCard/stories/ProductCard.mdx +0 -55
  81. package/src/components/molecules/ProductCard/stories/ProductCard.stories.tsx +0 -60
  82. package/src/components/molecules/ProductTitle/stories/ProductTitle.mdx +0 -26
  83. package/src/components/molecules/ProductTitle/stories/ProductTitle.stories.tsx +0 -27
  84. package/src/components/molecules/QuantitySelector/stories/QuantitySelector.mdx +0 -26
  85. package/src/components/molecules/QuantitySelector/stories/QuantitySelector.stories.tsx +0 -77
  86. package/src/components/molecules/QuantitySelector/stories/assets/Icons.tsx +0 -52
  87. package/src/components/molecules/RadioField/RadioField.stories.mdx +0 -38
  88. package/src/components/molecules/RadioGroup/stories/RadioGroup.mdx +0 -39
  89. package/src/components/molecules/RadioGroup/stories/RadioGroup.stories.tsx +0 -108
  90. package/src/components/molecules/SearchInput/stories/SearchInput.mdx +0 -28
  91. package/src/components/molecules/SearchInput/stories/SearchInput.stories.tsx +0 -45
  92. package/src/components/molecules/SearchInput/stories/assets/CustomIcon.tsx +0 -22
  93. package/src/components/molecules/SkuSelector/stories/SkuSelector.mdx +0 -24
  94. package/src/components/molecules/SkuSelector/stories/SkuSelector.stories.tsx +0 -52
  95. package/src/components/molecules/Tag/Tag.stories.mdx +0 -31
  96. package/src/components/organisms/OutOfStock/stories/OutOfStock.mdx +0 -37
  97. package/src/components/organisms/OutOfStock/stories/OutOfStock.stories.tsx +0 -71
  98. package/src/components/organisms/Tiles/stories/Tiles.mdx +0 -39
  99. package/src/components/organisms/Tiles/stories/Tiles.stories.tsx +0 -38
  100. package/src/typings/utils.d.ts +0 -5
@@ -1,54 +0,0 @@
1
- import { Canvas, Props, Story, ArgsTable } from '@storybook/addon-docs'
2
-
3
- import Card from '../Card'
4
- import CardImage from '../CardImage'
5
- import CardContent from '../CardContent'
6
- import CardActions from '../CardActions'
7
-
8
- # Card
9
-
10
- <Canvas>
11
- <Story id="molecules-card--card" />
12
- </Canvas>
13
-
14
- ## Components
15
-
16
- The `Card` uses the [Compound Component](https://kentcdodds.com/blog/compound-components-with-react-hooks) pattern, its components are:
17
-
18
- - `Card`: the wrapper component;
19
- - `CardImage`: the wrapper component for the content's image;
20
- - `CardContent`: the wrapper component for the content's details;
21
- - `CardActions`: the wrapper component for the content's CTAs (call-to-action);
22
-
23
- ## Props
24
-
25
- All Card-related components support all attributes also supported by the `<div>` tag.
26
-
27
- ### `Card`
28
-
29
- <ArgsTable of={Card} />
30
-
31
- ### `CardImage`
32
-
33
- <ArgsTable of={CardImage} />
34
-
35
- ### `CardContent`
36
-
37
- <ArgsTable of={CardContent} />
38
-
39
- ### `CardActions`
40
-
41
- <ArgsTable of={CardActions} />
42
-
43
- ## CSS Selectors
44
-
45
- ```css
46
- [data-fs-card] {
47
- }
48
- [data-card-image] {
49
- }
50
- [data-card-content] {
51
- }
52
- [data-card-actions] {
53
- }
54
- ```
@@ -1,63 +0,0 @@
1
- import type { Meta, Story } from '@storybook/react'
2
- import React from 'react'
3
-
4
- // Atoms
5
- import { Icon } from '@faststore/components'
6
- // Card components
7
- import type { CardProps } from '../Card'
8
- import CardComponent from '../Card'
9
- import CardActions from '../CardActions'
10
- import CardContent from '../CardContent'
11
- import CardImage from '../CardImage'
12
- import mdx from './Card.mdx'
13
-
14
- const RightArrow = () => (
15
- <svg
16
- xmlns="http://www.w3.org/2000/svg"
17
- width="18"
18
- height="18"
19
- viewBox="0 0 18 18"
20
- >
21
- <path
22
- d="M10.6553 3.40717C10.3624 3.11428 9.88756 3.11428 9.59467 3.40717C9.30178 3.70006 9.30178 4.17494 9.59467 4.46783L13.3768 8.25H2.8125C2.39829 8.25 2.0625 8.58579 2.0625 9C2.0625 9.41421 2.39829 9.75 2.8125 9.75H13.3768L9.59467 13.5322C9.30178 13.8251 9.30178 14.2999 9.59467 14.5928C9.88756 14.8857 10.3624 14.8857 10.6553 14.5928L15.7178 9.53033C15.8643 9.38388 15.9375 9.19194 15.9375 9C15.9375 8.89831 15.9173 8.80134 15.8806 8.71291C15.844 8.62445 15.7897 8.54158 15.7178 8.46967L10.6553 3.40717Z"
23
- fill="currentColor"
24
- />
25
- </svg>
26
- )
27
-
28
- const CardTemplate: Story<CardProps> = ({ testId }) => {
29
- return (
30
- <CardComponent testId={testId}>
31
- <CardImage>
32
- <img
33
- alt="A person with hands on the pocket, carrying a round straw bag"
34
- src="https://storecomponents.vtex.app/assets/fit-in/1280x613/center/middle/https%3A%2F%2Fstorecomponents.vtexassets.com%2Fassets%2Fvtex.file-manager-graphql%2Fimages%2Fedce348c-068c-4fb9-91f2-7d235d596e0f___b2822f893b14f87337d08f07f0e520ab.jpg"
35
- />
36
- </CardImage>
37
- <CardContent>
38
- <h3>Get to know our next release</h3>
39
- <p>
40
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Evehicula in
41
- turpis sit ametl.{' '}
42
- </p>
43
- </CardContent>
44
- <CardActions>
45
- <a href="/">
46
- Check new releases <Icon component={<RightArrow />} />
47
- </a>
48
- </CardActions>
49
- </CardComponent>
50
- )
51
- }
52
-
53
- export const Card = CardTemplate.bind({})
54
- Card.storyName = 'Card'
55
-
56
- export default {
57
- title: 'Molecules/Card',
58
- parameters: {
59
- docs: {
60
- page: mdx,
61
- },
62
- },
63
- } as Meta
@@ -1,35 +0,0 @@
1
- import { Canvas, Story, ArgsTable } from '@storybook/addon-docs'
2
-
3
- import Carousel from '../Carousel'
4
-
5
- # Carousel
6
-
7
- <Canvas>
8
- <Story id="molecules-carousel--carousel" />
9
- </Canvas>
10
-
11
- ## Props
12
-
13
- <ArgsTable of={Carousel} />
14
-
15
- ## CSS Selectors
16
-
17
- ```css
18
- [data-fs-carousel] {}
19
-
20
- [data-fs-carousel-track-container] {}
21
-
22
- [data-fs-carousel-track] {}
23
-
24
- [data-fs-carousel-item] {}
25
-
26
- [data-fs-carousel-controls] {}
27
-
28
- [data-fs-carousel-control="left|right"] {}
29
-
30
- [data-fs-carousel-bullets] {}
31
-
32
- [data-fs-carousel-bullets] [data-fs-bullets] {}
33
- ```
34
-
35
- This components inherits [IconButton](?path=/docs/molecules-iconbutton--default#css-selectors), [Bullets](?path=/docs/molecules-bullets--bullets#css-selectors) css selectors.
@@ -1,56 +0,0 @@
1
- import React from 'react'
2
- import type { Story } from '@storybook/react'
3
-
4
- import type { ComponentArgTypes } from '../../../../typings/utils'
5
- import Component from '../Carousel'
6
- import type { CarouselProps } from '../Carousel'
7
- import mdx from './Carousel.mdx'
8
-
9
- const CarouselTemplate: Story<
10
- CarouselProps & { transitionDuration: number }
11
- > = ({ infiniteMode, controls, transitionDuration }) => (
12
- <Component
13
- infiniteMode={infiniteMode}
14
- controls={controls}
15
- transition={{ property: 'transform', duration: transitionDuration }}
16
- >
17
- <img
18
- height={480}
19
- width="100%"
20
- alt="A vintage camera"
21
- src="https://storecomponents.vtex.app/assets/fit-in/480x480/center/middle/https%3A%2F%2Fstorecomponents.vtexassets.com%2Farquivos%2Fids%2F155481%2FFrame-3.jpg%3Fv%3D636793814536230000"
22
- />
23
- <img
24
- height={480}
25
- width="100%"
26
- alt="A vintage camera"
27
- src="https://storecomponents.vtex.app/assets/fit-in/480x480/center/middle/https%3A%2F%2Fstorecomponents.vtexassets.com%2Farquivos%2Fids%2F155481%2FFrame-3.jpg%3Fv%3D636793814536230000"
28
- />
29
- </Component>
30
- )
31
-
32
- export const Carousel = CarouselTemplate.bind({})
33
-
34
- const argTypes: ComponentArgTypes<
35
- CarouselProps & { transitionDuration: number }
36
- > = {
37
- controls: {
38
- type: 'select',
39
- options: ['complete', 'paginationBullets', 'navigationArrows'],
40
- defaultValue: 'complete',
41
- },
42
- transitionDuration: {
43
- type: 'number',
44
- defaultValue: 400,
45
- },
46
- }
47
-
48
- export default {
49
- title: 'Molecules/Carousel',
50
- argTypes,
51
- parameters: {
52
- docs: {
53
- page: mdx,
54
- },
55
- },
56
- }
@@ -1,79 +0,0 @@
1
- import { ArgsTable, Canvas, Props, Story } from '@storybook/addon-docs'
2
-
3
- import CartItem, {
4
- CartItemActions,
5
- CartItemContent,
6
- CartItemImage,
7
- CartItemPrices,
8
- CartItemSummary,
9
- CartItemTitle,
10
- } from '../'
11
-
12
- # Cart Item
13
-
14
- <Canvas>
15
- <Story id="molecules-cartitem--default" />
16
- </Canvas>
17
-
18
- ## Components
19
-
20
- The `CartItem` uses the [Compound Component](https://kentcdodds.com/blog/compound-components-with-react-hooks) pattern, its components are:
21
-
22
- - `CartItem`: the wrapper component;
23
- - `CartItemContent`: the wrapper component for the image and summary;
24
- - `CartItemImage`: the wrapper component for the content's image;
25
- - `CartItemSummary`: the wrapper component for the title and prices;
26
- - `CartItemTitle`: the wrapper component for the title;
27
- - `CartItemPrices`: the wrapper component for the prices;
28
- - `CartItemActions`: the wrapper component for the remove from cart button and quantity selector;
29
-
30
- ## Props
31
-
32
- All CartItem-related components support all attributes also supported by the `<div>` tag.
33
-
34
- ### `CartItem`
35
-
36
- <ArgsTable of={CartItem} />
37
-
38
- ### `CartItemContent`
39
-
40
- <ArgsTable of={CartItemContent} />
41
-
42
- ### `CartItemImage`
43
-
44
- <ArgsTable of={CartItemImage} />
45
-
46
- ### `CartItemSummary`
47
-
48
- <ArgsTable of={CartItemSummary} />
49
-
50
- ### `CartItemTitle`
51
-
52
- <ArgsTable of={CartItemTitle} />
53
-
54
- ### `CartItemPrices`
55
-
56
- <ArgsTable of={CartItemPrices} />
57
-
58
- ### `CartItemActions`
59
-
60
- <ArgsTable of={CartItemActions} />
61
-
62
- ## CSS Selectors
63
-
64
- ```css
65
- [data-fs-cart-item] {
66
- }
67
- [data-fs-cart-item-content] {
68
- }
69
- [data-fs-cart-item-image] {
70
- }
71
- [data-fs-cart-item-summary] {
72
- }
73
- [data-fs-cart-item-title] {
74
- }
75
- [data-fs-cart-item-prices] {
76
- }
77
- [data-fs-cart-item-actions] {
78
- }
79
- ```
@@ -1,70 +0,0 @@
1
- import React from 'react'
2
-
3
- import CartItem, {
4
- CartItemActions,
5
- CartItemContent,
6
- CartItemImage,
7
- CartItemPrices,
8
- CartItemSummary,
9
- CartItemTitle,
10
- } from '../'
11
- import { Button, Price, QuantitySelector } from '../../../../'
12
- import mdx from './CartItem.mdx'
13
-
14
- import type { Meta, Story } from '@storybook/react'
15
- import type { CartItemProps } from '../'
16
-
17
- const product = {
18
- name: 'Apple Magic Mouse',
19
- imageUrl:
20
- 'https://assets.vtex.app/unsafe/216x216/center/middle/https%3A%2F%2Fstoreframework.vtexassets.com%2Farquivos%2Fids%2F190902%2Funsplash-magic-mouse.jpg%3Fv%3D637800136963870000',
21
- price: {
22
- listing: 999,
23
- spot: 950,
24
- },
25
- }
26
-
27
- const CartItemTemplate: Story<CartItemProps> = ({ testId }) => {
28
- return (
29
- <CartItem testId={testId}>
30
- <CartItemContent>
31
- <CartItemImage>
32
- <img alt={product.name} src={product.imageUrl} />
33
- </CartItemImage>
34
-
35
- <CartItemSummary>
36
- <CartItemTitle>{product.name}</CartItemTitle>
37
-
38
- <CartItemPrices>
39
- <Price variant="listing" value={product.price.listing} />
40
- <Price variant="spot" value={product.price.spot} />
41
- </CartItemPrices>
42
- </CartItemSummary>
43
- </CartItemContent>
44
-
45
- <CartItemActions>
46
- <Button>Remove</Button>
47
-
48
- <QuantitySelector
49
- quantity={1}
50
- leftButtonProps={{ icon: <span>-</span> }}
51
- rightButtonProps={{ icon: <span>+</span> }}
52
- inputProps={{ readOnly: true }}
53
- />
54
- </CartItemActions>
55
- </CartItem>
56
- )
57
- }
58
-
59
- export const Default = CartItemTemplate.bind({})
60
-
61
- Default.storyName = 'CartItem'
62
-
63
- export default {
64
- title: 'Molecules/CartItem',
65
- parameters: {
66
- docs: {
67
- page: mdx,
68
- },
69
- },
70
- } as Meta
@@ -1,38 +0,0 @@
1
- import { Meta, Canvas, Story, ArgsTable } from '@storybook/addon-docs'
2
-
3
- import { CheckboxField } from '@faststore/components'
4
-
5
- <Meta title="Molecules/CheckboxField" component={CheckboxField} argTypes={{}} />
6
-
7
- export const Template = (args) => (
8
- <CheckboxField id="checkbox-field" label="CheckboxField" />
9
- )
10
-
11
- <header>
12
-
13
- # CheckboxField
14
-
15
- CheckboxField is composed of a Checkbox input and its corresponding Label. It allows users to select one option from a set.
16
-
17
- </header>
18
-
19
- ## Usage
20
-
21
- ```jsx
22
- import CheckboxField from '@faststore/ui'
23
- // Styles
24
- import '@faststore/ui/src/components/molecules/CheckboxField/styles.scss'
25
- ```
26
-
27
- <Canvas>
28
- <Story
29
- name="default"
30
- args={{
31
- id: 'checkbox-default',
32
- }}
33
- >
34
- {Template.bind({})}
35
- </Story>
36
- </Canvas>
37
-
38
- <ArgsTable story="default" />
@@ -1,38 +0,0 @@
1
- import { Meta, Canvas, Story, ArgsTable } from '@storybook/addon-docs'
2
-
3
- import { DiscountBadge } from '@faststore/components'
4
-
5
- <Meta title="Molecules/DiscountBadge" component={DiscountBadge} argTypes={{}} />
6
-
7
- export const Template = (args) => (
8
- <DiscountBadge id="discount-badge-id" listPrice={65} spotPrice={40} />
9
- )
10
-
11
- <header>
12
-
13
- # DiscountBadge
14
-
15
- A custom `Badge` that display product's discounts.
16
-
17
- </header>
18
-
19
- ## Usage
20
-
21
- ```jsx
22
- import { DiscountBadge } from '@faststore/ui'
23
- // Styles
24
- import '@faststore/ui/src/components/molecules/DiscountBadge/styles.scss'
25
- ```
26
-
27
- <Canvas>
28
- <Story
29
- name="default"
30
- args={{
31
- id: 'discount-badge-default',
32
- }}
33
- >
34
- {Template.bind({})}
35
- </Story>
36
- </Canvas>
37
-
38
- <ArgsTable story="default" />
@@ -1,63 +0,0 @@
1
- import { Canvas, Props, Story, ArgsTable } from '@storybook/addon-docs'
2
-
3
- import Dropdown from '../Dropdown'
4
- import DropdownButton from '../DropdownButton'
5
- import DropdownItem from '../DropdownItem'
6
- import DropdownMenu from '../DropdownMenu'
7
-
8
- # DropdownUncontrolled
9
-
10
- <Canvas>
11
- <Story id="molecules-dropdown--uncontrolled" />
12
- </Canvas>
13
-
14
- # DropdownControlled
15
-
16
- <Canvas>
17
- <Story id="molecules-dropdown--controlled" />
18
- </Canvas>
19
-
20
- # DropdownSelectable
21
-
22
- <Canvas>
23
- <Story id="molecules-dropdown--selectable" />
24
- </Canvas>
25
-
26
- ## Components
27
-
28
- The `Dropdown` uses the [Compound Component](https://kentcdodds.com/blog/compound-components-with-react-hooks) pattern, its components are:
29
-
30
- - `Dropdown`: the wrapper component, can receive an `isOpen` and emit the event `onDismiss`, which can be used as a controlled component.
31
- - `DropdownButton`: the button that emits the trigger to open de DropdownMenu.
32
- - `DropdownItem`: an option on DropdownMenu.
33
- - `DropdownMenu`: wraps a series of `DropdownItem`s.
34
-
35
- ## Props
36
-
37
- ### `Dropdown`
38
-
39
- <ArgsTable of={Dropdown} />
40
-
41
- ### `DropdownButton`
42
-
43
- <ArgsTable of={DropdownButton} />
44
-
45
- ### `DropdownItem`
46
-
47
- <ArgsTable of={DropdownItem} />
48
-
49
- ### `DropdownMenu`
50
-
51
- <ArgsTable of={DropdownMenu} />
52
-
53
- ## CSS Selectors
54
-
55
- ```css
56
- [data-fs-dropdown-button] {}
57
-
58
- [data-fs-dropdown-item] {}
59
-
60
- [data-fs-dropdown-overlay] {}
61
-
62
- [data-fs-dropdown-menu] {}
63
- ```
@@ -1,94 +0,0 @@
1
- import React, { useState } from 'react'
2
- import type { PropsWithChildren } from 'react'
3
- import type { Meta, Story } from '@storybook/react'
4
-
5
- import { Caret } from './assets/Caret'
6
- import { Button } from '@faststore/components'
7
- import type { DropdownProps } from '..'
8
- import Dropdown, { DropdownButton, DropdownItem, DropdownMenu } from '..'
9
- import mdx from './Dropdown.mdx'
10
-
11
- const DropdownUncontrolledTemplate: Story<
12
- PropsWithChildren<DropdownProps>
13
- > = () => {
14
- return (
15
- <>
16
- <Dropdown>
17
- <DropdownButton>Dropdown Button</DropdownButton>
18
- <DropdownMenu>
19
- <DropdownItem onClick={() => console.log('Item 1')}>
20
- Dropdown Item 1
21
- </DropdownItem>
22
- <DropdownItem onClick={() => console.log('Item 2')}>
23
- Dropdown Item 2
24
- </DropdownItem>
25
- <DropdownItem onClick={() => console.log('Item 3')}>
26
- Dropdown Item 3
27
- </DropdownItem>
28
- </DropdownMenu>
29
- </Dropdown>
30
- </>
31
- )
32
- }
33
-
34
- export const Uncontrolled = DropdownUncontrolledTemplate.bind({})
35
-
36
- const DropdownControlledTemplate: Story<
37
- PropsWithChildren<DropdownProps>
38
- > = () => {
39
- const [isOpen, setIsOpen] = useState(false)
40
-
41
- return (
42
- <>
43
- <Button onClick={() => setIsOpen((old) => !old)}>Simple Button</Button>
44
- <Dropdown isOpen={isOpen} onDismiss={() => setIsOpen(false)}>
45
- <DropdownButton>DropdownButton</DropdownButton>
46
- <DropdownMenu>
47
- <DropdownItem>Dropdown Item 1</DropdownItem>
48
- <DropdownItem>Dropdown Item 2</DropdownItem>
49
- <DropdownItem>Dropdown Item 3</DropdownItem>
50
- </DropdownMenu>
51
- </Dropdown>
52
- </>
53
- )
54
- }
55
-
56
- export const Controlled = DropdownControlledTemplate.bind({})
57
-
58
- const DropdownSelectableTemplate: Story<
59
- PropsWithChildren<DropdownProps>
60
- > = () => {
61
- const [value, setValue] = useState('Selectable')
62
-
63
- return (
64
- <>
65
- <Dropdown>
66
- <DropdownButton>
67
- {value} <Caret />
68
- </DropdownButton>
69
- <DropdownMenu>
70
- <DropdownItem onClick={() => setValue('Value 1')}>
71
- Value 1
72
- </DropdownItem>
73
- <DropdownItem onClick={() => setValue('Value 2')}>
74
- Value 2
75
- </DropdownItem>
76
- <DropdownItem onClick={() => setValue('Value 3')}>
77
- Value 3
78
- </DropdownItem>
79
- </DropdownMenu>
80
- </Dropdown>
81
- </>
82
- )
83
- }
84
-
85
- export const Selectable = DropdownSelectableTemplate.bind({})
86
-
87
- export default {
88
- title: 'Molecules/Dropdown',
89
- parameters: {
90
- docs: {
91
- page: mdx,
92
- },
93
- },
94
- } as Meta
@@ -1,19 +0,0 @@
1
- import React from 'react'
2
-
3
- export const Caret = () => (
4
- <svg
5
- xmlns="http://www.w3.org/2000/svg"
6
- width="24"
7
- height="24"
8
- viewBox="0 0 24 24"
9
- fill="none"
10
- stroke="currentColor"
11
- strokeWidth="2"
12
- strokeLinecap="round"
13
- strokeLinejoin="round"
14
- className="feather feather-chevron-down"
15
- style={{ display: 'inline' }}
16
- >
17
- <polyline points="6 9 12 15 18 9" />
18
- </svg>
19
- )
@@ -1,23 +0,0 @@
1
- import { Canvas, Props, Story, ArgsTable } from '@storybook/addon-docs'
2
-
3
- import Form from '../Form'
4
-
5
- # Form
6
-
7
- <Canvas>
8
- <Story id="molecules-form--form" />
9
- </Canvas>
10
-
11
- ## Props
12
-
13
- The `Form` component supports all attributes also supported by the `<form>` HTML tag.
14
-
15
- Besides those attributes, the following prop is also supported:
16
-
17
- <ArgsTable of={Form} />
18
-
19
- ## CSS Selectors
20
-
21
- ```css
22
- [data-fs-form] {}
23
- ```