Client - make language dropdown keyboard-navigable

This commit is contained in:
Sam 2023-07-12 19:53:37 +02:00
parent 3b59c4599f
commit 4b3270f546
2 changed files with 54 additions and 39 deletions

View File

@ -1,15 +1,21 @@
<template> <template>
<div class="dropdown-wrapper"> <div class="dropdown-wrapper">
<div class="dropdown-selected" @click="toggleDropdown"> <button
:aria-expanded="isOpen"
class="dropdown-selector transparent"
@click="toggleDropdown"
>
<slot></slot> <slot></slot>
</div> </button>
<ul class="dropdown-list" v-if="isOpen"> <ul class="dropdown-list" v-if="isOpen">
<li <li
class="dropdown-item" class="dropdown-item"
:class="{ selected: option.value === selected }" :class="{ selected: option.value === selected }"
v-for="(option, index) in dropdownOptions" v-for="(option, index) in dropdownOptions"
:key="index" :key="index"
tabindex="0"
@click="updateSelected(option)" @click="updateSelected(option)"
@keydown.enter="updateSelected(option)"
> >
{{ option.label }} {{ option.label }}
</li> </li>
@ -51,6 +57,13 @@
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@import '~@/scss/vars.scss';
.dropdown-wrapper {
.dropdown-selector {
margin: 0;
padding: $default-padding * 0.5;
}
.dropdown-list { .dropdown-list {
list-style-type: none; list-style-type: none;
background-color: #ffffff; background-color: #ffffff;
@ -63,14 +76,8 @@
box-shadow: 2px 2px 5px lightgrey; box-shadow: 2px 2px 5px lightgrey;
width: auto !important; width: auto !important;
li {
padding: 3px 8px;
}
}
.dropdown-item { .dropdown-item {
cursor: pointer; padding: 3px 12px;
&.selected { &.selected {
font-weight: bold; font-weight: bold;
} }
@ -83,4 +90,6 @@
background-color: var(--dropdown-hover-color); background-color: var(--dropdown-hover-color);
} }
} }
}
}
</style> </style>

View File

@ -175,6 +175,7 @@
font-size: 1.2em; font-size: 1.2em;
font-weight: bold; font-weight: bold;
margin-right: 10px; margin-right: 10px;
line-height: 1.6em;
} }
.fa { .fa {
@ -194,7 +195,7 @@
display: flex; display: flex;
flex: 1; flex: 1;
justify-content: space-between; justify-content: space-between;
line-height: 1.8em; line-height: 2em;
width: 100%; width: 100%;
.nav-items-close { .nav-items-close {
@ -213,13 +214,16 @@
} }
.nav-item { .nav-item {
padding: 0 10px; padding: 0 10px;
&.dropdown-wrapper {
padding: 0;
margin-left: 2px;
::v-deep(.dropdown-list) { ::v-deep(.dropdown-list) {
z-index: 1000; z-index: 1000;
margin-left: -160px !important; margin-left: -150px !important;
width: 180px !important; width: 180px !important;
} }
} }
}
.nav-link { .nav-link {
color: var(--app-a-color); color: var(--app-a-color);
@ -330,12 +334,14 @@
.nav-item { .nav-item {
padding: 7px 25px; padding: 7px 25px;
&.dropdown-wrapper {
padding-left: 15px;
::v-deep(.dropdown-list) { ::v-deep(.dropdown-list) {
margin-left: initial !important; margin-left: initial !important;
width: auto !important; width: auto !important;
} }
} }
}
.nav-profile-img { .nav-profile-img {
display: none; display: none;