From 2eaa3d557faffadb4db93ac78b39e48ef634a36a Mon Sep 17 00:00:00 2001 From: Evan Willhite Date: Tue, 3 Oct 2017 10:25:56 -0500 Subject: [PATCH 1/2] Better handling of class inheritance for drupal --- components/_patterns/02-molecules/menus/_menu-item.twig | 8 +++++++- components/_patterns/02-molecules/menus/_menu.twig | 8 ++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/components/_patterns/02-molecules/menus/_menu-item.twig b/components/_patterns/02-molecules/menus/_menu-item.twig index 9cf357bc..86f5dae9 100644 --- a/components/_patterns/02-molecules/menus/_menu-item.twig +++ b/components/_patterns/02-molecules/menus/_menu-item.twig @@ -1,4 +1,6 @@ -{% set item_modifiers = [] %} +{% if not item_modifiers %} + {% set item_modifiers = [] %} +{% endif %} {% if item.in_active_trail == TRUE %} {% set item_modifiers = item_modifiers|merge(['active']) %} {% endif %} @@ -8,6 +10,10 @@ {% if item.below %} {% set item_modifiers = item_modifiers|merge(['with-sub']) %} {% endif %} +{# below could maybe be done without a loop? #} +{% for modifier in item.modifiers %} + {% set item_modifiers = item_modifiers|merge([modifier]) %} +{% endfor %} {% embed "@atoms/03-lists/_list-item.twig" with { "list_item_label": item_label, diff --git a/components/_patterns/02-molecules/menus/_menu.twig b/components/_patterns/02-molecules/menus/_menu.twig index fabed8c7..3439c929 100644 --- a/components/_patterns/02-molecules/menus/_menu.twig +++ b/components/_patterns/02-molecules/menus/_menu.twig @@ -26,7 +26,7 @@ #} {{ menus.menu_links(items, attributes, 0, menu_class, menu_modifiers, menu_blockname, item_base_class, item_modifiers, item_blockname) }} -{% macro menu_links(items, attributes, menu_level, menu_class, menu_modifiers, menu_blockname) %} +{% macro menu_links(items, attributes, menu_level, menu_class, menu_modifiers, menu_blockname, item_base_class, item_modifiers, item_blockname) %} {% import _self as menus %} {% if items %} @@ -47,7 +47,11 @@ } %} {% block list_content %} {% for item in items %} - {% include "@molecules/menus/_menu-item.twig" %} + {% include "@molecules/menus/_menu-item.twig" with { + li_base_class: item_base_class, + li_modifiers: item_modifiers, + li_blockname: item_blockname, + } %} {% endfor %} {% endblock %} {% endembed %} From 9f77409bfdb212d29cc802ec2bd6916405525033 Mon Sep 17 00:00:00 2001 From: Evan Willhite Date: Tue, 3 Oct 2017 10:29:24 -0500 Subject: [PATCH 2/2] Drupal block menu file to remove nav element (provided in component) --- .../block/block--mainnavigation.html.twig | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 templates/block/block--mainnavigation.html.twig diff --git a/templates/block/block--mainnavigation.html.twig b/templates/block/block--mainnavigation.html.twig new file mode 100644 index 00000000..d599345c --- /dev/null +++ b/templates/block/block--mainnavigation.html.twig @@ -0,0 +1,49 @@ +{# +/** + * @file + * Theme override for a menu block. + * + * Available variables: + * - plugin_id: The ID of the block implementation. + * - label: The configured label of the block if visible. + * - configuration: A list of the block's configuration values. + * - label: The configured label for the block. + * - label_display: The display settings for the label. + * - provider: The module or other provider that provided this block plugin. + * - Block plugin specific settings will also be stored here. + * - content: The content of this block. + * - attributes: HTML attributes for the containing element. + * - id: A valid HTML ID and guaranteed unique. + * - title_attributes: HTML attributes for the title element. + * - content_attributes: HTML attributes for the content element. + * - title_prefix: Additional output populated by modules, intended to be + * displayed in front of the main title tag that appears in the template. + * - title_suffix: Additional output populated by modules, intended to be + * displayed after the main title tag that appears in the template. + * + * Headings should be used on navigation menus that consistently appear on + * multiple pages. When this menu block's label is configured to not be + * displayed, it is automatically made invisible using the 'visually-hidden' CSS + * class, which still keeps it visible for screen-readers and assistive + * technology. Headings allow screen-reader and keyboard only users to navigate + * to or skip the links. + * See http://juicystudio.com/article/screen-readers-display-none.php and + * http://www.w3.org/TR/WCAG-TECHS/H42.html for more information. + */ +#} + +{# Label. If not displayed, we still provide it for screen readers. #} +{% if not configuration.label_display %} + {% set title_attributes = title_attributes.addClass('visually-hidden') %} +{% endif %} +{{ title_prefix }} +{% include "@atoms/02-text/00-headings/_heading.twig" with { + "heading_level": 2, + "heading": label, +} %} +{{ title_suffix }} + +{# Menu. #} +{% block content %} + {{ content }} +{% endblock %}