Skip to content

Commit

Permalink
feat: ✨ composant tooltip fonctionnel avec js du dsfr
Browse files Browse the repository at this point in the history
  • Loading branch information
DaBadBunny committed Dec 20, 2023
1 parent d71bec7 commit 2a2e5b3
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions src/components/DsfrTooltip/DsfrTooltip.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { getRandomId } from '../../utils/random-utils'
import { ref } from 'vue'
import '@gouvfr/dsfr/dist/core/core.module.min.js'
import '@gouvfr/dsfr/dist/component/tooltip/tooltip.module.min.js'
withDefaults(defineProps<{
content: string
Expand All @@ -11,19 +12,11 @@ withDefaults(defineProps<{
content: '',
id: () => getRandomId('tooltip'),
})
const showToolTip = ref(false)
function toggleToolTip () {
showToolTip.value = !showToolTip.value
}
</script>

<template>
<div
v-if="onHover"
@mouseover="toggleToolTip()"
@mouseout="toggleToolTip()"
>
<a
:id="'link-' + id"
Expand All @@ -35,10 +28,7 @@ function toggleToolTip () {
</a>
<span
:id="id"
class="fr-tooltip fr-placement fr-placement--top fr-placement--center fr-tooltype-style"
:class="{
'fr-tooltip--shown': showToolTip
}"
class="fr-tooltip fr-placement fr-tooltype-style"
role="tooltip"
aria-hidden="true"
>
Expand All @@ -48,7 +38,6 @@ function toggleToolTip () {

<div
v-if="onClick"
@click="toggleToolTip()"
>
<button
:id="'button-' + id"
Expand All @@ -57,10 +46,7 @@ function toggleToolTip () {
/>
<span
:id="id"
class="fr-tooltip fr-placement fr-placement--top fr-placement--center fr-tooltype-style"
:class="{
'fr-tooltip--shown': showToolTip
}"
class="fr-tooltip fr-placement fr-tooltype-style"
role="tooltip"
aria-hidden="true"
>
Expand Down

0 comments on commit 2a2e5b3

Please sign in to comment.