Skip to content

Commit

Permalink
fix(user_status): Use native radio buttons for online status selection
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed May 11, 2023
1 parent 5f205fe commit 91edc9c
Showing 1 changed file with 61 additions and 41 deletions.
102 changes: 61 additions & 41 deletions apps/user_status/src/components/PredefinedStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,24 @@
-
-->
<template>
<li class="predefined-status"
tabindex="0"
role="radio"
:aria-checked="`${selected}`"
@keyup.enter="select"
@keyup.space="select"
@click="select">
<span aria-hidden="true" class="predefined-status__icon">
{{ icon }}
</span>
<span class="predefined-status__message">
{{ message }}
</span>
<span class="predefined-status__clear-at">
{{ clearAt | clearAtFilter }}
</span>
<li class="predefined-status">
<input :id="id"
class="predefined-status__input"
type="radio"
name="predefined-status"
:checked="selected"
@change="select">
<label class="predefined-status__label" :for="id">
<span aria-hidden="true" class="predefined-status__label--icon">
{{ icon }}
</span>
<span class="predefined-status__label--message">
{{ message }}
</span>
<span class="predefined-status__label--clear-at">
{{ clearAt | clearAtFilter }}
</span>
</label>
</li>
</template>

Expand Down Expand Up @@ -70,6 +72,11 @@ export default {
default: false,
},
},
computed: {
id() {
return `user-status-predefined-status-${this.messageId}`
},
},
methods: {
/**
* Emits an event when the user clicks the row
Expand All @@ -83,39 +90,52 @@ export default {

<style lang="scss" scoped>
.predefined-status {
display: flex;
flex-wrap: nowrap;
justify-content: flex-start;
flex-basis: 100%;
border-radius: var(--border-radius);
align-items: center;
min-height: 44px;
&__label {
display: flex;
flex-wrap: nowrap;
justify-content: flex-start;
flex-basis: 100%;
border-radius: var(--border-radius);
align-items: center;
min-height: 44px;
&:hover,
&:focus {
background-color: var(--color-background-hover);
}
&--icon {
flex-basis: 40px;
text-align: center;
}
&:active{
background-color: var(--color-background-dark);
}
&--message {
font-weight: bold;
padding: 0 6px;
}
&--clear-at {
color: var(--color-text-maxcontrast);
&__icon {
flex-basis: 40px;
text-align: center;
&::before {
content: '';
}
}
}
&__message {
font-weight: bold;
padding: 0 6px;
&__input:checked + &__label,
&__input:focus + &__label,
&__label:hover {
background-color: var(--color-background-hover);
}
&__clear-at {
color: var(--color-text-maxcontrast);
&__label:active {
background-color: var(--color-background-dark);
}
&::before {
content: '';
}
// Inputs are here for keyboard navigation, they are not visually visible
&__input {
position: absolute;
top: auto;
left: -10000px;
overflow: hidden;
width: 1px;
height: 1px;
}
}
</style>

0 comments on commit 91edc9c

Please sign in to comment.