diff --git a/core/modules/comment/config/install/views.view.comments_recent.yml b/core/modules/comment/config/install/views.view.comments_recent.yml index 98b0ce1d2a63b1..7a4b5596fc9c4e 100644 --- a/core/modules/comment/config/install/views.view.comments_recent.yml +++ b/core/modules/comment/config/install/views.view.comments_recent.yml @@ -45,6 +45,7 @@ display: row_class: '' default_row_class: true type: ul + wrapper_class: item-list class: '' provider: views row: diff --git a/core/modules/simpletest/css/simpletest.module.css b/core/modules/simpletest/css/simpletest.module.css index 88c45644fa1c0b..71f7eea132b155 100644 --- a/core/modules/simpletest/css/simpletest.module.css +++ b/core/modules/simpletest/css/simpletest.module.css @@ -35,7 +35,7 @@ table#simpletest-form-table tr.simpletest-group label { display: inline; } -div.message > ul { +div.message > div.item-list { font-weight: normal; } diff --git a/core/modules/system/css/system.theme.css b/core/modules/system/css/system.theme.css index 0f1d8aef7758aa..bf1433952b951f 100644 --- a/core/modules/system/css/system.theme.css +++ b/core/modules/system/css/system.theme.css @@ -20,6 +20,24 @@ td.active { background-color: #ddd; } +/** + * Markup generated by theme_item_list(). + */ +.item-list .title { + font-weight: bold; +} +.item-list ul { + margin: 0 0 0.75em 0; + padding: 0; +} +.item-list ul li { + margin: 0 0 0.25em 1.5em; /* LTR */ + padding: 0; +} +[dir="rtl"] .item-list ul li { + margin: 0 1.5em 0.25em 0; +} + /** * Markup generated by Form API. */ diff --git a/core/modules/system/src/Tests/Theme/FunctionsTest.php b/core/modules/system/src/Tests/Theme/FunctionsTest.php index 0e55865c27f5ca..c8d068cb747d71 100644 --- a/core/modules/system/src/Tests/Theme/FunctionsTest.php +++ b/core/modules/system/src/Tests/Theme/FunctionsTest.php @@ -44,21 +44,21 @@ class FunctionsTest extends WebTestBase { // Verify that empty items produce the empty string. $variables = array(); $variables['empty'] = 'No items found.'; - $expected = 'No items found.'; + $expected = '
No items found.
'; $this->assertThemeOutput('item_list', $variables, $expected, 'Empty %callback generates empty string.'); // Verify that empty items produce the empty string with title. $variables = array(); $variables['title'] = 'Some title'; $variables['empty'] = 'No items found.'; - $expected = '

Some title

No items found.'; + $expected = '

Some title

No items found.
'; $this->assertThemeOutput('item_list', $variables, $expected, 'Empty %callback generates empty string with title.'); // Verify that title set to 0 is output. $variables = array(); $variables['title'] = 0; $variables['empty'] = 'No items found.'; - $expected = '

0

No items found.'; + $expected = '

0

No items found.
'; $this->assertThemeOutput('item_list', $variables, $expected, '%callback with title set to 0 generates a title.'); // Verify that title set to a render array is output. @@ -67,7 +67,7 @@ class FunctionsTest extends WebTestBase { '#markup' => 'Render array', ); $variables['empty'] = 'No items found.'; - $expected = '

Render array

No items found.'; + $expected = '

Render array

No items found.
'; $this->assertThemeOutput('item_list', $variables, $expected, '%callback with title set to a render array generates a title.'); // Verify that empty text is not displayed when there are list items. @@ -75,7 +75,7 @@ class FunctionsTest extends WebTestBase { $variables['title'] = 'Some title'; $variables['empty'] = 'No items found.'; $variables['items'] = array('Un', 'Deux', 'Trois'); - $expected = '

Some title

'; + $expected = '

Some title

'; $this->assertThemeOutput('item_list', $variables, $expected, '%callback does not print empty text when there are list items.'); // Verify nested item lists. @@ -136,23 +136,24 @@ class FunctionsTest extends WebTestBase { 'f', ); - $inner_b = '
    '; + $inner_b = '
      '; $inner_b .= '
    1. ba
    2. '; $inner_b .= '
    3. bb
    4. '; - $inner_b .= '
    '; + $inner_b .= '
'; - $inner_cb = ''; - $inner_c = ''; - $expected = '

Some title

'; + $expected = '
'; + $expected .= '

Some title

'; $expected .= ''; + $expected .= '
'; $this->assertThemeOutput('item_list', $variables, $expected); } diff --git a/core/modules/system/templates/item-list.html.twig b/core/modules/system/templates/item-list.html.twig index 2a59319b89d5b3..bd71e7f96058a6 100644 --- a/core/modules/system/templates/item-list.html.twig +++ b/core/modules/system/templates/item-list.html.twig @@ -19,16 +19,18 @@ */ #} {%- if items or empty -%} - {%- if title is not empty -%} -

