From 64d1c11eae111e38fb6716fcdd134a311d398fd3 Mon Sep 17 00:00:00 2001 From: DaBadBunny Date: Tue, 29 Aug 2023 16:01:43 +0200 Subject: [PATCH] feat: :sparkles: Nouveau composant Bulle d'aide --- .vitepress/config.ts | 4 +- .vitepress/theme/style.css | 14 +- docs/_frame.md | 2 +- src/components/DsfrTooltip/DsfrTooltip.md | 48 ++++++ .../DsfrTooltip/DsfrTooltip.stories.ts | 95 ++++++++++++ src/components/DsfrTooltip/DsfrTooltip.vue | 142 ++++++++++++++++++ .../docs-demo/DsfrTooltipExample.vue | 37 +++++ 7 files changed, 338 insertions(+), 4 deletions(-) create mode 100644 src/components/DsfrTooltip/DsfrTooltip.md create mode 100644 src/components/DsfrTooltip/DsfrTooltip.stories.ts create mode 100644 src/components/DsfrTooltip/DsfrTooltip.vue create mode 100644 src/components/DsfrTooltip/docs-demo/DsfrTooltipExample.vue diff --git a/.vitepress/config.ts b/.vitepress/config.ts index ae8cf311..fde6cd4b 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -118,8 +118,8 @@ export default defineConfig({ link: '/composants/DsfrSegmented.md', }, { - text: 'DsfrSegmentedSet', - link: '/composants/DsfrSegmentedSet.md', + text: 'DsfrTooltip', + link: '/composants/DsfrTooltip.md', }, ] }, diff --git a/.vitepress/theme/style.css b/.vitepress/theme/style.css index a5cd579c..9a4ca893 100644 --- a/.vitepress/theme/style.css +++ b/.vitepress/theme/style.css @@ -7,7 +7,7 @@ * Colors * -------------------------------------------------------------------------- */ -@font-face { + @font-face { font-family: Marianne; src: url("@gouvfr/dsfr/dist/fonts/Marianne-Light.woff2") format("woff2"), url("@gouvfr/dsfr/dist/fonts/Marianne-Light.woff") format("woff"); font-weight: 300; @@ -190,3 +190,15 @@ .w-full { width: 100%; } + +.h-full { + width: 100%; +} + +.flex { + display: flex; +} + +.flex-end { + justify-content: flex-end; +} diff --git a/docs/_frame.md b/docs/_frame.md index f6d85047..c7fff87c 100644 --- a/docs/_frame.md +++ b/docs/_frame.md @@ -2,7 +2,7 @@ layout: false --- -
+
diff --git a/src/components/DsfrTooltip/DsfrTooltip.stories.ts b/src/components/DsfrTooltip/DsfrTooltip.stories.ts new file mode 100644 index 00000000..838dcbec --- /dev/null +++ b/src/components/DsfrTooltip/DsfrTooltip.stories.ts @@ -0,0 +1,95 @@ +import DsfrTooltip from './DsfrTooltip.vue' +export default { + component: DsfrTooltip, + title: 'Composants/DsfrTooltip', + argTypes: { + id: { + control: 'text', + description: '(optionnel) Valeur de l’attribut `id` du tooltip. Par dĂ©faut, un id pseudo-alĂ©atoire sera donnĂ©.', + }, + content: { + control: 'text', + description: 'Contenu de votre bulle d’aide : il s’agit d’un texte sans mise en forme.', + }, + onHover: { + control: 'boolean', + description: 'Permet de dĂ©finir si l’infobulle doit s’afficher au survol de l’élĂ©ment (`true`) ou au clic (`false`, dĂ©faut).', + }, + }, +} + +export const Infobulle = (args) => ({ + components: { + DsfrTooltip, + }, + + data () { + return { + ...args, + } + }, + + template: ` + + Un Ă©lĂ©ment intriguant + + `, + +}) +Infobulle.args = { + content: 'Un Ă©lĂ©ment assez intriguant', + onHover: false, +} + +export const InfobulleParDefaut = (args) => ({ + components: { + DsfrTooltip, + }, + + data () { + return { + ...args, + } + }, + + template: ` + + Un contenu qui n’apparaĂźtra que si hover est Ă  \`true\` + + `, + +}) +InfobulleParDefaut.args = { + content: 'Un Ă©lĂ©ment assez intriguant', +} + +export const InfobulleAuSurvol = (args) => ({ + components: { + DsfrTooltip, + }, + + data () { + return { + ...args, + } + }, + + template: ` + Du texte + + avec une prĂ©cision Ă  donner ici + + `, + +}) +InfobulleAuSurvol.args = { + content: 'Texte prĂ©cisant pourquoi ce texte est lĂ ', +} diff --git a/src/components/DsfrTooltip/DsfrTooltip.vue b/src/components/DsfrTooltip/DsfrTooltip.vue new file mode 100644 index 00000000..b109b6a6 --- /dev/null +++ b/src/components/DsfrTooltip/DsfrTooltip.vue @@ -0,0 +1,142 @@ + + + + + diff --git a/src/components/DsfrTooltip/docs-demo/DsfrTooltipExample.vue b/src/components/DsfrTooltip/docs-demo/DsfrTooltipExample.vue new file mode 100644 index 00000000..bd21f461 --- /dev/null +++ b/src/components/DsfrTooltip/docs-demo/DsfrTooltipExample.vue @@ -0,0 +1,37 @@ + + +