Chris@0
|
1 {#
|
Chris@0
|
2 /**
|
Chris@0
|
3 * @file
|
Chris@0
|
4 * Theme override for status messages.
|
Chris@0
|
5 *
|
Chris@0
|
6 * Displays status, error, and warning messages, grouped by type.
|
Chris@0
|
7 *
|
Chris@0
|
8 * An invisible heading identifies the messages for assistive technology.
|
Chris@0
|
9 * Sighted users see a colored box. See http://www.w3.org/TR/WCAG-TECHS/H69.html
|
Chris@0
|
10 * for info.
|
Chris@0
|
11 *
|
Chris@0
|
12 * Add an ARIA label to the contentinfo area so that assistive technology
|
Chris@0
|
13 * user agents will better describe this landmark.
|
Chris@0
|
14 *
|
Chris@0
|
15 * Available variables:
|
Chris@0
|
16 * - message_list: List of messages to be displayed, grouped by type.
|
Chris@0
|
17 * - status_headings: List of all status types.
|
Chris@0
|
18 * - attributes: HTML attributes for the element, including:
|
Chris@0
|
19 * - class: HTML classes.
|
Chris@0
|
20 */
|
Chris@0
|
21 #}
|
Chris@0
|
22 {% block messages %}
|
Chris@0
|
23 {% for type, messages in message_list %}
|
Chris@0
|
24 {%
|
Chris@0
|
25 set classes = [
|
Chris@0
|
26 'messages',
|
Chris@0
|
27 'messages--' ~ type,
|
Chris@0
|
28 ]
|
Chris@0
|
29 %}
|
Chris@0
|
30 <div role="contentinfo" aria-label="{{ status_headings[type] }}"{{ attributes.addClass(classes)|without('role', 'aria-label') }}>
|
Chris@0
|
31 {% if type == 'error' %}
|
Chris@0
|
32 <div role="alert">
|
Chris@0
|
33 {% endif %}
|
Chris@0
|
34 {% if status_headings[type] %}
|
Chris@0
|
35 <h2 class="visually-hidden">{{ status_headings[type] }}</h2>
|
Chris@0
|
36 {% endif %}
|
Chris@0
|
37 {% if messages|length > 1 %}
|
Chris@0
|
38 <ul class="messages__list">
|
Chris@0
|
39 {% for message in messages %}
|
Chris@0
|
40 <li class="messages__item">{{ message }}</li>
|
Chris@0
|
41 {% endfor %}
|
Chris@0
|
42 </ul>
|
Chris@0
|
43 {% else %}
|
Chris@0
|
44 {{ messages|first }}
|
Chris@0
|
45 {% endif %}
|
Chris@0
|
46 {% if type == 'error' %}
|
Chris@0
|
47 </div>
|
Chris@0
|
48 {% endif %}
|
Chris@0
|
49 </div>
|
Chris@0
|
50 {# Remove type specific classes. #}
|
Chris@0
|
51 {% set attributes = attributes.removeClass(classes) %}
|
Chris@0
|
52 {% endfor %}
|
Chris@0
|
53 {% endblock messages %}
|