Visitar URL original
USWDS - Header: Consistent nav data is passed in Header by mejiaj · Pull Request #5311 · uswds/uswds · GitHub
Skip to content
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"title": "Extended header with mega-menu",
"modifier": "usa-header--extended",
"id_prefix": "extended-megamenu",
"nav": {
"menu": {
"label": "Menu"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"modifier": "usa-header--extended",
"title": "Extended header",
"id_prefix": "extended",
"nav": {
"menu": {
"label": "Menu"
},
"aria_label": "Primary navigation",
"megamenu": false,
"items": [
{
"label": "<Current section>",
Expand Down
2 changes: 2 additions & 0 deletions packages/usa-header/src/usa-header.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"modifier": "",
"title": "Basic header",
"id_prefix": "basic",
"nav": {
"menu": {
"label": "Menu"
},
"megamenu": false,
"aria_label": "Primary navigation",
"close": {
"label": "Close"
Expand Down
2 changes: 0 additions & 2 deletions packages/usa-header/src/usa-header.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Default.args = DefaultContent;
export const Megamenu = Template.bind({});
Megamenu.args = {
...MegamenuContent,
megamenu: true,
};

export const Extended = ExtendedTemplate.bind({});
Expand All @@ -44,7 +43,6 @@ Extended.args = {
export const ExtendedMegamenu = ExtendedTemplate.bind({});
ExtendedMegamenu.args = {
...ExtendedMegamenuContent,
megamenu: true,
navSecondaryContent: {
...navSecondaryContent,
search: true,
Expand Down
8 changes: 4 additions & 4 deletions packages/usa-header/src/usa-header.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<div class="usa-nav-container">
{% include "@components/usa-header/src/_includes/usa-navbar.twig" %}
{% if nav %}
<nav aria-label="{{ nav.aria_label }}" class="usa-nav">
{% include "@components/usa-nav/src/usa-nav__primary/usa-nav__primary.twig" %}
{% include "@components/usa-search/src/usa-search.twig" with search.settings %}
</nav>
<nav aria-label="{{ nav.aria_label }}" class="usa-nav">
{% include "@components/usa-nav/src/usa-nav__primary/usa-nav__primary.twig" %}
{% include "@components/usa-search/src/usa-search.twig" with search.settings %}
</nav>
{% endif %}
</div>
</header>
1 change: 1 addition & 0 deletions packages/usa-header/src/usa-header~megamenu.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"modifier": "usa-header--megamenu",
"title": "Basic with mega-menu",
"id_prefix": "megamenu",
"nav": {
"menu": {
"label": "Menu"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
{% endif %}
{% else %}
<a
href="{{ item.href }}"
href="{{ item.href | default("javascript:void(0);") }}"
{% if menu_level == 0 %} class="usa-nav-link" {% endif %}
>
{% if megamenu %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ Default.args = Content;
export const Megamenu = Template.bind({});
Megamenu.args = {
...Content,
megamenu: true,
nav: {
...Content.nav,
megamenu: true,
},
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"modifier": "usa-nav__primary",
"nav": {
"megamenu": true,
"megamenu": false,
"close": {
"label": "Close"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
<img src="{{ img_path }}/usa-icons/close.svg" role="img" alt="{{ nav.close.label }}">
</button>

{{ menus.menu_links(nav.items, 0, megamenu) }}
{{ menus.menu_links(nav.items, 0, nav.megamenu) }}