Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
8.5.7
Browse files Browse the repository at this point in the history
- D8CORE-4490: adding secondary skip links to secondary navigation (#232) (24e659c)
- D8CORE-4496 Prevent empty <ul> elements in secondary nav (#233) (2682a18)
  • Loading branch information
pookmish authored Jul 9, 2021
2 parents b0f3b05 + 1e24a5c commit 6fe1c42
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 38 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Stanford Basic Theme

8.x-5.7
--------------------------------------------------------------------------------
_Release Date: 2021-07-09_

- D8CORE-4490: adding secondary skip links to secondary navigation (#232) (24e659c)
- D8CORE-4496 Prevent empty <ul> elements in secondary nav (#233) (2682a18)

8.x-5.6
--------------------------------------------------------------------------------
_Release Date: 2021-06-11_
Expand Down
2 changes: 1 addition & 1 deletion dist/js/behaviors.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/js/stanford_basic.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export default {
// Validate there is a skip link for the secondary navigation. If not,
// remove the skip link. If the mobile hamburger is visible, remove the link.
var $sn = $('#secondary-navigation', context).length;
if (!$sn) {
var $pn = $('.menu--stanford-publication-topics', context).length;
if (!$sn && !$pn) {
$('.su-skipnav--secondary', context).remove();
}

Expand Down
2 changes: 1 addition & 1 deletion stanford_basic.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: 'Stanford Basic'
type: theme
description: 'Stanford Basic Branding Theme.'
package: Stanford
version: 8.x-5.6
version: 8.x-5.7
core_version_requirement: ^9
'base theme': stable9
regions:
Expand Down
2 changes: 2 additions & 0 deletions templates/block/block--system-menu-block.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
]
%}
{% set heading_id = (configuration.id ~ '-menu')|clean_id %}
<a href="#main-content" class="visually-hidden focusable su-skipnav su-skipnav--content">{{ 'Skip to main content'|t }}</a>
<div {{ attributes.addClass(classes) }}>
<div id="secondary-navigation" tabindex="-1" class="visually-hidden focusable">{{ 'Secondary Navigation'|t }}</div>
{# Label. If not displayed, we still provide it for screen readers. #}
{% if not configuration.label_display %}
{% set title_attributes = title_attributes.addClass('visually-hidden') %}
Expand Down
74 changes: 40 additions & 34 deletions templates/menus/macros/secondary-nav-menu.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,50 @@
* Macro for creating nested menus.
*/
#}

{% macro secondary_nav_menu(items, menu_level, class_prefix, parent) %}
{% import _self as menus %}
<ul class="{{ class_prefix }}__menu {{ class_prefix }}__menu-lv{{ menu_level }}">
{% for item in items %}

{# Link Attribtues #}
{% set link_attributes = item.attributes %}
{% set link_attributes = link_attributes.addClass(class_prefix ~ "__link") %}
{% set link_attributes = link_attributes.setAttribute('href', item.url|render) %}
{% set items_to_display = items|filter(item => item.in_active_trail == true or menu_level == 1 or parent.in_active_trail == true) %}

{% if items_to_display is not empty %}
<ul class="{{ class_prefix }}__menu {{ class_prefix }}__menu-lv{{ menu_level }}">
{% for item in items_to_display %}

{# Link Attribtues #}
{% set link_attributes = item.attributes %}
{% set link_attributes = link_attributes.addClass(class_prefix ~ "__link") %}
{% set link_attributes = link_attributes.setAttribute('href', item.url|render) %}

{# Item Attributes #}
{% set list_attributes = create_attribute() %}
{% set list_attributes = list_attributes.addClass(class_prefix ~ "__item") %}
{% if item.below is not empty %}
{% set list_attributes = list_attributes.addClass(class_prefix ~ "__item--parent") %}
{% endif %}
{% if item.in_active_trail == true %}
{% set list_attributes = list_attributes.addClass(class_prefix ~ "__item--active-trail") %}
{% endif %}
{% if item.is_active == true %}
{% set list_attributes = list_attributes.addClass(class_prefix ~ "__item--current") %}
{% set link_attributes = link_attributes.setAttribute('aria-current', 'true') %}
{% endif %}
{# Item Attributes #}
{% set list_attributes = create_attribute() %}
{% set list_attributes = list_attributes.addClass(class_prefix ~ "__item") %}
{% if item.below is not empty %}
{% set list_attributes = list_attributes.addClass(class_prefix ~ "__item--parent") %}
{% endif %}
{% if item.in_active_trail == true %}
{% set list_attributes = list_attributes.addClass(class_prefix ~ "__item--active-trail") %}
{% endif %}
{% if item.is_active == true %}
{% set list_attributes = list_attributes.addClass(class_prefix ~ "__item--current") %}
{% set link_attributes = link_attributes.setAttribute('aria-current', 'true') %}
{% endif %}

{# Skip non-trail items below the first level. #}
{% if item.in_active_trail == true or menu_level == 1 or parent.in_active_trail == true %}
<li{{ list_attributes }}>
<a{{ link_attributes }}>
{{ item.title }}
{% if item.unpublished %}
<div class="unpublished-indicator">{{ "Unpublished Page"|t }}</div>
{# Skip non-trail items below the first level. #}
{% if item.in_active_trail == true or menu_level == 1 or parent.in_active_trail == true %}
<li{{ list_attributes }}>
<a{{ link_attributes }}>
{{ item.title }}
{% if item.unpublished %}
<div class="unpublished-indicator">{{ "Unpublished Page"|t }}</div>
{% endif %}
</a>
{% if item.below %}
{{ menus.secondary_nav_menu(item.below, menu_level + 1, class_prefix, item) }}
{% endif %}
</a>
{% if item.below %}
{{ menus.secondary_nav_menu(item.below, menu_level + 1, class_prefix, item) }}
{% endif %}
</li>
{% endif %}
{% endfor %}
</ul>
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
{% endmacro %}
2 changes: 1 addition & 1 deletion templates/menus/menu--secondary-nav.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{%- import "@basic/menus/macros/secondary-nav-menu.twig" as menus -%}
<a href="#main-content" class="visually-hidden focusable su-skipnav su-skipnav--content">{{ 'Skip to main content'|t }}</a>
<nav{{ attributes }}>
<a name="secondary-navigation" id="secondary-navigation" tabindex="-1" class="visually-hidden focusable">{{ 'Secondary Navigation'|t }}</a>
<div id="secondary-navigation" tabindex="-1" class="visually-hidden focusable">{{ 'Secondary Navigation'|t }}</div>
{% spaceless %}
{% if items is iterable %}
{{ menus.secondary_nav_menu(items, 1, 'su-secondary-nav') }}
Expand Down

0 comments on commit 6fe1c42

Please sign in to comment.