Added sound on hover/focus

This commit is contained in:
Alexis
2023-05-09 10:42:38 +02:00
parent 947c4b6c1f
commit 592eded221
5 changed files with 59 additions and 0 deletions

View File

@@ -1,6 +1,11 @@
<script lang="ts" setup>
import { useSound } from '@vueuse/sound'
import { computed } from 'vue'
import buttonSfx from '@/assets/sounds/btn-hover.mp3'
const { play, stop } = useSound(buttonSfx)
const props = defineProps<{
href?: string
target?: string
@@ -26,6 +31,9 @@ const elementTag = computed(() => (props.href ? 'a' : 'button'))
v-bind="attributes"
class="btn w-full p-1 px-2 text-left bg-y-beige-500 hover:shadow-md focus-visible:shadow-md"
:class="{ active: isActive }"
@focus="play"
@mouseover="play"
@mouseleave="stop"
>
<span class="mr-1" v-if="hasSquare">
<font-awesome-icon :icon="['fas', 'square']" />