chore(a11y): improve component roles

This commit is contained in:
liyasthomas
2022-03-01 12:11:53 +05:30
parent b3d0d4d86b
commit 9bd55b6db5
39 changed files with 498 additions and 420 deletions

View File

@@ -1,6 +1,7 @@
<template> <template>
<div <div
class="relative flex items-center px-4 py-2 transition bg-error text-tiny group" class="relative flex items-center px-4 py-2 transition bg-error text-tiny group"
role="alert"
> >
<i class="mr-2 material-icons">info_outline</i> <i class="mr-2 material-icons">info_outline</i>
<span class="text-secondaryDark"> <span class="text-secondaryDark">

View File

@@ -59,6 +59,7 @@
ref="tippyActions" ref="tippyActions"
class="flex flex-col focus:outline-none" class="flex flex-col focus:outline-none"
tabindex="0" tabindex="0"
role="menu"
@keyup.d="documentation.$el.click()" @keyup.d="documentation.$el.click()"
@keyup.s="shortcuts.$el.click()" @keyup.s="shortcuts.$el.click()"
@keyup.c="chat.$el.click()" @keyup.c="chat.$el.click()"

View File

@@ -87,7 +87,7 @@
svg="user" svg="user"
/> />
</template> </template>
<div class="flex flex-col px-2 text-tiny"> <div class="flex flex-col px-2 text-tiny" role="menu">
<span class="inline-flex font-semibold truncate"> <span class="inline-flex font-semibold truncate">
{{ currentUser.displayName }} {{ currentUser.displayName }}
</span> </span>

View File

@@ -1,6 +1,8 @@
<template> <template>
<aside class="flex justify-between h-full md:flex-col"> <aside class="flex justify-between h-full md:flex-col">
<nav class="flex flex-1 flex-nowrap md:flex-col md:flex-none"> <nav class="flex flex-1 flex-nowrap md:flex-col md:flex-none">
<ul>
<li>
<NuxtLink <NuxtLink
v-for="(navigation, index) in primaryNavigation" v-for="(navigation, index) in primaryNavigation"
:key="`navigation-${index}`" :key="`navigation-${index}`"
@@ -19,6 +21,8 @@
:content="navigation.title" :content="navigation.title"
/> />
</NuxtLink> </NuxtLink>
</li>
</ul>
</nav> </nav>
</aside> </aside>
</template> </template>

View File

@@ -26,6 +26,7 @@
:disabled="disabled" :disabled="disabled"
:tabindex="loading ? '-1' : '0'" :tabindex="loading ? '-1' : '0'"
:type="type" :type="type"
role="button"
> >
<span <span
v-if="!loading" v-if="!loading"

View File

@@ -25,6 +25,7 @@
]" ]"
:disabled="disabled" :disabled="disabled"
:tabindex="loading ? '-1' : '0'" :tabindex="loading ? '-1' : '0'"
role="button"
> >
<span <span
v-if="!loading" v-if="!loading"

View File

@@ -39,6 +39,7 @@
/> />
</span> </span>
</template> </template>
<div class="flex flex-col" role="menu">
<SmartItem <SmartItem
v-for="(team, index) in myTeams" v-for="(team, index) in myTeams"
:key="`team-${index}`" :key="`team-${index}`"
@@ -55,6 +56,7 @@
} }
" "
/> />
</div>
</tippy> </tippy>
</SmartIntersection> </SmartIntersection>
</SmartTab> </SmartTab>

View File

@@ -60,6 +60,7 @@
ref="tippyActions" ref="tippyActions"
class="flex flex-col focus:outline-none" class="flex flex-col focus:outline-none"
tabindex="0" tabindex="0"
role="menu"
@keyup.n="folderAction.$el.click()" @keyup.n="folderAction.$el.click()"
@keyup.e="edit.$el.click()" @keyup.e="edit.$el.click()"
@keyup.delete="deleteAction.$el.click()" @keyup.delete="deleteAction.$el.click()"

View File

@@ -56,6 +56,7 @@
ref="tippyActions" ref="tippyActions"
class="flex flex-col focus:outline-none" class="flex flex-col focus:outline-none"
tabindex="0" tabindex="0"
role="menu"
@keyup.n="folderAction.$el.click()" @keyup.n="folderAction.$el.click()"
@keyup.e="edit.$el.click()" @keyup.e="edit.$el.click()"
@keyup.delete="deleteAction.$el.click()" @keyup.delete="deleteAction.$el.click()"

View File

