Skip to content

Commit

Permalink
add date picker day narration for accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
goemen committed Aug 13, 2024
1 parent e540bcc commit 6620e6a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
22 changes: 20 additions & 2 deletions admin-frontend/src/components/announcements/AnnouncementForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
v-model="publishedOn"
:aria-labels="{ input: 'Publish On' }"
>
<template #day="{ day, date }">
<span :aria-label="formatDate(date)">
{{ day }}
</span>
</template>
</VueDatePicker>
</v-col>
</v-row>
Expand All @@ -89,7 +94,13 @@
prevent-min-max-navigation
v-model="expiresOn"
:disabled="noExpiry"
/>
>
<template #day="{ day, date }">
<span :aria-label="formatDate(date)">
{{ day }}
</span>
</template>
</VueDatePicker>
</v-col>
</v-row>
<v-row class="mt-0">
Expand Down Expand Up @@ -152,7 +163,8 @@ import { AnnouncementFormValue } from '../../types/announcements';
import { useField, useForm } from 'vee-validate';
import * as zod from 'zod';
import { isEmpty } from 'lodash';
import { LocalDate, nativeJs } from '@js-joda/core';
import { DateTimeFormatter, LocalDate, nativeJs } from '@js-joda/core';
import { Locale } from '@js-joda/locale_en';
import ConfirmationDialog from '../util/ConfirmationDialog.vue';
import { useRouter } from 'vue-router';
Expand Down Expand Up @@ -228,6 +240,12 @@ watch(noExpiry, () => {
}
});
const formatDate = (date: Date) => {
return LocalDate.from(nativeJs(date)).format(
DateTimeFormatter.ofPattern('EEEE d MMMM yyyy').withLocale(Locale.CANADA),
);
};
const handleCancel = async () => {
if (!meta.value.dirty) {
router.back();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,19 @@
<VueDatePicker
v-model="publishDateRange"
range
placeholder="Select date range"
format="yyyy-MM-dd"
:enable-time-picker="false"
arrow-navigation
auto-apply
prevent-min-max-navigation
/>
>
<template #day="{ day, date }">
<span :aria-label="formatDate(date)">
{{ day }}
</span>
</template>
</VueDatePicker>
</v-col>

<v-col sm="6" md="6" lg="4" xl="3" class="d-flex flex-column">
Expand All @@ -71,7 +78,14 @@
arrow-navigation
auto-apply
prevent-min-max-navigation
/>
placeholder="Select date range"
>
<template #day="{ day, date }">
<span :aria-label="formatDate(date)">
{{ day }}
</span>
</template>
</VueDatePicker>
</v-col>

<v-col sm="6" md="6" lg="4" xl="3" class="d-flex flex-column">
Expand Down Expand Up @@ -169,7 +183,9 @@ import {
nativeJs,
DateTimeFormatter,
ZoneId,
LocalDate,
} from '@js-joda/core';
import { Locale } from '@js-joda/locale_en';
const announcementSearchStore = useAnnouncementSearchStore();
Expand All @@ -186,6 +202,12 @@ const statusOptions = ref([
AnnouncementStatus.Expired,
]);
const formatDate = (date: Date) => {
return LocalDate.from(nativeJs(date)).format(
DateTimeFormatter.ofPattern('EEEE d MMMM yyyy').withLocale(Locale.CANADA),
);
};
function getAnnouncementSearchFilters(): AnnouncementFilterType {
const filters: any[] = [];
if (searchText.value) {
Expand Down

0 comments on commit 6620e6a

Please sign in to comment.