|
| 1 | +import { TagsGroup, TagsGroupProps } from "../dist/TagsGroup"; |
| 2 | +import { sectionName } from "./sectionName"; |
| 3 | +import { getStoryFactory } from "./getStory"; |
| 4 | +import { TagProps } from "../dist/Tag"; |
| 5 | + |
| 6 | +const { meta, getStory } = getStoryFactory({ |
| 7 | + sectionName, |
| 8 | + "wrappedComponent": { TagsGroup }, |
| 9 | + "description": ` |
| 10 | +- [See DSFR documentation](https://www.systeme-de-design.gouv.fr/composants-et-modeles/composants/tag) |
| 11 | +- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/TagsGroup.tsx)`, |
| 12 | + "argTypes": { |
| 13 | + "smallTags": { |
| 14 | + "description": ` |
| 15 | + Default: false, if true, the tags will be smaller. |
| 16 | + `, |
| 17 | + "control": { "type": "boolean" } |
| 18 | + }, |
| 19 | + "tags": { |
| 20 | + "description": `An array of TagProps (at least 1, max recommended: 6).`, |
| 21 | + "control": { "type": null } |
| 22 | + } |
| 23 | + }, |
| 24 | + "disabledProps": ["lang"], |
| 25 | + "defaultContainerWidth": 800 |
| 26 | +}); |
| 27 | + |
| 28 | +export default meta; |
| 29 | + |
| 30 | +const tagsWithProps = (props?: Omit<TagProps, "children">) => |
| 31 | + Array.from( |
| 32 | + { "length": 6 }, |
| 33 | + (_, i) => |
| 34 | + ({ |
| 35 | + ...props, |
| 36 | + "children": `Libellé tag ${i + 1}` |
| 37 | + } as TagProps) |
| 38 | + ) as TagsGroupProps["tags"]; |
| 39 | + |
| 40 | +export const Default = getStory({ |
| 41 | + "tags": tagsWithProps() |
| 42 | +}); |
| 43 | + |
| 44 | +export const SmallTags = getStory({ |
| 45 | + "tags": tagsWithProps(), |
| 46 | + "smallTags": true |
| 47 | +}); |
| 48 | + |
| 49 | +export const TagsAsAnchor = getStory({ |
| 50 | + "tags": tagsWithProps({ "linkProps": { "href": "#" } }) |
| 51 | +}); |
| 52 | + |
| 53 | +export const SmallTagsAsAnchor = getStory({ |
| 54 | + "tags": tagsWithProps({ "linkProps": { "href": "#" } }), |
| 55 | + "smallTags": true |
| 56 | +}); |
| 57 | + |
| 58 | +export const TagsPressed = getStory({ |
| 59 | + "tags": tagsWithProps({ "pressed": true }) |
| 60 | +}); |
| 61 | + |
| 62 | +export const SmallTagsPressed = getStory({ |
| 63 | + "tags": tagsWithProps({ "pressed": true }), |
| 64 | + "smallTags": true |
| 65 | +}); |
| 66 | + |
| 67 | +export const TagsDismissable = getStory({ |
| 68 | + "tags": tagsWithProps({ "dismissible": true }) |
| 69 | +}); |
| 70 | + |
| 71 | +export const SmallTagsDismissable = getStory({ |
| 72 | + "tags": tagsWithProps({ "dismissible": true }), |
| 73 | + "smallTags": true |
| 74 | +}); |
0 commit comments