@@ -16,6 +16,7 @@
svg="more-vertical" svg="more-vertical"
/> />
</template> </template>
<div class="flex flex-col" role="menu">
<SmartItem <SmartItem
icon="assignment_returned" icon="assignment_returned"
:label="t('import.from_gist')" :label="t('import.from_gist')"
@@ -54,6 +55,7 @@
" "
/> />
</span> </span>
</div>
</tippy> </tippy>
</span> </span>
</template> </template>

View File

@@ -56,6 +56,7 @@
ref="tippyActions" ref="tippyActions"
class="flex flex-col focus:outline-none" class="flex flex-col focus:outline-none"
tabindex="0" tabindex="0"
role="menu"
@keyup.e="edit.$el.click()" @keyup.e="edit.$el.click()"
@keyup.d="duplicate.$el.click()" @keyup.d="duplicate.$el.click()"
@keyup.delete="deleteAction.$el.click()" @keyup.delete="deleteAction.$el.click()"

View File

@@ -78,6 +78,7 @@
ref="tippyActions" ref="tippyActions"
class="flex flex-col focus:outline-none" class="flex flex-col focus:outline-none"
tabindex="0" tabindex="0"
role="menu"
@keyup.n="folderAction.$el.click()" @keyup.n="folderAction.$el.click()"
@keyup.e="edit.$el.click()" @keyup.e="edit.$el.click()"
@keyup.delete="deleteAction.$el.click()" @keyup.delete="deleteAction.$el.click()"

View File

@@ -56,6 +56,7 @@
ref="tippyActions" ref="tippyActions"
class="flex flex-col focus:outline-none" class="flex flex-col focus:outline-none"
tabindex="0" tabindex="0"
role="menu"
@keyup.n="folderAction.$el.click()" @keyup.n="folderAction.$el.click()"
@keyup.e="edit.$el.click()" @keyup.e="edit.$el.click()"
@keyup.delete="deleteAction.$el.click()" @keyup.delete="deleteAction.$el.click()"

View File

@@ -80,6 +80,7 @@
ref="tippyActions" ref="tippyActions"
class="flex flex-col focus:outline-none" class="flex flex-col focus:outline-none"
tabindex="0" tabindex="0"
role="menu"
@keyup.e="edit.$el.click()" @keyup.e="edit.$el.click()"
@keyup.d="duplicate.$el.click()" @keyup.d="duplicate.$el.click()"
@keyup.delete="deleteAction.$el.click()" @keyup.delete="deleteAction.$el.click()"

View File

@@ -79,6 +79,7 @@
ref="tippyActions" ref="tippyActions"
class="flex flex-col focus:outline-none" class="flex flex-col focus:outline-none"
tabindex="0" tabindex="0"
role="menu"
@keyup.n="folderAction.$el.click()" @keyup.n="folderAction.$el.click()"
@keyup.e="edit.$el.click()" @keyup.e="edit.$el.click()"
@keyup.delete="deleteAction.$el.click()" @keyup.delete="deleteAction.$el.click()"

View File

@@ -58,6 +58,7 @@
ref="tippyActions" ref="tippyActions"
class="flex flex-col focus:outline-none" class="flex flex-col focus:outline-none"
tabindex="0" tabindex="0"
role="menu"
@keyup.n="folderAction.$el.click()" @keyup.n="folderAction.$el.click()"
@keyup.e="edit.$el.click()" @keyup.e="edit.$el.click()"
@keyup.delete="deleteAction.$el.click()" @keyup.delete="deleteAction.$el.click()"

View File

@@ -80,6 +80,7 @@
ref="tippyActions" ref="tippyActions"
class="flex flex-col focus:outline-none" class="flex flex-col focus:outline-none"
tabindex="0" tabindex="0"
role="menu"
@keyup.e="edit.$el.click()" @keyup.e="edit.$el.click()"
@keyup.d="duplicate.$el.click()" @keyup.d="duplicate.$el.click()"
@keyup.delete="deleteAction.$el.click()" @keyup.delete="deleteAction.$el.click()"

View File

@@ -37,6 +37,7 @@
ref="tippyActions" ref="tippyActions"
class="flex flex-col focus:outline-none" class="flex flex-col focus:outline-none"
tabindex="0" tabindex="0"
role="menu"
@keyup.e="edit.$el.click()" @keyup.e="edit.$el.click()"
@keyup.d="duplicate.$el.click()" @keyup.d="duplicate.$el.click()"
@keyup.delete=" @keyup.delete="

View File

@@ -16,6 +16,7 @@
svg="more-vertical" svg="more-vertical"
/> />
</template> </template>
<div class="flex flex-col" role="menu">
<SmartItem <SmartItem
icon="assignment_returned" icon="assignment_returned"
:label="t('import.from_gist')" :label="t('import.from_gist')"
@@ -54,6 +55,7 @@
" "
/> />
</span> </span>
</div>
</tippy> </tippy>
</span> </span>
</template> </template>

