Skip to content

Commit 918216d

Browse files
committed
feat: ✨ add download props for DsfrFileDownload
1 parent 02399b6 commit 918216d

File tree

6 files changed

+23
-2
lines changed

6 files changed

+23
-2
lines changed

src/components/DsfrFileDownload/DsfrFileDownload.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ describe('DsfrFileDownload', () => {
88
const format = 'JPEG'
99
const size = '205 Ko'
1010
const href = '#'
11+
const download = 'document.txt'
1112
const block = true
1213
const description = 'Une chouette description'
1314

@@ -17,6 +18,7 @@ describe('DsfrFileDownload', () => {
1718
format,
1819
size,
1920
href,
21+
download,
2022
block,
2123
description,
2224
},

src/components/DsfrFileDownload/DsfrFileDownload.stories.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ export default {
2323
control: 'text',
2424
description: 'Chemin vers la ressource à télécharger',
2525
},
26+
download: {
27+
control: 'text',
28+
description: 'Nom de la ressource à télécharger',
29+
},
2630
block: {
2731
control: 'boolean',
2832
description: 'Permet de basculer le lien de téléchargement en mode block',
@@ -48,6 +52,7 @@ export const TelechargementDeFichier = (args) => ({
4852
:format="format"
4953
:size="size"
5054
:href="href"
55+
:download="download"
5156
:block="block"
5257
:description="description"
5358
:title="title"
@@ -59,6 +64,7 @@ TelechargementDeFichier.args = {
5964
format: 'PDF',
6065
size: '250 Go',
6166
href: 'src/assets/icone-marianne-seule.png',
67+
download: 'marianne.png',
6268
block: false,
6369
description: 'Description du téléchargement',
6470
title: 'Titre du téléchargement',
@@ -78,6 +84,7 @@ export const BlocDeTelechargement = (args) => ({
7884
:format="format"
7985
:size="size"
8086
:href="href"
87+
:download="download"
8188
:block="block"
8289
:description="description"
8390
:title="title"
@@ -89,6 +96,7 @@ BlocDeTelechargement.args = {
8996
format: 'JPEG',
9097
size: '1.2 To',
9198
href: 'src/assets/icone-marianne-seule.png',
99+
download: 'marianne.png',
92100
description: 'Description du téléchargement',
93101
title: 'Titre du téléchargement',
94102
block: true,

src/components/DsfrFileDownload/DsfrFileDownload.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ export default defineComponent({
2121
type: String,
2222
default: '#',
2323
},
24+
download: {
25+
type: String,
26+
default: '',
27+
},
2428
description: {
2529
type: String,
2630
default: '',
@@ -38,7 +42,7 @@ export default defineComponent({
3842
<p>
3943
<a
4044
:href="href"
41-
download
45+
:download="download"
4246
class="fr-download__link"
4347
> {{ title }}
4448
<span class="fr-download__detail">

src/components/DsfrFileDownload/DsfrFileDownloadList.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,21 @@ describe('DsfrFileDownloadList', () => {
1111
format: 'PNG',
1212
size: '250 Mo',
1313
href: '#',
14+
download: 'document1.md',
1415
},
1516
{
1617
title: 'Télécharger document 2',
1718
format: 'GIF',
1819
size: '107 Ko',
1920
href: '#',
21+
download: 'document2.md',
2022
},
2123
{
2224
title: 'Télécharger document 3',
2325
format: 'ZIP',
2426
size: '1,5 Go',
2527
href: '#',
28+
download: 'document3.md',
2629
},
2730
]
2831

src/components/DsfrFileDownload/DsfrFileDownloadList.stories.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default {
99
argTypes: {
1010
files: {
1111
control: 'object',
12-
description: 'Tableau d\'objets contenant les propriétés "title", "format", "size" et "href" propres au composant DsfrFileDownload',
12+
description: 'Tableau d\'objets contenant les propriétés "title", "format", "size", "href" et "download" propres au composant DsfrFileDownload',
1313
},
1414
title: {
1515
control: 'string',
@@ -42,18 +42,21 @@ ListeDeTelechargements.args = {
4242
format: 'PNG',
4343
size: '250 Mo',
4444
href: '#',
45+
download: 'document1.md',
4546
},
4647
{
4748
title: 'Télécharger document 2',
4849
format: 'GIF',
4950
size: '107 Ko',
5051
href: '#',
52+
download: 'document2.md',
5153
},
5254
{
5355
title: 'Télécharger document 3',
5456
format: 'ZIP',
5557
size: '1,5 Go',
5658
href: '#',
59+
download: 'document3.md',
5760
},
5861
],
5962
title: 'Titre facultatif',

src/components/DsfrFileDownload/DsfrFileDownloadList.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export default defineComponent({
3939
:format="element.format"
4040
:size="element.size"
4141
:href="element.href"
42+
:download="element.download"
4243
/>
4344
</li>
4445
</ul>

0 commit comments

Comments
 (0)