feat(a11y): improve focus state (#116)

This commit is contained in:
Lucie 2022-11-25 18:46:25 -05:00 committed by GitHub
parent 2cf970225f
commit 1ad3fcf20c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 56 additions and 45 deletions

View file

@ -8,6 +8,7 @@ defineProps<{
groupHover: string
active?: boolean
disabled?: boolean
as?: string
}>()
defineOptions({
@ -16,15 +17,17 @@ defineOptions({
</script>
<template>
<button
flex gap-1 items-center rounded :hover="`op100 ${hover}`" group
<component
:is="as || 'button'"
flex gap-1 items-center rounded group
:hover="`op100 ${hover}`" focus:outline-none :focus-visible="`op100 ${hover}`"
:class="active ? [color, 'op100'] : 'op50'"
v-bind="$attrs"
>
<div rounded-full p2 :group-hover="groupHover">
<div rounded-full p2 :group-hover="groupHover" :group-focus-visible="groupHover" group-focus-visible:ring="2 current">
<div :class="[active && activeIcon ? activeIcon : icon, { 'pointer-events-none': disabled }]" />
</div>
<span v-if="text">{{ text }}</span>
</button>
</component>
</template>