|
| 1 | +import { CallOut } from "../dist/CallOut"; |
| 2 | +import type { CallOutProps } from "../dist/CallOut"; |
| 3 | +import { sectionName } from "./sectionName"; |
| 4 | +import { getStoryFactory, logCallbacks } from "./getStory"; |
| 5 | +import { assert } from "tsafe/assert"; |
| 6 | +import type { Equals } from "tsafe"; |
| 7 | + |
| 8 | +const { meta, getStory } = getStoryFactory({ |
| 9 | + sectionName, |
| 10 | + "wrappedComponent": { CallOut }, |
| 11 | + "description": ` |
| 12 | +- [See DSFR documentation](https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/mise-en-avant) |
| 13 | +- [See source code](//github.com/codegouvfr/react-dsfr/blob/main/src/CallOut.tsx)`, |
| 14 | + "disabledProps": ["lang"], |
| 15 | + "argTypes": { |
| 16 | + "title": { |
| 17 | + "description": "Optional" |
| 18 | + }, |
| 19 | + "colorVariant": { |
| 20 | + "options": (() => { |
| 21 | + const options = [ |
| 22 | + "green-tilleul-verveine", |
| 23 | + "green-bourgeon", |
| 24 | + "green-emeraude", |
| 25 | + "green-menthe", |
| 26 | + "green-archipel", |
| 27 | + "blue-ecume", |
| 28 | + "blue-cumulus", |
| 29 | + "purple-glycine", |
| 30 | + "pink-macaron", |
| 31 | + "pink-tuile", |
| 32 | + "brown-cafe-creme", |
| 33 | + "brown-caramel", |
| 34 | + "brown-opera", |
| 35 | + "orange-terre-battue", |
| 36 | + "yellow-moutarde", |
| 37 | + "yellow-tournesol", |
| 38 | + "beige-gris-galet", |
| 39 | + undefined |
| 40 | + ] as const; |
| 41 | + |
| 42 | + assert<Equals<typeof options[number], CallOutProps["colorVariant"]>>(); |
| 43 | + |
| 44 | + return options; |
| 45 | + })(), |
| 46 | + "control": { type: "select", labels: { null: "no severity" } } |
| 47 | + }, |
| 48 | + "iconId": { |
| 49 | + "options": (() => { |
| 50 | + const options = [ |
| 51 | + "ri-information-line", |
| 52 | + "fr-icon-checkbox-circle-line", |
| 53 | + "ri-ancient-gate-fill", |
| 54 | + undefined |
| 55 | + ] as const; |
| 56 | + |
| 57 | + assert<typeof options[number] extends CallOutProps["iconId"] ? true : false>(); |
| 58 | + |
| 59 | + return options; |
| 60 | + })(), |
| 61 | + "description": "Optional", |
| 62 | + "control": { "type": "radio" } |
| 63 | + }, |
| 64 | + "buttonProps": { |
| 65 | + "description": |
| 66 | + "The same props you would pass to a `<Button />`, `undefined` if you don't want any button", |
| 67 | + "control": { "type": null } |
| 68 | + } |
| 69 | + } |
| 70 | +}); |
| 71 | + |
| 72 | +export default meta; |
| 73 | + |
| 74 | +export const Default = getStory({ |
| 75 | + "title": "Titre mise en avant", |
| 76 | + "iconId": "ri-information-line", |
| 77 | + "description": `Les parents d’enfants de 11 à 14 ans n’ont aucune démarche à |
| 78 | + accomplir : les CAF versent automatiquement l’ARS aux familles déjà allocataires |
| 79 | + qui remplissent les conditions.`, |
| 80 | + "colorVariant": undefined, |
| 81 | + "buttonProps": { |
| 82 | + "children": "Label bouton MD", |
| 83 | + ...logCallbacks(["onClick"]) |
| 84 | + } |
| 85 | +}); |
| 86 | + |
| 87 | +export const NoTitle = getStory({ |
| 88 | + "iconId": "ri-information-line", |
| 89 | + "description": `Les parents d’enfants de 11 à 14 ans n’ont aucune démarche à |
| 90 | + accomplir : les CAF versent automatiquement l’ARS aux familles déjà allocataires |
| 91 | + qui remplissent les conditions.`, |
| 92 | + "colorVariant": undefined, |
| 93 | + "buttonProps": { |
| 94 | + "children": "Label bouton MD", |
| 95 | + ...logCallbacks(["onClick"]) |
| 96 | + } |
| 97 | +}); |
| 98 | + |
| 99 | +export const NoIcon = getStory({ |
| 100 | + "title": "Titre mise en avant", |
| 101 | + "description": `Les parents d’enfants de 11 à 14 ans n’ont aucune démarche à |
| 102 | + accomplir : les CAF versent automatiquement l’ARS aux familles déjà allocataires |
| 103 | + qui remplissent les conditions.`, |
| 104 | + "colorVariant": undefined, |
| 105 | + "buttonProps": { |
| 106 | + "children": "Label bouton MD", |
| 107 | + ...logCallbacks(["onClick"]) |
| 108 | + } |
| 109 | +}); |
| 110 | + |
| 111 | +export const NoButton = getStory({ |
| 112 | + "title": "Titre mise en avant", |
| 113 | + "iconId": "ri-information-line", |
| 114 | + "description": `Les parents d’enfants de 11 à 14 ans n’ont aucune démarche à |
| 115 | + accomplir : les CAF versent automatiquement l’ARS aux familles déjà allocataires |
| 116 | + qui remplissent les conditions.` |
| 117 | +}); |
0 commit comments