|
| 1 | +import { Highlight } from "../dist/Highlight"; |
| 2 | +import type { HighlightProps } from "../dist/Highlight"; |
| 3 | +import { sectionName } from "./sectionName"; |
| 4 | +import { getStoryFactory } from "./getStory"; |
| 5 | +import { assert } from "tsafe/assert"; |
| 6 | +import type { Equals } from "tsafe"; |
| 7 | + |
| 8 | +const { meta, getStory } = getStoryFactory<HighlightProps>({ |
| 9 | + sectionName, |
| 10 | + wrappedComponent: { Highlight }, |
| 11 | + description: ` |
| 12 | +- [See DSFR documentation](https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/mise-en-exergue) |
| 13 | +- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/Highlight.tsx)`, |
| 14 | + argTypes: { |
| 15 | + size: { |
| 16 | + options: (() => { |
| 17 | + const sizes = ["sm", "lg"] as const; |
| 18 | + |
| 19 | + assert<Equals<typeof sizes[number], HighlightProps.Size>>(); |
| 20 | + |
| 21 | + return [null, ...sizes]; |
| 22 | + })(), |
| 23 | + control: { type: "select", labels: { null: "default", sm: "small", lg: "large" } }, |
| 24 | + description: "Content text size" |
| 25 | + }, |
| 26 | + children: { |
| 27 | + type: { name: "string", required: true }, |
| 28 | + description: "Text to display as highlight content" |
| 29 | + }, |
| 30 | + classes: { |
| 31 | + control: "object", |
| 32 | + description: |
| 33 | + 'Add custom classes for "root" or "content" component inner elements. Associate custom class values with "root" or "content" keys' |
| 34 | + } |
| 35 | + }, |
| 36 | + disabledProps: ["lang"] |
| 37 | +}); |
| 38 | + |
| 39 | +export default meta; |
| 40 | + |
| 41 | +export const Default = getStory({ |
| 42 | + children: |
| 43 | + "Les parents d’enfants de 11 à 14 ans n’ont aucune démarche à accomplir : les CAF versent automatiquement l’ARS aux familles déjà allocataires qui remplissent les conditions." |
| 44 | +}); |
| 45 | + |
| 46 | +export const HighlightSmall = getStory( |
| 47 | + { |
| 48 | + children: "Highlight contains a text with small font size", |
| 49 | + size: "sm" |
| 50 | + }, |
| 51 | + { |
| 52 | + description: "Small `Highlight`" |
| 53 | + } |
| 54 | +); |
| 55 | + |
| 56 | +export const HighlightLarge = getStory( |
| 57 | + { |
| 58 | + children: "Highlight contains a text with large font size", |
| 59 | + size: "lg" |
| 60 | + }, |
| 61 | + { |
| 62 | + description: "Large `Highlight`" |
| 63 | + } |
| 64 | +); |
| 65 | + |
| 66 | +export const HighlightCustomGreenAccentColor = getStory( |
| 67 | + { |
| 68 | + children: "Highlight contains a text with custom green emeraude accent color", |
| 69 | + classes: { |
| 70 | + root: "fr-highlight--green-emeraude" |
| 71 | + } |
| 72 | + }, |
| 73 | + { |
| 74 | + description: "Large `Highlight`" |
| 75 | + } |
| 76 | +); |
| 77 | + |
| 78 | +export const HighlightCustomBrownAccentColor = getStory( |
| 79 | + { |
| 80 | + children: "Highlight contains a text with custom brown caramel accent color", |
| 81 | + classes: { |
| 82 | + root: "fr-highlight--brown-caramel" |
| 83 | + } |
| 84 | + }, |
| 85 | + { |
| 86 | + description: "Large `Highlight`" |
| 87 | + } |
| 88 | +); |
0 commit comments