|
| 1 | +import DsfrBadge from './DsfrBadge.vue' |
| 2 | + |
| 3 | +export default { |
| 4 | + component: DsfrBadge, |
| 5 | + title: 'Composants/Badge - DsfrBadge', |
| 6 | + argTypes: { |
| 7 | + dark: { |
| 8 | + control: 'boolean', |
| 9 | + description: 'Permet de voir le composant dans les deux **thèmes** : **clair** (`false`, défaut) et **sombre** (`true`).\n\n*N.B. : Ne fait pas partie du composant.*', |
| 10 | + }, |
| 11 | + label: { |
| 12 | + control: 'text', |
| 13 | + description: 'Label (texte) du badge', |
| 14 | + }, |
| 15 | + type: { |
| 16 | + options: ['error', 'success', 'new', 'info', 'warning', undefined], |
| 17 | + control: 'radio', |
| 18 | + description: '(Optionnel) **Type** du badge : `error` (Erreur), `success` (Succès), `new` (Nouveau), `info` (Information), `warning` (Avertissement)', |
| 19 | + }, |
| 20 | + noIcon: { |
| 21 | + control: 'boolean', |
| 22 | + description: 'Permet de ne pas afficher d’icône (si `true`)', |
| 23 | + }, |
| 24 | + small: { |
| 25 | + control: 'boolean', |
| 26 | + description: 'Permet d’afficher une petite icône (si `true`)', |
| 27 | + }, |
| 28 | + }, |
| 29 | +} |
| 30 | + |
| 31 | +export const Badge = (args) => ({ |
| 32 | + components: { |
| 33 | + DsfrBadge, |
| 34 | + }, |
| 35 | + data () { |
| 36 | + return args |
| 37 | + }, |
| 38 | + template: ` |
| 39 | + <DsfrBadge :label="label" :small="small" :type="type" :no-icon="noIcon" /> |
| 40 | + `, |
| 41 | + mounted () { |
| 42 | + document.body.parentElement.setAttribute('data-fr-theme', this.dark ? 'dark' : 'light') |
| 43 | + }, |
| 44 | +}) |
| 45 | +Badge.args = { |
| 46 | + dark: false, |
| 47 | + small: false, |
| 48 | + type: 'success', |
| 49 | + label: 'Succès au chocolat vert', |
| 50 | + noIcon: false, |
| 51 | +} |
| 52 | + |
| 53 | +export const TousLesBadges = (args) => ({ |
| 54 | + components: { |
| 55 | + DsfrBadge, |
| 56 | + }, |
| 57 | + data () { |
| 58 | + return args |
| 59 | + }, |
| 60 | + template: ` |
| 61 | + <p> |
| 62 | + <DsfrBadge label="Simple" /> |
| 63 | + </p> |
| 64 | + <p> |
| 65 | + <DsfrBadge style="width: 300px" ellipsis label="Label très long qui, normalement, devrait être coupé par une ellipse" /> |
| 66 | + </p> |
| 67 | + <p> |
| 68 | + <DsfrBadge label="Succès" type="success" /> |
| 69 | + </p> |
| 70 | + <p> |
| 71 | + <DsfrBadge label="Erreur" type="error" /> |
| 72 | + </p> |
| 73 | + <p> |
| 74 | + <DsfrBadge label="Attention !" type="warning" /> |
| 75 | + </p> |
| 76 | + <p> |
| 77 | + <DsfrBadge label="Information" type="info" /> |
| 78 | + </p> |
| 79 | + <p> |
| 80 | + <DsfrBadge label="Nouveauté" type="new" /> |
| 81 | + </p> |
| 82 | + `, |
| 83 | + mounted () { |
| 84 | + document.body.parentElement.setAttribute('data-fr-theme', this.dark ? 'dark' : 'light') |
| 85 | + }, |
| 86 | +}) |
| 87 | +TousLesBadges.args = { |
| 88 | + dark: false, |
| 89 | +} |
0 commit comments