Skip to content

Commit cef8f12

Browse files
committed
chore(demo-app): 📝 Ajoute un exemple d'utilisation de DsfrModal
1 parent be1cc9d commit cef8f12

File tree

3 files changed

+66
-10
lines changed

3 files changed

+66
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"build": "run-p build:css build:js",
1919
"build:css": "node build-css.mjs",
2020
"build:js": "cross-env NODE_ENV=production rollup --config rollup.config.js",
21-
"serve": "vite preview",
21+
"demo-app": "vite",
2222
"test": "jest",
2323
"format": "npm run lint -- --fix",
2424
"lint": "eslint ./src/**/*.{vue,js,jsx,ts,tsx}",

src/App.vue

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,74 @@
1+
<script setup>
2+
import { ref } from 'vue'
3+
4+
const isModalOpen = ref(false)
5+
const displayAlert = ref(false)
6+
const close = () => {
7+
displayAlert.value = false
8+
setTimeout(
9+
() => { isModalOpen.value = false },
10+
1000,
11+
)
12+
}
13+
14+
const actions = [
15+
{
16+
label: 'Valider',
17+
onClick: () => {
18+
displayAlert.value = true
19+
setTimeout(
20+
close,
21+
2000,
22+
)
23+
},
24+
},
25+
{
26+
label: 'Annuler',
27+
secondary: true,
28+
onClick: () => { isModalOpen.value = false },
29+
},
30+
]
31+
32+
</script>
33+
134
<template>
235
<div>
3-
App
36+
<h1>App</h1>
37+
<DsfrButton
38+
class="m1"
39+
@click="isModalOpen = true"
40+
>
41+
Open modal
42+
</DsfrButton>
43+
<teleport to="body">
44+
<DsfrModal
45+
v-if="isModalOpen"
46+
:opened="isModalOpen"
47+
:actions="actions"
48+
@close="isModalOpen = false"
49+
>
50+
<DsfrAlert
51+
:closed="!displayAlert"
52+
type="success"
53+
sm
54+
description="Opération terminée avec succès"
55+
/>
56+
Ceci est une modale. Elle peut se fermer sans aucun changement au clic sur le bouton "Fermer" ou bien simplement avec la touche <kbd>Échappe</kbd>
57+
</DsfrModal>
58+
</teleport>
459
</div>
560
</template>
661

7-
<script>
8-
export default {
9-
name: 'App',
10-
}
11-
</script>
12-
1362
<style>
1463
#app {
15-
font-family: Avenir, Helvetica, Arial, sans-serif;
1664
-webkit-font-smoothing: antialiased;
1765
-moz-osx-font-smoothing: grayscale;
1866
text-align: center;
1967
color: #2c3e50;
2068
margin-top: 60px;
2169
}
70+
71+
.m1 {
72+
margin: 0.5rem;
73+
}
2274
</style>

src/main.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ import {
44
RiCheckboxCircleLine,
55
} from 'oh-vue-icons/icons'
66

7+
import './main.css'
8+
import './assets/fonts-dsfr.css'
9+
import VueDsfr from './index.js'
10+
711
import App from './App.vue'
812

913
OhVueIcon.add(
1014
RiCheckboxCircleLine,
1115
)
1216

1317
createApp(App)
14-
.component('v-icon', OhVueIcon)
18+
.use(VueDsfr)
1519
.mount('#app')

0 commit comments

Comments
 (0)