Skip to content

Commit 1762480

Browse files
committed
refactor(DsfrFileDownloadList): ♻️ convertit les stories au format CSF3
## Pourquoi les changements ont été faits : - migration vers Storybook 9 avec format CSF3 - remplacement de l'Options API par la Composition API - amélioration du typage TypeScript ## Quelles modifications ont été apportées : - convertit la meta definition avec Meta<typeof DsfrFileDownloadList> - convertit la story ListeDeTelechargements au format StoryObj - utilise setup() avec return { args } au lieu de data() - déplace les args dans la propriété args de l'objet Story
1 parent bb76da8 commit 1762480

File tree

1 file changed

+45
-42
lines changed

1 file changed

+45
-42
lines changed
Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import type { Meta, StoryObj } from '@storybook/vue3'
2+
13
import DsfrFileDownloadList from './DsfrFileDownloadList.vue'
24

35
/**
4-
* [Voir quand lutiliser sur la documentation du DSFR](https://www.systeme-de-design.gouv.fr/version-courante/fr/composants/telechargement-de-fichier)
6+
* [Voir quand l'utiliser sur la documentation du DSFR](https://www.systeme-de-design.gouv.fr/version-courante/fr/composants/telechargement-de-fichier)
57
*/
6-
export default {
8+
const meta = {
79
component: DsfrFileDownloadList,
810
title: 'Composants/DsfrFileDownloadList',
911
argTypes: {
@@ -18,47 +20,48 @@ export default {
1820
'Chaîne de caractères optionnelle permettant d\'ajouter un titre à la liste des liens de téléchargement',
1921
},
2022
},
21-
}
23+
} as Meta<typeof DsfrFileDownloadList>
2224

23-
export const ListeDeTelechargements = (args) => ({
24-
components: {
25-
DsfrFileDownloadList,
26-
},
27-
data () {
28-
return {
29-
...args,
30-
}
25+
export default meta
26+
type Story = StoryObj<typeof meta>
27+
28+
export const ListeDeTelechargements: Story = {
29+
args: {
30+
files: [
31+
{
32+
title: 'Télécharger document 1',
33+
format: 'PNG',
34+
size: '250 Mo',
35+
href: '#',
36+
download: 'document1.md',
37+
},
38+
{
39+
title: 'Télécharger document 2',
40+
format: 'GIF',
41+
size: '107 Ko',
42+
href: '#',
43+
download: 'document2.md',
44+
},
45+
{
46+
title: 'Télécharger document 3',
47+
format: 'ZIP',
48+
size: '1,5 Go',
49+
href: '#',
50+
download: 'document3.md',
51+
},
52+
],
53+
title: 'Titre facultatif',
3154
},
32-
template: `
33-
<DsfrFileDownloadList
34-
:files="files"
35-
:title="title"
36-
/>
37-
`,
38-
})
39-
ListeDeTelechargements.args = {
40-
files: [
41-
{
42-
title: 'Télécharger document 1',
43-
format: 'PNG',
44-
size: '250 Mo',
45-
href: '#',
46-
download: 'document1.md',
47-
},
48-
{
49-
title: 'Télécharger document 2',
50-
format: 'GIF',
51-
size: '107 Ko',
52-
href: '#',
53-
download: 'document2.md',
54-
},
55-
{
56-
title: 'Télécharger document 3',
57-
format: 'ZIP',
58-
size: '1,5 Go',
59-
href: '#',
60-
download: 'document3.md',
55+
render: (args) => ({
56+
components: { DsfrFileDownloadList },
57+
setup () {
58+
return { args }
6159
},
62-
],
63-
title: 'Titre facultatif',
60+
template: `
61+
<DsfrFileDownloadList
62+
:files="args.files"
63+
:title="args.title"
64+
/>
65+
`,
66+
}),
6467
}

0 commit comments

Comments
 (0)