View File

@@ -20,6 +20,7 @@
/> />
</span> </span>
</template> </template>
<div class="flex flex-col" role="menu">
<SmartItem <SmartItem
:label="`${$t('environment.no_environment')}`" :label="`${$t('environment.no_environment')}`"
:info-icon="selectedEnvironmentIndex === -1 ? 'done' : ''" :info-icon="selectedEnvironmentIndex === -1 ? 'done' : ''"
@@ -45,6 +46,7 @@
} }
" "
/> />
</div>
</tippy> </tippy>
<div class="flex justify-between flex-1 border-b border-dividerLight"> <div class="flex justify-between flex-1 border-b border-dividerLight">
<ButtonSecondary <ButtonSecondary

View File

@@ -22,6 +22,7 @@
/> />
</span> </span>
</template> </template>
<div class="flex flex-col" role="menu">
<SmartItem <SmartItem
label="None" label="None"
:icon=" :icon="
@@ -97,6 +98,7 @@
} }
" "
/> />
</div>
</tippy> </tippy>
</span> </span>
<div class="flex"> <div class="flex">
@@ -204,6 +206,7 @@
/> />
</span> </span>
</template> </template>
<div class="flex flex-col" role="menu">
<SmartItem <SmartItem
:icon=" :icon="
addTo === 'Headers' addTo === 'Headers'
@@ -234,6 +237,7 @@
} }
" "
/> />
</div>
</tippy> </tippy>
</div> </div>
</div> </div>

View File

@@ -22,6 +22,7 @@
/> />
</span> </span>
</template> </template>
<div class="flex flex-col" role="menu">
<SmartItem <SmartItem
:label="$t('state.none').toLowerCase()" :label="$t('state.none').toLowerCase()"
:info-icon="contentType === null ? 'done' : ''" :info-icon="contentType === null ? 'done' : ''"
@@ -46,6 +47,7 @@
} }
" "
/> />
</div>
</tippy> </tippy>
</span> </span>
</div> </div>

View File

@@ -31,7 +31,7 @@
:placeholder="`${t('action.search')}`" :placeholder="`${t('action.search')}`"
/> />
</div> </div>
<div class="flex flex-col"> <div class="flex flex-col" role="menu">
<SmartItem <SmartItem
v-for="codegen in filteredCodegenDefinitions" v-for="codegen in filteredCodegenDefinitions"
:key="codegen.name" :key="codegen.name"

View File

@@ -26,12 +26,14 @@
/> />
</span> </span>
</template> </template>
<div class="flex flex-col" role="menu">
<SmartItem <SmartItem
v-for="(method, index) in methods" v-for="(method, index) in methods"
:key="`method-${index}`" :key="`method-${index}`"
:label="method" :label="method"
@click.native="onSelectMethod(method)" @click.native="onSelectMethod(method)"
/> />
</div>
</tippy> </tippy>
</label> </label>
</div> </div>
@@ -69,6 +71,7 @@
ref="sendTippyActions" ref="sendTippyActions"
class="flex flex-col focus:outline-none" class="flex flex-col focus:outline-none"
tabindex="0" tabindex="0"
role="menu"
@keyup.c="curl.$el.click()" @keyup.c="curl.$el.click()"
@keyup.s="show.$el.click()" @keyup.s="show.$el.click()"
@keyup.delete="clearAll.$el.click()" @keyup.delete="clearAll.$el.click()"
@@ -150,6 +153,7 @@
ref="saveTippyActions" ref="saveTippyActions"
class="flex flex-col focus:outline-none" class="flex flex-col focus:outline-none"
tabindex="0" tabindex="0"
role="menu"
@keyup.c="copyRequestAction.$el.click()" @keyup.c="copyRequestAction.$el.click()"
@keyup.s="saveRequestAction.$el.click()" @keyup.s="saveRequestAction.$el.click()"
@keyup.escape="saveOptions.tippy().hide()" @keyup.escape="saveOptions.tippy().hide()"

View File

@@ -37,6 +37,7 @@
<div <div
v-if="noEnvSelected && !globalHasAdditions" v-if="noEnvSelected && !globalHasAdditions"
class="flex p-4 bg-error text-secondaryDark" class="flex p-4 bg-error text-secondaryDark"
role="alert"
> >
<i class="mr-4 material-icons"> warning </i> <i class="mr-4 material-icons"> warning </i>
<div class="flex flex-col"> <div class="flex flex-col">

