Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(NcAppNavigationItem): Add active property to set active state & use aria-current #4716

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/components/NcAppNavigationItem/NcAppNavigationItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,14 @@
```
* With a spinning loader instead of the icon:

```
```vue
<NcAppNavigationItem name="Loading Item" :loading="true" />
```
* With an active state (only needed when not using `vue-router` and the `to` property, otherwise this is set automatically)

```vue
<NcAppNavigationItem name="Current page" :active="true" />
```

### Element with actions
Wrap the children in a template. If you have more than 2 actions, a popover menu and a menu
Expand Down Expand Up @@ -261,12 +266,13 @@ Just set the `pinned` prop.
<div :class="{
'app-navigation-entry--editing': editingActive,
'app-navigation-entry--deleted': undo,
'active': isActive && to,
'active': (isActive && to) || active,
}"
class="app-navigation-entry">
<!-- Icon and name -->
<a v-if="!undo"
class="app-navigation-entry-link"
:aria-current="active || (isActive && to) ? 'page' : undefined"
:aria-description="ariaDescription"
:aria-expanded="hasChildren ? opened.toString() : undefined"
:href="href || routerLinkHref || '#'"
Expand Down Expand Up @@ -390,6 +396,15 @@ export default {
mixins: [isMobile],

props: {
/**
* If you are not using vue-router you can use the property to set this item as the active navigation entry.
* When using vue-router and the `to` property this is set automatically.
*/
active: {
type: Boolean,
default: false,
},

/**
* The main text content of the entry.
*/
Expand Down