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

Add aria label to the home icon within the breadcrumb #1152

Merged
merged 2 commits into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/unreleased/enhancement-aria-label-for-breadcrumb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Enhancement: Add aria label to the home icon within the breadcrumb

https://github.com/owncloud/owncloud-design-system/pull/1152
https://github.com/owncloud/web/issues/4329
33 changes: 26 additions & 7 deletions src/components/OcBreadcrumb.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
<div :class="`oc-breadcrumb oc-breadcrumb-${variation}`">
<ul class="oc-breadcrumb-list">
<li v-for="(item, index) in items" :key="index" class="oc-breadcrumb-list-item">
<router-link v-if="home && index === 0" :to="item.to" class="uk-flex uk-float-left">
<router-link
v-if="home && index === 0"
:to="item.to"
class="uk-flex uk-float-left"
:aria-label="homeAccessibleLabelValue"
>
<oc-icon name="home" />
</router-link>
<router-link v-else-if="item.to" :to="item.to">{{ item.text }}</router-link>
Expand All @@ -13,15 +18,15 @@
<div class="oc-breadcrumb-drop">
<label class="oc-breadcrumb-drop-label">
<span
v-if="$_ocBreadcrumb_currentFolder"
v-if="currentFolder"
class="oc-breadcrumb-drop-label-text"
v-text="$_ocBreadcrumb_currentFolder.text"
v-text="currentFolder.text"
/>
<oc-icon class="oc-breadcrumb-drop-label-icon" name="expand_more" />
</label>
<oc-drop v-if="$_ocBreadcrumb_dropdownItems" :options="{ offset: 20 }">
<oc-drop v-if="dropdownItems" :options="{ offset: 20 }">
<ul class="uk-nav uk-nav-default">
<li v-for="(item, index) in $_ocBreadcrumb_dropdownItems" :key="index">
<li v-for="(item, index) in dropdownItems" :key="index">
<router-link v-if="item.to" :to="item.to">{{ item.text }}</router-link>
<a v-else-if="item.onClick" @click="item.onClick">{{ item.text }}</a>
<span v-else v-text="item.text" />
Expand All @@ -42,6 +47,9 @@ import OcIcon from "./OcIcon.vue"
* - text: mandatory element, holds the text which is to be displayed in the breadcrumb
* - to: optional element, the vue router link
*
* ## Accessibility
*
* You can provide an accessibility label to the home icon via `homeAccessibleLabel`. If not set, it will default to "Go to Home".
*/
export default {
name: "OcBreadcrumb",
Expand Down Expand Up @@ -69,6 +77,14 @@ export default {
type: [Boolean],
default: false,
},
/**
* Aria-label for the home icon
*/
homeAccessibleLabel: {
type: String,
required: false,
default: "",
},
/**
* Variation of breadcrumbs
* Can be `default` or `lead`
Expand All @@ -81,16 +97,19 @@ export default {
},
},
computed: {
$_ocBreadcrumb_dropdownItems() {
dropdownItems() {
if (this.items.length <= 1 || !this.items) return false

return [...this.items].reverse().slice(1)
},
$_ocBreadcrumb_currentFolder() {
currentFolder() {
if (this.items.length === 0 || !this.items) return false

return [...this.items].reverse()[0]
},
homeAccessibleLabelValue() {
return this.homeAccessibleLabel || this.$gettext("Go to root directory")
},
},
}
</script>
Expand Down