{{ title }}

- {%- endif -%} - {%- if items -%} - <{{ list_type }}{{ attributes }}> - {%- for item in items -%} - {{ item.value }} - {%- endfor -%} - - {%- else -%} - {{- empty -}} - {%- endif -%} +
+ {%- if title is not empty -%} +

{{ title }}

+ {%- endif -%} + {%- if items -%} + <{{ list_type }}{{ attributes }}> + {%- for item in items -%} + {{ item.value }} + {%- endfor -%} + + {%- else -%} + {{- empty -}} + {%- endif -%} +
{%- endif %} diff --git a/core/modules/toolbar/css/toolbar.module.css b/core/modules/toolbar/css/toolbar.module.css index 30661d7af5de12..06224fe2fd5074 100644 --- a/core/modules/toolbar/css/toolbar.module.css +++ b/core/modules/toolbar/css/toolbar.module.css @@ -20,9 +20,10 @@ /** * Very specific overrides for Drupal system CSS. */ -.toolbar ul, .toolbar li, .toolbar .menu li, +.toolbar .item-list, +.toolbar .item-list li, .toolbar .menu li.expanded { list-style-type: none; list-style-image: none; diff --git a/core/modules/user/config/install/views.view.who_s_online.yml b/core/modules/user/config/install/views.view.who_s_online.yml index 0109ebd1923012..5b2208224fb233 100644 --- a/core/modules/user/config/install/views.view.who_s_online.yml +++ b/core/modules/user/config/install/views.view.who_s_online.yml @@ -52,6 +52,7 @@ display: row_class: '' default_row_class: true type: ul + wrapper_class: item-list class: '' provider: views row: diff --git a/core/modules/user/src/Tests/UserAdminListingTest.php b/core/modules/user/src/Tests/UserAdminListingTest.php index 0a45c5edab7300..65e9ef33c4fadf 100644 --- a/core/modules/user/src/Tests/UserAdminListingTest.php +++ b/core/modules/user/src/Tests/UserAdminListingTest.php @@ -69,8 +69,8 @@ class UserAdminListingTest extends WebTestBase { foreach ($result as $account) { $name = (string) $account->td[0]->span; $roles = array(); - if (isset($account->td[2]->ul)) { - foreach ($account->td[2]->ul->li as $element) { + if (isset($account->td[2]->div->ul)) { + foreach ($account->td[2]->div->ul->li as $element) { $roles[] = (string) $element; } } diff --git a/core/modules/views/src/Plugin/views/style/HtmlList.php b/core/modules/views/src/Plugin/views/style/HtmlList.php index b98b03052027f3..d9657927001476 100644 --- a/core/modules/views/src/Plugin/views/style/HtmlList.php +++ b/core/modules/views/src/Plugin/views/style/HtmlList.php @@ -46,6 +46,7 @@ class HtmlList extends StylePluginBase { $options['type'] = array('default' => 'ul'); $options['class'] = array('default' => ''); + $options['wrapper_class'] = array('default' => 'item-list'); return $options; } @@ -61,6 +62,13 @@ class HtmlList extends StylePluginBase { '#options' => array('ul' => $this->t('Unordered list'), 'ol' => $this->t('Ordered list')), '#default_value' => $this->options['type'], ); + $form['wrapper_class'] = array( + '#title' => $this->t('Wrapper class'), + '#description' => $this->t('The class to provide on the wrapper, outside the list.'), + '#type' => 'textfield', + '#size' => '30', + '#default_value' => $this->options['wrapper_class'], + ); $form['class'] = array( '#title' => $this->t('List class'), '#description' => $this->t('The class to provide on the list element itself.'), diff --git a/core/modules/views/src/Tests/Plugin/StyleHtmlListTest.php b/core/modules/views/src/Tests/Plugin/StyleHtmlListTest.php index 65d5db79290428..0642eff0b46972 100644 --- a/core/modules/views/src/Tests/Plugin/StyleHtmlListTest.php +++ b/core/modules/views/src/Tests/Plugin/StyleHtmlListTest.php @@ -33,16 +33,24 @@ class StyleHtmlListTest extends ViewUnitTestBase { $output = $view->preview(); $output = drupal_render($output); + // Check that an empty class attribute is not added if the wrapper class is + // not set. + $this->assertTrue(strpos($output, '
') !== FALSE, 'Empty class is not added to DIV when class is not set'); + // Check that an empty class attribute is not added if the list class is // not set. $this->assertTrue(strpos($output, '