View File

@@ -51,19 +51,23 @@
arrow arrow
> >
<template #trigger> <template #trigger>
<div v-if="item.kind === 'RootObject'" class="outline">{}</div> <div v-if="item.kind === 'RootObject'" class="outline-item">{}</div>
<div v-if="item.kind === 'RootArray'" class="outline">[]</div> <div v-if="item.kind === 'RootArray'" class="outline-item">[]</div>
<div v-if="item.kind === 'ArrayMember'" class="outline"> <div v-if="item.kind === 'ArrayMember'" class="outline-item">
{{ item.index }} {{ item.index }}
</div> </div>
<div v-if="item.kind === 'ObjectMember'" class="outline"> <div v-if="item.kind === 'ObjectMember'" class="outline-item">
{{ item.name }} {{ item.name }}
</div> </div>
</template> </template>
<div <div
v-if="item.kind === 'ArrayMember' || item.kind === 'ObjectMember'" v-if="item.kind === 'ArrayMember' || item.kind === 'ObjectMember'"
> >
<div v-if="item.kind === 'ArrayMember'" class="flex flex-col"> <div
v-if="item.kind === 'ArrayMember'"
class="flex flex-col"
role="menu"
>
<SmartItem <SmartItem
v-for="(arrayMember, astIndex) in item.astParent.values" v-for="(arrayMember, astIndex) in item.astParent.values"
:key="`ast-${astIndex}`" :key="`ast-${astIndex}`"
@@ -76,7 +80,11 @@
" "
/> />
</div> </div>
<div v-if="item.kind === 'ObjectMember'" class="flex flex-col"> <div
v-if="item.kind === 'ObjectMember'"
class="flex flex-col"
role="menu"
>
<SmartItem <SmartItem
v-for="(objectMember, astIndex) in item.astParent.members" v-for="(objectMember, astIndex) in item.astParent.members"
:key="`ast-${astIndex}`" :key="`ast-${astIndex}`"
@@ -90,7 +98,11 @@
/> />
</div> </div>
</div> </div>
<div v-if="item.kind === 'RootObject'" class="flex flex-col"> <div
v-if="item.kind === 'RootObject'"
class="flex flex-col"
role="menu"
>
<SmartItem <SmartItem
label="{}" label="{}"
@click.native=" @click.native="
@@ -101,7 +113,11 @@
" "
/> />
</div> </div>
<div v-if="item.kind === 'RootArray'" class="flex flex-col"> <div
v-if="item.kind === 'RootArray'"
class="flex flex-col"
role="menu"
>
<SmartItem <SmartItem
label="[]" label="[]"
@click.native=" @click.native="
@@ -206,7 +222,7 @@ const outlinePath = computed(() => {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.outline { .outline-item {
@apply cursor-pointer; @apply cursor-pointer;
@apply flex-grow-0 flex-shrink-0; @apply flex-grow-0 flex-shrink-0;
@apply text-secondaryLight; @apply text-secondaryLight;

View File

@@ -43,12 +43,14 @@
/> />
</span> </span>
</template> </template>
<div class="flex flex-col" role="menu">
<SmartItem <SmartItem
v-for="(_, version) in socketIoClients" v-for="(_, version) in socketIoClients"
:key="`client-${version}`" :key="`client-${version}`"
:label="`Client ${version}`" :label="`Client ${version}`"
@click.native="onSelectVersion(version)" @click.native="onSelectVersion(version)"
/> />
</div>
</tippy> </tippy>
</label> </label>
<input <input
@@ -109,6 +111,7 @@
/> />
</span> </span>
</template> </template>
<div class="flex flex-col" role="menu">
<SmartItem <SmartItem
label="None" label="None"
:icon=" :icon="
@@ -139,6 +142,7 @@
} }
" "
/> />
</div>
</tippy> </tippy>
</span> </span>
<div class="flex"> <div class="flex">

View File

@@ -15,6 +15,7 @@
/> />
</span> </span>
</template> </template>
<div class="flex flex-col" role="menu">
<NuxtLink <NuxtLink
v-for="(locale, index) in $i18n.locales" v-for="(locale, index) in $i18n.locales"
:key="`locale-${index}`" :key="`locale-${index}`"
@@ -27,6 +28,7 @@
:info-icon="$i18n.locale === locale.code ? 'done' : null" :info-icon="$i18n.locale === locale.code ? 'done' : null"
/> />
</NuxtLink> </NuxtLink>
</div>
</tippy> </tippy>
</span> </span>
</template> </template>

View File

@@ -1,6 +1,8 @@
<template> <template>
<div <div
class="inline-flex items-center justify-center cursor-pointer transition flex-nowrap group hover:text-secondaryDark" class="inline-flex items-center justify-center cursor-pointer transition flex-nowrap group hover:text-secondaryDark"
role="checkbox"
:aria-checked="on"
@click="$emit('change')" @click="$emit('change')"
> >
<input <input

View File

@@ -3,6 +3,8 @@
v-if="show" v-if="show"
dialog dialog
:title="$t('modal.confirm')" :title="$t('modal.confirm')"
role="dialog"
aria-modal="true"
@close="hideModal" @close="hideModal"
> >
<template #body> <template #body>

View File

@@ -15,6 +15,7 @@
/> />
</span> </span>
</template> </template>
<div class="flex flex-col" role="menu">
<SmartItem <SmartItem
v-for="(size, index) in fontSizes" v-for="(size, index) in fontSizes"
:key="`size-${index}`" :key="`size-${index}`"
@@ -30,6 +31,7 @@
} }
" "
/> />
</div>
</tippy> </tippy>
</span> </span>
</template> </template>

