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(menu): add aria-label on main nav - FRONT-4478 #3540

Merged
merged 1 commit into from
Aug 7, 2024
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
2 changes: 2 additions & 0 deletions src/implementations/twig/components/menu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ npm install --save @ecl/twig-component-menu
- **"toggle"**: (associative array) (default: {}): Toggle (hambrger) link, using ECL Link structure
- **"close"**: (associative array) (default: {}): Close button, using ECL Button structure
- **"back_label"** (string): (default: ''): Back button label
- **"aria_label"** (string) (default: '') Aria label for the main nav
- **"icon_path"** (string) (default: ''): Path to the icon sprite
- **"items"**: (array) (default: []): The menu items - format: [
{
Expand Down Expand Up @@ -80,6 +81,7 @@ npm install --save @ecl/twig-component-menu
hide_label: true,
},
back_label: 'Back',
aria_label: 'Main navigation',
icon_path: '/icons.svg',
menu_link: './example.com',
items: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports[`Menu Default renders correctly 1`] = `
<jest>
<nav
aria-expanded="false"
aria-label="Main navigation"
class="ecl-menu"
data-ecl-auto-init="Menu"
data-ecl-menu=""
Expand Down Expand Up @@ -864,6 +865,7 @@ exports[`Menu Default renders correctly with a external first level menu item 1`
<jest>
<nav
aria-expanded="false"
aria-label="Main navigation"
class="ecl-menu"
data-ecl-auto-init="Menu"
data-ecl-menu=""
Expand Down Expand Up @@ -1742,6 +1744,7 @@ exports[`Menu Default renders correctly with extra attributes 1`] = `
<jest>
<nav
aria-expanded="false"
aria-label="Main navigation"
class="ecl-menu"
data-ecl-auto-init="Menu"
data-ecl-menu=""
Expand Down Expand Up @@ -2604,6 +2607,7 @@ exports[`Menu Default renders correctly with extra attributes for the items 1`]
<jest>
<nav
aria-expanded="false"
aria-label="Main navigation"
class="ecl-menu"
data-ecl-auto-init="Menu"
data-ecl-menu=""
Expand Down Expand Up @@ -3465,6 +3469,7 @@ exports[`Menu Default renders correctly with extra attributes for the sub-items
<jest>
<nav
aria-expanded="false"
aria-label="Main navigation"
class="ecl-menu"
data-ecl-auto-init="Menu"
data-ecl-menu=""
Expand Down Expand Up @@ -4326,6 +4331,7 @@ exports[`Menu Default renders correctly with extra class names 1`] = `
<jest>
<nav
aria-expanded="false"
aria-label="Main navigation"
class="ecl-menu custom-button custom-button--test"
data-ecl-auto-init="Menu"
data-ecl-menu=""
Expand Down Expand Up @@ -5186,6 +5192,7 @@ exports[`Menu Long renders correctly 1`] = `
<jest>
<nav
aria-expanded="false"
aria-label="Main navigation"
class="ecl-menu"
data-ecl-auto-init="Menu"
data-ecl-menu=""
Expand Down
5 changes: 5 additions & 0 deletions src/implementations/twig/components/menu/menu.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- "toggle": (associative array) (default: {}): Toggle (hamburger) link, using ECL Link structure
- "close": (associative array) (default: {}): Close button, using ECL Button structure
- "back_label": (string): (default: ''): Back button label
- "aria_label" (string) (default: '') Aria label for the main nav
- "icon_path": (string) (default: ''): Path to the icon sprite
- "items": (array) (default: []): The menu items - format: [
{
Expand Down Expand Up @@ -50,6 +51,7 @@
{% set _id = id|default('ecl-menu-' ~ random()) %}
{% set _title = title|default('') %}
{% set _back_label = back_label|default('') %}
{% set _aria_label = aria_label|default('') %}
{% set _toggle = toggle|default({}) %}
{% set _close = close|default({}) %}
{% set _css_class = 'ecl-menu' %}
Expand Down Expand Up @@ -91,6 +93,9 @@
{% endif %}
aria-expanded="false"
role="navigation"
{%- if _aria_label is not empty %}
aria-label="{{ _aria_label }}"
{%- endif -%}
{{ _extra_attributes|raw }}
>
<div class="ecl-menu__overlay"></div>
Expand Down
1 change: 1 addition & 0 deletions src/specs/components/menu/demo/data--ec-long.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const exampleLink = `${publicUrl}/example`;

module.exports = {
id: 'demo',
aria_label: 'Main navigation',
title: 'Menu',
toggle: {
link: {
Expand Down
1 change: 1 addition & 0 deletions src/specs/components/menu/demo/data--ec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const exampleLink = `${publicUrl}/example`;

module.exports = {
id: 'demo',
aria_label: 'Main navigation',
title: 'Menu',
toggle: {
link: {
Expand Down
1 change: 1 addition & 0 deletions src/specs/components/menu/demo/data--eu-long.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const exampleLink = `${publicUrl}/example`;

module.exports = {
id: 'demo',
aria_label: 'Main navigation',
title: 'Menu',
toggle: {
link: {
Expand Down
1 change: 1 addition & 0 deletions src/specs/components/menu/demo/data--eu.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const exampleLink = `${publicUrl}/example`;

module.exports = {
title: 'Menu',
aria_label: 'Main navigation',
id: 'demo',
toggle: {
link: {
Expand Down
Loading