Skip to content

Commit b52f89d

Browse files
authored
Merge pull request #594 from dnum-mi/feat/maj-component-FileDownload
feat: ✨ Mise à jour du composant Téléchargement de fichier
2 parents b7684c9 + 3b4db3f commit b52f89d

File tree

3 files changed

+13
-77
lines changed

3 files changed

+13
-77
lines changed

src/components/DsfrFileDownload/DsfrFileDownload.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ import { render } from '@testing-library/vue'
33
import DsfrFileDownload from './DsfrFileDownload.vue'
44

55
describe('DsfrFileDownload', () => {
6-
it('should render a download link block', async () => {
6+
it('should render a download link', async () => {
77
const title = 'Téléchargement du fichier 1'
88
const format = 'JPEG'
99
const size = '205 Ko'
1010
const href = '#'
1111
const download = 'document.txt'
12-
const block = true
13-
const description = 'Une chouette description'
1412

1513
const { getByText } = render(DsfrFileDownload, {
1614
props: {
@@ -19,13 +17,11 @@ describe('DsfrFileDownload', () => {
1917
size,
2018
href,
2119
download,
22-
block,
23-
description,
2420
},
2521
})
2622

2723
const downloadTitle = getByText(title)
2824

29-
expect((downloadTitle).parentNode.parentNode).toHaveClass('fr-download--card')
25+
expect((downloadTitle)).toHaveClass('fr-link--download')
3026
})
3127
})

src/components/DsfrFileDownload/DsfrFileDownload.stories.ts

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,10 @@ export default {
2727
control: 'text',
2828
description: 'Nom de la ressource à télécharger',
2929
},
30-
block: {
31-
control: 'boolean',
32-
description: 'Permet de basculer le lien de téléchargement en mode block',
33-
},
34-
description: {
35-
control: 'text',
36-
description: 'Une description associée au lien disponible en mode block',
37-
},
3830
},
3931
}
4032

41-
export const TelechargementDeFichier = (args) => ({
33+
export const LienDeTelechargement = (args) => ({
4234
components: {
4335
DsfrFileDownload,
4436
},
@@ -53,51 +45,15 @@ export const TelechargementDeFichier = (args) => ({
5345
:size="size"
5446
:href="href"
5547
:download="download"
56-
:block="block"
57-
:description="description"
5848
:title="title"
5949
/>
6050
`,
6151

6252
})
63-
TelechargementDeFichier.args = {
53+
LienDeTelechargement.args = {
6454
format: 'PDF',
6555
size: '250 Go',
6656
href: 'src/assets/icone-marianne-seule.png',
6757
download: 'marianne.png',
68-
block: false,
69-
description: 'Description du téléchargement',
70-
title: 'Titre du téléchargement',
71-
}
72-
73-
export const BlocDeTelechargement = (args) => ({
74-
components: {
75-
DsfrFileDownload,
76-
},
77-
data () {
78-
return {
79-
...args,
80-
}
81-
},
82-
template: `
83-
<DsfrFileDownload
84-
:format="format"
85-
:size="size"
86-
:href="href"
87-
:download="download"
88-
:block="block"
89-
:description="description"
90-
:title="title"
91-
/>
92-
`,
93-
94-
})
95-
BlocDeTelechargement.args = {
96-
format: 'JPEG',
97-
size: '1.2 To',
98-
href: 'src/assets/icone-marianne-seule.png',
99-
download: 'marianne.png',
100-
description: 'Description du téléchargement',
10158
title: 'Titre du téléchargement',
102-
block: true,
10359
}

src/components/DsfrFileDownload/DsfrFileDownload.vue

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ export type DsfrFileDownloadProps = {
55
size?: string
66
href?: string
77
download?: string
8-
description?: string
9-
block?: boolean
108
}
119
1210
withDefaults(defineProps<DsfrFileDownloadProps>(), {
@@ -15,31 +13,17 @@ withDefaults(defineProps<DsfrFileDownloadProps>(), {
1513
size: '250 Ko',
1614
href: '#',
1715
download: '',
18-
description: '',
1916
})
2017
</script>
2118

2219
<template>
23-
<div
24-
class="fr-download"
25-
:class="{ 'fr-enlarge-link fr-download--card': block }"
26-
>
27-
<p>
28-
<a
29-
:href="href"
30-
:download="download"
31-
class="fr-download__link"
32-
> {{ title }}
33-
<span class="fr-download__detail">
34-
{{ format }} – {{ size }}
35-
</span>
36-
</a>
37-
</p>
38-
<p
39-
v-if="block"
40-
class="fr-download__desc"
41-
>
42-
{{ description }}
43-
</p>
44-
</div>
20+
<a
21+
:href="href"
22+
:download="download"
23+
class="fr-link fr-link--download"
24+
> {{ title }}
25+
<span class="fr-link__detail">
26+
{{ format }} – {{ size }}
27+
</span>
28+
</a>
4529
</template>

0 commit comments

Comments
 (0)