View File

@@ -16,6 +16,7 @@
]" ]"
:disabled="disabled" :disabled="disabled"
:tabindex="loading ? '-1' : '0'" :tabindex="loading ? '-1' : '0'"
role="menuitem"
> >
<span <span
v-if="!loading" v-if="!loading"

View File

@@ -28,6 +28,7 @@ const SmartLink = {
switch (tag) { switch (tag) {
case ANCHOR_TAG: case ANCHOR_TAG:
attrs["aria-label"] = "Link" attrs["aria-label"] = "Link"
attrs.role = "link"
// Map `to` prop to the correct attribute // Map `to` prop to the correct attribute
attrs.href = context.props.to attrs.href = context.props.to
@@ -56,6 +57,7 @@ const SmartLink = {
default: default:
attrs["aria-label"] = "Button" attrs["aria-label"] = "Button"
attrs.role = "button"
break break
} }

View File

@@ -3,6 +3,8 @@
<div <div
ref="modal" ref="modal"
class="fixed inset-0 z-10 z-50 overflow-y-auto transition hide-scrollbar" class="fixed inset-0 z-10 z-50 overflow-y-auto transition hide-scrollbar"
role="dialog"
aria-modal="true"
> >
<div <div
class="flex items-end justify-center min-h-screen text-center sm:block" class="flex items-end justify-center min-h-screen text-center sm:block"

View File

@@ -5,6 +5,8 @@
value === selected ? 'radio_button_checked' : 'radio_button_unchecked' value === selected ? 'radio_button_checked' : 'radio_button_unchecked'
" "
:active="value === selected" :active="value === selected"
role="radio"
:aria-checked="value === selected"
@click.native="$emit('change', value)" @click.native="$emit('change', value)"
/> />
</template> </template>

View File

@@ -19,6 +19,7 @@
class="tab" class="tab"
:class="[{ active: tab.active }, { vertical: vertical }]" :class="[{ active: tab.active }, { vertical: vertical }]"
:aria-label="tab.label" :aria-label="tab.label"
role="button"
@keyup.enter="selectTab(tab)" @keyup.enter="selectTab(tab)"
@click="selectTab(tab)" @click="selectTab(tab)"
> >

View File

@@ -104,6 +104,7 @@
/> />
</span> </span>
</template> </template>
<div class="flex flex-col" role="menu">
<SmartItem <SmartItem
label="OWNER" label="OWNER"
:icon=" :icon="
@@ -149,6 +150,7 @@
} }
" "
/> />
</div>
</tippy> </tippy>
</span> </span>
<div class="flex"> <div class="flex">

View File

@@ -160,6 +160,7 @@
/> />
</span> </span>
</template> </template>
<div class="flex flex-col" role="menu">
<SmartItem <SmartItem
label="OWNER" label="OWNER"
:icon=" :icon="
@@ -205,6 +206,7 @@
} }
" "
/> />
</div>
</tippy> </tippy>
</span> </span>
<div class="flex"> <div class="flex">

View File

@@ -86,6 +86,7 @@
ref="tippyActions" ref="tippyActions"
class="flex flex-col focus:outline-none" class="flex flex-col focus:outline-none"
tabindex="0" tabindex="0"
role="menu"
@keyup.e="team.myRole === 'OWNER' ? edit.$el.click() : null" @keyup.e="team.myRole === 'OWNER' ? edit.$el.click() : null"
@keyup.x=" @keyup.x="
!(team.myRole === 'OWNER' && team.ownersCount == 1) !(team.myRole === 'OWNER' && team.ownersCount == 1)