Updated the Bootstrap theme.
[yaffs-website] / web / themes / contrib / bootstrap / templates / system / status-messages.html.twig
1 {#
2 /**
3  * @file
4  * Default theme implementation for status messages.
5  *
6  * Displays status, error, and warning messages, grouped by type.
7  *
8  * An invisible heading identifies the messages for assistive technology.
9  * Sighted users see a colored box. See http://www.w3.org/TR/WCAG-TECHS/H69.html
10  * for info.
11  *
12  * Add an ARIA label to the contentinfo area so that assistive technology
13  * user agents will better describe this landmark.
14  *
15  * Available variables:
16  * - message_list: List of messages to be displayed, grouped by type.
17  * - status_headings: List of all status types.
18  * - display: (optional) May have a value of 'status' or 'error' when only
19  *   displaying messages of that specific type.
20  * - attributes: HTML attributes for the element, including:
21  *   - class: HTML classes.
22  *
23  * @ingroup templates
24  *
25  * @see template_preprocess_status_messages()
26  */
27 #}
28 {# Save original attribute classes. This is needed to override in loop below. #}
29 {# @see https://www.drupal.org/project/bootstrap/issues/2892936 #}
30 {% set classes = attributes.offsetGet('class')|default({}) %}
31 {%
32   set status_heading = {
33     'status': 'Status message'|t,
34     'error': 'Error message'|t,
35     'warning': 'Warning message'|t,
36     'info': 'Informative message'|t,
37   }
38 %}
39 {%
40   set status_classes = {
41     'status': 'success',
42     'error': 'danger',
43     'warning': 'warning',
44     'info': 'info',
45   }
46 %}
47 {% for type, messages in message_list %}
48   {%
49     set message_classes = [
50       'alert',
51       'alert-' ~ status_classes[type],
52       'alert-dismissible',
53     ]
54   %}
55   {# Reset the attribute classes and then add the message specific classes. #}
56   <div{{ attributes.setAttribute('class', classes).addClass(message_classes).setAttribute('role', 'alert') }}>
57     <button role="button" class="close" data-dismiss="alert" aria-label="{{ 'Close'|t }}"><span aria-hidden="true">&times;</span></button>
58     {% if status_headings[type] %}
59       <h4 class="sr-only">{{ status_headings[type] }}</h4>
60     {% endif %}
61     {% if messages|length > 1 %}
62       <ul class="item-list item-list--messages">
63         {% for message in messages %}
64           <li class="item item--message">{{ message }}</li>
65         {% endfor %}
66       </ul>
67     {% else %}
68       {{ messages|first }}
69     {% endif %}
70   </div>
71 {% endfor %}