Skip to content

Commit

Permalink
enh(a11y): Add API for using nav header menu
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <chrng8@gmail.com>
  • Loading branch information
Pytal committed Aug 29, 2023
1 parent b1b6aa0 commit 2378044
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/components/NcHeaderMenu/NcHeaderMenu.vue
Expand Up @@ -64,8 +64,10 @@ export default {
</docs>

<template>
<div :id="id"
<component :is="isNav ? 'nav' : 'div'"
:id="id"
v-click-outside="clickOutsideConfig"
:aria-label="wrapperAriaLabel"
:class="{ 'header-menu--opened': opened }"
class="header-menu">
<!-- Trigger -->
Expand All @@ -86,14 +88,13 @@ export default {
<!-- Menu opened content -->
<div v-show="opened"
:id="`header-menu-${id}`"
class="header-menu__wrapper"
role="menu">
class="header-menu__wrapper">
<div ref="content" class="header-menu__content">
<!-- @slot Main content -->
<slot />
</div>
</div>
</div>
</component>
</template>

<script>
Expand Down Expand Up @@ -138,6 +139,22 @@ export default {
type: Boolean,
default: false,
},
/**
* True if the header menu is used for website navigation
*/
isNav: {
type: Boolean,
default: false,
},
/**
* aria-label attribute of the wrapper element
*/
wrapperAriaLabel: {
type: String,
default: null,
},
},
emits: [
Expand Down

0 comments on commit 2378044

Please sign in to comment.