Skip to content

Commit ea2c20a

Browse files
authored
Merge pull request #309 from dnum-mi/feat/transition-dsfr-1.4.1
feat: ✨ Implémente la version 1.4.1 du DSFR
2 parents 0ae0c2d + c441bc3 commit ea2c20a

36 files changed

+436
-195
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
"vue-tsc": "vue-tsc --declaration --emitDeclarationOnly"
8383
},
8484
"dependencies": {
85-
"@gouvfr/dsfr": "^1.3.1",
85+
"@gouvfr/dsfr": "^1.4.1",
8686
"focus-trap": "^6.7.3",
8787
"focus-trap-vue": "^3.2.1",
8888
"oh-vue-icons": "^1.0.0-rc2",

src/components/DsfrAccordion/DsfrAccordion.stories.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ AccordeonDansUnAccordeon.args = {
137137
export const AccordeonTitreCustom = (args) => ({
138138
components: {
139139
DsfrAccordion,
140-
DsfrAccordionsGroup
140+
DsfrAccordionsGroup,
141141
},
142142

143143
data () {
@@ -178,5 +178,5 @@ export const AccordeonTitreCustom = (args) => ({
178178
AccordeonTitreCustom.args = {
179179
dark: false,
180180
title1: 'Un titre d’accordéon customisé',
181-
title2: 'Un autre titre d’accordéon'
181+
title2: 'Un autre titre d’accordéon',
182182
}

src/components/DsfrAccordion/DsfrAccordion.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default defineComponent({
5050
:aria-controls="id"
5151
@click="toggleExpanded()"
5252
>
53-
<!-- @slot Slot pour le contenu personnalisé du titre de l’accordéon. Une props du même nom est utilisable pour du texte simple sans mise en forme. -->
53+
<!-- @slot Slot pour le contenu personnalisé du titre de l’accordéon. Une props du même nom est utilisable pour du texte simple sans mise en forme. -->
5454
<slot name="title">
5555
<span>{{ title }}</span>
5656
</slot>

src/components/DsfrAlert/DsfrAlert.e2e.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('DsfrAlert', () => {
3333
.should('be.visible')
3434
.contains(description)
3535

36-
cy.get('.close-icon')
36+
cy.get('.fr-btn--close')
3737
.should('be.visible')
3838
})
3939

src/components/DsfrAlert/DsfrAlert.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('DsfrAlert', () => {
6363
await fireEvent.click(closeBtn)
6464

6565
// Then
66-
expect(closeBtn).toHaveClass('close-icon')
66+
expect(closeBtn).toHaveClass('fr-btn--close')
6767
expect(emitted()).toHaveProperty('close')
6868
expect(emitted().close).toHaveLength(1)
6969
})

src/components/DsfrAlert/DsfrAlert.vue

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -85,71 +85,17 @@ export default defineComponent({
8585
</div>
8686
<button
8787
v-if="closeable"
88-
class="close-icon"
88+
class="fr-btn fr-btn--close"
8989
title="Fermer"
9090
aria-label="Fermer"
9191
@click="onClick"
92-
>
93-
<VIcon
94-
scale="1"
95-
name="ri-close-line"
96-
/>
97-
</button>
92+
/>
9893
</div>
9994
</transition>
10095
</template>
10196

10297
<style src="@gouvfr/dsfr/dist/component/alert/alert.main.min.css" />
10398

10499
<style scoped>
105-
.fr-alert,
106-
.close-icon {
107-
color: var(--text-default-grey);
108-
}
109100
110-
.fr-alert--info::before,
111-
.fr-alert--warning::before,
112-
.fr-alert--success::before,
113-
.fr-alert--error::before
114-
{
115-
height: 40px;
116-
}
117-
.fr-alert--sm {
118-
padding: .575rem 2.25rem .75rem 3.5rem;
119-
height: 40px;
120-
& .fr-alert__description {
121-
margin: 0;
122-
}
123-
}
124-
125-
.alert-content {
126-
display: flex;
127-
flex-direction: column;
128-
}
129-
.close-icon {
130-
position: absolute;
131-
top: 0.25rem;
132-
right: 0.25rem;
133-
width: 2rem;
134-
height: 2rem;
135-
136-
&:hover {
137-
border-radius: 1rem;
138-
}
139-
}
140-
141-
/* Enter and leave animations can use different */
142-
/* durations and timing functions. */
143-
/* .slide-fade-enter-active {
144-
transition: all 0.5s ease-out;
145-
}
146-
.slide-fade-leave-active {
147-
transition: all 0.5s cubic-bezier(1, 0.5, 0.8, 1);
148-
}
149-
.slide-fade-enter-from,
150-
.slide-fade-leave-to {
151-
transform: translateY(-100%);
152-
opacity: 0;
153-
}
154-
*/
155101
</style>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { render } from '@testing-library/vue'
2+
// import '@gouvfr/dsfr/dist/core/core.module.js'
3+
4+
import DsfrBadge from './DsfrBadge.vue'
5+
6+
describe('DsfrBadge', () => {
7+
it('should render a success badge', async () => {
8+
const label = 'Succès'
9+
const type = 'success'
10+
11+
const { getByText } = render(DsfrBadge, {
12+
props: {
13+
label,
14+
type,
15+
},
16+
})
17+
18+
const badge = getByText(label).parentElement
19+
20+
expect(badge).toHaveClass('fr-badge')
21+
expect(badge).not.toHaveClass('fr-badge--sm')
22+
expect(badge).toHaveClass(`fr-badge--${type}`)
23+
})
24+
25+
it('should render a small error badge', async () => {
26+
const label = 'Error'
27+
const type = 'error'
28+
29+
const { getByText } = render(DsfrBadge, {
30+
props: {
31+
label,
32+
type,
33+
small: true,
34+
},
35+
})
36+
37+
const badge = getByText(label).parentElement
38+
39+
expect(badge).toHaveClass('fr-badge')
40+
expect(badge).toHaveClass('fr-badge--sm')
41+
expect(badge).toHaveClass(`fr-badge--${type}`)
42+
})
43+
})
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<script setup>
2+
defineProps({
3+
label: {
4+
type: String,
5+
default: '',
6+
},
7+
type: {
8+
type: String,
9+
default: undefined,
10+
validator: value => ['success', 'error', 'new', 'info', 'warning', undefined].includes(value),
11+
},
12+
noIcon: Boolean,
13+
small: Boolean,
14+
ellipsis: Boolean,
15+
})
16+
</script>
17+
18+
<template>
19+
<p
20+
class="fr-badge"
21+
:class="{
22+
[`fr-badge--${type}`]: type,
23+
'fr-badge--no-icon': noIcon,
24+
'fr-badge--sm': small,
25+
}"
26+
>
27+
<span :class="ellipsis ? 'fr-ellipsis' : ''">
28+
{{ label }}
29+
</span>
30+
</p>
31+
</template>
32+
33+
<style src="@gouvfr/dsfr/dist/component/badge/badge.main.min.css" />

0 commit comments

Comments
 (0)