mirror of
https://github.com/elk-zone/elk.git
synced 2025-03-28 20:41:20 +03:00
fix(a11y): settings items without href
This commit is contained in:
parent
25fb7c1c97
commit
2dc2c34a74
2 changed files with 33 additions and 5 deletions
|
@ -11,11 +11,28 @@ const props = defineProps<{
|
||||||
large?: true
|
large?: true
|
||||||
match?: boolean
|
match?: boolean
|
||||||
target?: string
|
target?: string
|
||||||
|
button?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
|
defineEmits<{
|
||||||
|
(event: 'click'): void
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const vm = getCurrentInstance()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const scrollOnClick = computed(() => props.to && !(props.target === '_blank' || props.external))
|
const scrollOnClick = computed(() => props.to && !(props.target === '_blank' || props.external))
|
||||||
|
|
||||||
|
function focus() {
|
||||||
|
setTimeout(() => {
|
||||||
|
if (props.button)
|
||||||
|
vm?.vnode.el?.querySelector('button')?.focus()
|
||||||
|
else
|
||||||
|
vm?.vnode.el?.focus()
|
||||||
|
}, 100)
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({ focus })
|
||||||
|
|
||||||
useCommand({
|
useCommand({
|
||||||
scope: 'Settings',
|
scope: 'Settings',
|
||||||
|
|
||||||
|
@ -45,13 +62,17 @@ useCommand({
|
||||||
exact-active-class="text-primary"
|
exact-active-class="text-primary"
|
||||||
:class="disabled ? 'op25 pointer-events-none ' : match ? 'text-primary' : ''"
|
:class="disabled ? 'op25 pointer-events-none ' : match ? 'text-primary' : ''"
|
||||||
block w-full group focus:outline-none
|
block w-full group focus:outline-none
|
||||||
:tabindex="disabled ? -1 : null"
|
:tabindex="!button && disabled ? -1 : undefined"
|
||||||
|
:custom="button"
|
||||||
@click="scrollOnClick ? $scrollToTop() : undefined"
|
@click="scrollOnClick ? $scrollToTop() : undefined"
|
||||||
>
|
>
|
||||||
<div
|
<component
|
||||||
|
:is="button ? 'button' : 'div'"
|
||||||
w-full flex px5 py3 md:gap2 gap4 items-center
|
w-full flex px5 py3 md:gap2 gap4 items-center
|
||||||
transition-250 group-hover:bg-active
|
transition-250 group-hover:bg-active
|
||||||
group-focus-visible:ring="2 current"
|
group-focus-visible:ring="2 current"
|
||||||
|
:disabled="button ? disabled : undefined"
|
||||||
|
@click="button && !disabled && $emit('click')"
|
||||||
>
|
>
|
||||||
<div flex-1 flex items-center md:gap2 gap4>
|
<div flex-1 flex items-center md:gap2 gap4>
|
||||||
<div
|
<div
|
||||||
|
@ -85,6 +106,6 @@ useCommand({
|
||||||
</slot>
|
</slot>
|
||||||
</p>
|
</p>
|
||||||
<div v-if="to" :class="!external ? 'i-ri:arrow-right-s-line' : 'i-ri:external-link-line'" text-xl text-secondary-light class="rtl-flip" />
|
<div v-if="to" :class="!external ? 'i-ri:arrow-right-s-line' : 'i-ri:external-link-line'" text-xl text-secondary-light class="rtl-flip" />
|
||||||
</div>
|
</component>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -6,12 +6,14 @@ useHydratedHead({
|
||||||
title: () => `${t('settings.about.label')} | ${t('nav.settings')}`,
|
title: () => `${t('settings.about.label')} | ${t('nav.settings')}`,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const commitRef = ref()
|
||||||
const showCommit = ref(buildInfo.env !== 'release' && buildInfo.env !== 'dev')
|
const showCommit = ref(buildInfo.env !== 'release' && buildInfo.env !== 'dev')
|
||||||
const builtTime = useFormattedDateTime(buildInfo.time)
|
const builtTime = useFormattedDateTime(buildInfo.time)
|
||||||
|
|
||||||
function handleShowCommit() {
|
function handleShowCommit() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
showCommit.value = true
|
showCommit.value = true
|
||||||
|
nextTick(() => commitRef.value?.focus())
|
||||||
}, 50)
|
}, 50)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -33,9 +35,12 @@ function handleShowCommit() {
|
||||||
|
|
||||||
<template v-if="isHydrated">
|
<template v-if="isHydrated">
|
||||||
<SettingsItem
|
<SettingsItem
|
||||||
|
ref="commitRef"
|
||||||
:text="$t('settings.about.version')"
|
:text="$t('settings.about.version')"
|
||||||
:to="showCommit ? `https://github.com/elk-zone/elk/commit/${buildInfo.commit}` : undefined"
|
:to="showCommit ? `https://github.com/elk-zone/elk/commit/${buildInfo.commit}` : undefined"
|
||||||
external target="_blank"
|
external
|
||||||
|
target="_blank"
|
||||||
|
:button="!showCommit"
|
||||||
@click="handleShowCommit"
|
@click="handleShowCommit"
|
||||||
>
|
>
|
||||||
<template #content>
|
<template #content>
|
||||||
|
@ -54,7 +59,9 @@ function handleShowCommit() {
|
||||||
<SettingsItem
|
<SettingsItem
|
||||||
:text="$t('nav.show_intro')"
|
:text="$t('nav.show_intro')"
|
||||||
icon="i-ri:article-line"
|
icon="i-ri:article-line"
|
||||||
cursor-pointer large
|
cursor-pointer
|
||||||
|
large
|
||||||
|
button
|
||||||
@click="openPreviewHelp"
|
@click="openPreviewHelp"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue