core/modules/block/block.module | 1 - core/modules/block/src/Tests/BlockHtmlTest.php | 2 +- .../system/src/Tests/Menu/BreadcrumbTest.php | 2 +- core/modules/system/system.module | 2 ++ .../templates/block--system-menu-block.html.twig | 34 ++++++++++++++++++---- .../views/src/Tests/Plugin/DisplayPageWebTest.php | 4 +-- core/themes/bartik/css/style.css | 7 ++--- .../templates/block--system-menu-block.html.twig | 2 +- 8 files changed, 38 insertions(+), 16 deletions(-) diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 9582874..339d163 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -267,7 +267,6 @@ function template_preprocess_block(&$variables) { $variables['base_plugin_id'] = $variables['elements']['#base_plugin_id']; $variables['derivative_plugin_id'] = $variables['elements']['#derivative_plugin_id']; $variables['label'] = !empty($variables['configuration']['label_display']) ? $variables['configuration']['label'] : ''; - $variables['label_display'] = $variables['configuration']['label_display']; $variables['content'] = $variables['elements']['content']; // A block's label is configuration: it is static. Allow dynamic labels to be // set in the render array. diff --git a/core/modules/block/src/Tests/BlockHtmlTest.php b/core/modules/block/src/Tests/BlockHtmlTest.php index b6cb078..955955a 100644 --- a/core/modules/block/src/Tests/BlockHtmlTest.php +++ b/core/modules/block/src/Tests/BlockHtmlTest.php @@ -48,7 +48,7 @@ function testHtml() { $this->assertFieldByXPath('//div[@id="block-test-html-block" and @data-custom-attribute="foo"]', NULL, 'HTML ID and attributes for test block are valid and on the same DOM element.'); // Ensure expected markup for a menu block. - $elements = $this->xpath('//div[contains(@class, :div-class)]/div/ul[contains(@class, :ul-class)]/li', array(':div-class' => 'block-system', ':ul-class' => 'menu')); + $elements = $this->xpath('//nav[contains(@class, :nav-class)]/div/ul[contains(@class, :ul-class)]/li', array(':nav-class' => 'block-menu', ':ul-class' => 'menu')); $this->assertTrue(!empty($elements), 'The proper block markup was found.'); } diff --git a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php index ea55662..cf5ab1a 100644 --- a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php +++ b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php @@ -278,7 +278,7 @@ function testBreadCrumbs() { // untranslated menu links automatically generated from menu router items // ('taxonomy/term/%') should never be translated and appear in any menu // other than the breadcrumb trail. - $elements = $this->xpath('//div[@id=:menu]/descendant::a[@href=:href]', array( + $elements = $this->xpath('//nav[@id=:menu]/descendant::a[@href=:href]', array( ':menu' => 'block-bartik-tools', ':href' => url($link_path), )); diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 6142dfc..f6d1418 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -157,10 +157,12 @@ function system_theme() { // themes. We explicitly define theme suggestions here so that the block // templates in core/modules/system/templates are picked up. 'block__system_branding_block' => array( + 'render element' => 'elements', 'base hook' => 'block', 'template' => 'block--system-branding-block', ), 'block__system_menu_block' => array( + 'render element' => 'elements', 'base hook' => 'block', 'template' => 'block--system-menu-block', ), diff --git a/core/modules/system/templates/block--system-menu-block.html.twig b/core/modules/system/templates/block--system-menu-block.html.twig index acadc15..6c0fbe6 100644 --- a/core/modules/system/templates/block--system-menu-block.html.twig +++ b/core/modules/system/templates/block--system-menu-block.html.twig @@ -4,7 +4,29 @@ * Default theme implementation 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. + * - module: The module that provided this block plugin. + * - cache: The cache settings. + * - Block plugin specific settings will also be stored here. + * - block - The full block entity. + * - label_hidden: The hidden block title value if the block was + * configured to hide the title ('label' is empty in this case). + * - module: The module that generated the block. + * - delta: An ID for the block, unique within each module. + * - region: The block region embedding the current block. + * - 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 appears on * multiple pages. When this menu block's label is configured to not be @@ -27,22 +49,22 @@ %} {% set heading_id = attributes.id ~ '-menu'|clean_id %} - {# Block title. If not displayed, we still provide it for screen readers. #} - {% if not label_display %} + {# 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 }}

{{ configuration.label }}

{{ title_suffix }} - {# Menu #} - {% if label_display %} + {# Menu. If no label is displayed, don't wrap it in
. #} + {% if configuration.label_display %} {% endif %} {% block content %} {{ content }} {% endblock %} - {% if label_display %} + {% if configuration.label_display %}
{% endif %} diff --git a/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php b/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php index 3750601..d975a80 100644 --- a/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php +++ b/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php @@ -108,7 +108,7 @@ public function testPageDisplayMenu() { $this->drupalPlaceBlock('system_menu_block:tools'); $this->drupalGet(''); - $menu_link = $this->cssSelect('div.block-menu ul.menu a'); + $menu_link = $this->cssSelect('nav.block-menu ul.menu a'); $this->assertEqual((string) $menu_link[0], 'Test menu link'); // Update the menu link. @@ -117,7 +117,7 @@ public function testPageDisplayMenu() { ], t('Save')); $this->drupalGet(''); - $menu_link = $this->cssSelect('div.block-menu ul.menu a'); + $menu_link = $this->cssSelect('nav.block-menu ul.menu a'); $this->assertEqual((string) $menu_link[0], 'New title'); } diff --git a/core/themes/bartik/css/style.css b/core/themes/bartik/css/style.css index 29ecdc4..9a7ad23 100644 --- a/core/themes/bartik/css/style.css +++ b/core/themes/bartik/css/style.css @@ -652,10 +652,9 @@ body:not(:target) #header .block-menu:first-child .menu-toggle-target-show:targe /* --------------- Secondary Menu ------------ */ #header .block-menu:nth-child(2) { - border: 1px solid red; - position: absolute; - top: 0; - right: 0; /* LTR */ + position: absolute; + top: 0; + right: 0; /* LTR */ } [dir="rtl"] #header .block-menu:nth-child(2) { right: inherit; diff --git a/core/themes/bartik/templates/block--system-menu-block.html.twig b/core/themes/bartik/templates/block--system-menu-block.html.twig index 1e81581..b6c0412 100644 --- a/core/themes/bartik/templates/block--system-menu-block.html.twig +++ b/core/themes/bartik/templates/block--system-menu-block.html.twig @@ -12,7 +12,7 @@ {% set hide_anchor = "hide-" ~ attributes.id|clean_id %} {% block content %} {# When rendering a menu without label, render a menu toggle. #} - {% if not label_display %} + {% if not configuration.label_display %} {{ 'Menu'|t }}