Commit 0e6abffd authored by alexpott's avatar alexpott

Issue #2557367 by davidhernandez, joelpittet, madhavvyas, alexpott, nikkyR,...

Issue #2557367 by davidhernandez, joelpittet, madhavvyas, alexpott, nikkyR, Studiographene, emma.maria, xjm: Fix inline list CSS
parent c2af04eb
......@@ -1049,6 +1049,7 @@ function template_preprocess_table(&$variables) {
* @see https://www.drupal.org/node/1842756
*/
function template_preprocess_item_list(&$variables) {
$variables['wrapper_attributes'] = new Attribute($variables['wrapper_attributes']);
foreach ($variables['items'] as &$item) {
$attributes = array();
// If the item value is an array, then it is a render array.
......@@ -1752,7 +1753,7 @@ function drupal_common_theme() {
'variables' => array('status' => MARK_NEW),
),
'item_list' => array(
'variables' => array('items' => array(), 'title' => '', 'list_type' => 'ul', 'attributes' => array(), 'empty' => NULL, 'context' => array()),
'variables' => array('items' => array(), 'title' => '', 'list_type' => 'ul', 'wrapper_attributes' => array(), 'attributes' => array(), 'empty' => NULL, 'context' => array()),
),
'feed_icon' => array(
'variables' => array('url' => NULL, 'title' => NULL),
......
......@@ -589,13 +589,13 @@ function testDatelistWidget() {
protected function datelistDataProvider() {
return [
// Year only selected, validation error on Month, Day, Hour, Minute.
[['year' => 2012, 'month' => '', 'day' => '', 'hour' => '', 'minute' => ''], '4 errors have been found: MonthDayHourMinute'],
[['year' => 2012, 'month' => '', 'day' => '', 'hour' => '', 'minute' => ''], '4 errors have been found: MonthDayHourMinute'],
// Year and Month selected, validation error on Day, Hour, Minute.
[['year' => 2012, 'month' => '12', 'day' => '', 'hour' => '', 'minute' => ''], '3 errors have been found: DayHourMinute'],
[['year' => 2012, 'month' => '12', 'day' => '', 'hour' => '', 'minute' => ''], '3 errors have been found: DayHourMinute'],
// Year, Month and Day selected, validation error on Hour, Minute.
[['year' => 2012, 'month' => '12', 'day' => '31', 'hour' => '', 'minute' => ''], '2 errors have been found: HourMinute'],
[['year' => 2012, 'month' => '12', 'day' => '31', 'hour' => '', 'minute' => ''], '2 errors have been found: HourMinute'],
// Year, Month, Day and Hour selected, validation error on Minute only.
[['year' => 2012, 'month' => '12', 'day' => '31', 'hour' => '0', 'minute' => ''], '1 error has been found: Minute'],
[['year' => 2012, 'month' => '12', 'day' => '31', 'hour' => '0', 'minute' => ''], '1 error has been found: Minute'],
];
}
......
......@@ -275,7 +275,7 @@ public function testFieldAdminHandler() {
$this->drupalPostForm('node/add/' . $this->type, $edit, t('Save'));
// Assert that entity reference autocomplete field is validated.
$this->assertText(t('1 error has been found: Test Entity Reference Field'), 'Node save failed when required entity reference field was not correctly filled.');
$this->assertText(t('1 error has been found: Test Entity Reference Field'), 'Node save failed when required entity reference field was not correctly filled.');
$this->assertText(t('There are no entities matching "@entity"', ['@entity' => 'Test']));
$edit = array(
......@@ -286,7 +286,7 @@ public function testFieldAdminHandler() {
// Assert the results multiple times to avoid sorting problem of nodes with
// the same title.
$this->assertText(t('1 error has been found: Test Entity Reference Field'));
$this->assertText(t('1 error has been found: Test Entity Reference Field'));
$this->assertText(t('Multiple entities match this reference;'));
$this->assertText(t("@node1", ['@node1' => $node1->getTitle() . ' (' . $node1->id() . ')']));
$this->assertText(t("@node2", ['@node2' => $node2->getTitle() . ' (' . $node2->id() . ')']));
......
......@@ -35,7 +35,7 @@ function testRequired() {
$edit = array();
$edit['title[0][value]'] = $this->randomMachineName();
$this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish'));
$this->assertText('1 error has been found: ' . $field->label(), 'Node save failed when required file field was empty.');
$this->assertText('1 error has been found: ' . $field->label(), 'Node save failed when required file field was empty.');
$this->assertIdentical(1, count($this->xpath('//div[contains(concat(" ", normalize-space(@class), " "), :class)]//a', [':class' => ' messages--error '])), 'There is one link in the error message.');
// Create a new node with the uploaded file.
......@@ -57,7 +57,7 @@ function testRequired() {
$edit = array();
$edit['title[0][value]'] = $this->randomMachineName();
$this->drupalPostForm('node/add/' . $type_name, $edit, t('Save and publish'));
$this->assertText('1 error has been found: ' . $field->label(), 'Node save failed when required multiple value file field was empty.');
$this->assertText('1 error has been found: ' . $field->label(), 'Node save failed when required multiple value file field was empty.');
$this->assertIdentical(1, count($this->xpath('//div[contains(concat(" ", normalize-space(@class), " "), :class)]//a', [':class' => ' messages--error '])), 'There is one link in the error message.');
// Create a new node with the uploaded file into the multivalue field.
......
/**
* @file
* Styles for item list.
*/
.item-list__comma-list,
.item-list__comma-list li {
display: inline;
}
.item-list__comma-list {
margin: 0;
padding: 0;
}
.item-list__comma-list li:after {
content: ", ";
}
.item-list__comma-list li:last-child:after {
content: "";
}
......@@ -11,6 +11,7 @@ base:
css/components/clearfix.module.css: { weight: -10 }
css/components/details.module.css: { weight: -10 }
css/components/hidden.module.css: { weight: -10 }
css/components/item-list.module.css: { weight: -10 }
css/components/js.module.css: { weight: -10 }
css/components/nowrap.module.css: { weight: -10 }
css/components/position-container.module.css: { weight: -10 }
......
......@@ -9,6 +9,7 @@
* - value: The content of the list element.
* - title: The title of the list.
* - list_type: The tag for list element ("ul" or "ol").
* - wrapper_attributes: HTML attributes to be applied to the list wrapper.
* - attributes: HTML attributes to be applied to the list.
* - empty: A message to display when there are no items. Allowed value is a
* string or render array.
......@@ -21,9 +22,9 @@
*/
#}
{% if context.list_style %}
{% set attributes = attributes.addClass('item-list__' ~ context.list_style) %}
{%- set attributes = attributes.addClass('item-list__' ~ context.list_style) %}
{% endif %}
{%- if items or empty -%}
{% if items or empty %}
{%- if title is not empty -%}
<h3>{{ title }}</h3>
{%- endif -%}
......
......@@ -25,6 +25,5 @@
.item-list .item-list__comma-list li,
[dir="rtl"] .item-list .item-list__comma-list,
[dir="rtl"] .item-list .item-list__comma-list li {
margin: 0;
padding: 0;
}
......@@ -10,30 +10,23 @@
margin: 0 0 0.75em 0;
padding: 0;
}
.item-list ul li {
.item-list li {
margin: 0 0 0.25em 1.5em; /* LTR */
padding: 0;
}
[dir="rtl"] .item-list ul li {
[dir="rtl"] .item-list li {
margin: 0 1.5em 0.25em 0;
}
ul.item-list__comma-list {
display: inline;
}
ul.item-list__comma-list li {
/**
* Comma separated lists.
*/
.item-list--comma-list {
display: inline;
list-style-type: none;
}
ul.item-list__comma-list,
ul.item-list__comma-list li,
[dir="rtl"] ul.item-list__comma-list,
[dir="rtl"] ul.item-list__comma-list li {
.item-list--comma-list .item-list__comma-list,
.item-list__comma-list li,
[dir="rtl"] .item-list--comma-list .item-list__comma-list,
[dir="rtl"] .item-list__comma-list li {
margin: 0;
padding: 0;
}
ul.item-list__comma-list li:after {
content: ", ";
}
ul.item-list__comma-list li:last-child:after {
content: "";
}
......@@ -9,6 +9,7 @@
* - value: The content of the list element.
* - title: The title of the list.
* - list_type: The tag for list element ("ul" or "ol").
* - wrapper_attributes: HTML attributes to be applied to the list wrapper.
* - attributes: HTML attributes to be applied to the list.
* - empty: A message to display when there are no items. Allowed value is a
* string or render array.
......@@ -19,10 +20,11 @@
*/
#}
{% if context.list_style %}
{% set attributes = attributes.addClass('item-list__' ~ context.list_style) %}
{%- set wrapper_attributes = wrapper_attributes.addClass('item-list--' ~ context.list_style) %}
{%- set attributes = attributes.addClass('item-list__' ~ context.list_style) %}
{% endif %}
{%- if items or empty -%}
<div class="item-list">
{% if items or empty -%}
<div{{ wrapper_attributes.addClass('item-list') }}>
{%- if title is not empty -%}
<h3>{{ title }}</h3>
{%- endif -%}
......
......@@ -38,7 +38,3 @@ ul.inline li {
ul.inline li {
display: inline;
}
.item-list .item-list__comma-list,
[dir="rtl"] .item-list .item-list__comma-list {
margin: 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment