Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
Add ARIA labels to Sidebar component - Vue (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
codewithjazzy authored Oct 28, 2024
1 parent 3e7edfa commit 0b2b89b
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions javascript/dwa-starter-vue/src/components/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,32 @@ const closeDrawer = () => {
</script>

<template>
<div class="lg:hidden">
<div class="border-b py-2 backdrop-blur-lg dark:border-gray-700">
<Button @click="toggleDrawer" variant="ghost">
<!-- Sidebar container for mobile -->
<aside class="lg:hidden">
<!-- Toggle button with ARIA for expanded state -->
<header class="border-b py-2 backdrop-blur-lg dark:border-gray-700">
<Button @click="toggleDrawer" variant="ghost" aria-expanded="isOpen" aria-controls="mobile-sidebar" aria-label="Toggle sidebar">
<TextAlignLeftIcon class="w-6 h-6" />
</Button>
</div>
</header>

<div v-if="isOpen" @click="closeDrawer" class="fixed inset-0 bg-black bg-opacity-80 z-10"></div>
<!-- Keyboard accessible with tabindex and Enter key -->
<div v-if="isOpen" @click="closeDrawer" class="fixed inset-0 bg-black bg-opacity-80 z-10" role="button" tabindex="0" aria-label="Close sidebar" @keydown.enter="closeDrawer"></div>

<div
<!-- Sidebar drawer for navigation links -->
<div id="mobile-sidebar"
:class="[
'fixed top-0 left-0 z-20 h-full w-64 bg-white dark:bg-zinc-950 shadow-md transition-transform p-4',
isOpen ? 'translate-x-0' : '-translate-x-full'
]"
:aria-hidden="isOpen ? 'false' : 'true'"
>
<SidebarList @itemClicked="closeDrawer" />
</div>
</div>
</aside>

<div class="hidden lg:block h-full p-4 w-64">
<!-- Sidebar container for desktop -->
<aside class="hidden lg:block h-full p-4 w-64">
<SidebarList />
</div>
</aside>
</template>

0 comments on commit 0b2b89b

Please sign in to comment.