Skip to content

Commit bec93ab

Browse files
committed
refactor(DsfrConsent): ♻️ utilise defineSlots et met à jour imports Storybook
- Modernise le composant DsfrConsent pour utiliser defineSlots avec JSDoc - Met à jour les imports Storybook depuis 'storybook/test' vers '@storybook/test' - Améliore la documentation des slots avec JSDoc pour une meilleure DX - Corrige l'orthographe de "Évenement" en "Événement" - Ajoute defineSlots<{ default?: () => any }> avec JSDoc dans DsfrConsent.vue - Met à jour les imports avec Meta et StoryObj depuis @storybook/vue3-vite - Transforme export default en const meta avec satisfies Meta<typeof DsfrConsent> - Ajoute le type Story = StoryObj<typeof meta>
1 parent 4850d61 commit bec93ab

File tree

2 files changed

+46
-39
lines changed

2 files changed

+46
-39
lines changed
Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { fn } from 'storybook/test'
1+
import type { Meta, StoryObj } from '@storybook/vue3-vite'
2+
3+
import { fn } from '@storybook/test'
24

35
import DsfrConsent from './DsfrConsent.vue'
46

57
/**
68
* [Voir quand l’utiliser sur la documentation du DSFR](https://www.systeme-de-design.gouv.fr/version-courante/fr/composants/gestionnaire-de-consentement)
79
*/
8-
export default {
10+
const meta = {
911
component: DsfrConsent,
1012
title: 'Composants/DsfrConsent',
1113
argTypes: {
@@ -23,45 +25,40 @@ export default {
2325
description:
2426
'Url de la page concernant les "Données personnelles et cookies" sur votre site ou application.',
2527
},
26-
'accept-all': {
27-
description: 'Évenement émis lors du clic sur le bouton \'Tout accepter\'',
28-
},
29-
'refuse-all': {
30-
description: 'Évenement émis lors du clic sur le bouton \'Tout refuser\'',
31-
},
32-
customize: {
33-
description: 'Évenement émis lors du clic sur le bouton \'Personnaliser\'',
34-
},
3528
},
36-
}
29+
} satisfies Meta<typeof DsfrConsent>
3730

38-
export const GestionnaireDeConsentementSimple = (args) => ({
39-
components: { DsfrConsent },
40-
data () {
41-
return { ...args }
42-
},
43-
template: `
44-
<DsfrConsent
45-
@accept-all="onAcceptAll()"
46-
@refuse-all="onRefuseAll()"
47-
@customize="onCustomize()"
48-
:url="url"
49-
/>
50-
`,
51-
})
31+
export default meta
32+
33+
type Story = StoryObj<typeof meta>
5234

53-
GestionnaireDeConsentementSimple.args = {
54-
url: '/',
35+
export const GestionnaireDeConsentementSimple: Story = {
36+
args: {
37+
url: '/',
38+
} as any,
39+
render: (args) => ({
40+
components: { DsfrConsent },
41+
setup () {
42+
return { args }
43+
},
44+
template: `
45+
<DsfrConsent
46+
@accept-all="(args as any).onAcceptAll()"
47+
@refuse-all="(args as any).onRefuseAll()"
48+
@customize="(args as any).onCustomize()"
49+
:url="args.url"
50+
/>
51+
`,
52+
}),
5553
}
5654

57-
export const GestionnaireDeConsentementPersonnalisé = (args) => ({
58-
components: { DsfrConsent },
59-
data () {
60-
return { ...args }
61-
},
62-
template: `
63-
<DsfrConsent>
64-
Description personnalisée
65-
</DsfrConsent>
66-
`,
67-
})
55+
export const GestionnaireDeConsentementPersonnalisé: Story = {
56+
render: () => ({
57+
components: { DsfrConsent },
58+
template: `
59+
<DsfrConsent>
60+
Description personnalisée
61+
</DsfrConsent>
62+
`,
63+
}),
64+
}

src/components/DsfrConsent/DsfrConsent.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ import { computed } from 'vue'
55
66
export type { DsfrConsentProps }
77
8+
/**
9+
* Slots disponibles pour DsfrConsent
10+
*/
11+
defineSlots<{
12+
/**
13+
* Slot par défaut pour personnaliser la description du consentement
14+
*/
15+
default?: () => any
16+
}>()
17+
818
const props = withDefaults(defineProps<DsfrConsentProps>(), {
919
url: '',
1020
})

0 commit comments

Comments
 (0)