Skip to content

Commit d66167a

Browse files
author
Callin Mullaney
committed
feat: set base class as a variable for some templates
1 parent 2be47c7 commit d66167a

6 files changed

Lines changed: 56 additions & 36 deletions

templates/admin/locale-translation-update-info.html.twig

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,19 @@
1313
* @see \Drupal\locale\Hook\LocaleThemeHooks::preprocessLocaleTranslationUpdateInfo()
1414
*/
1515
#}
16-
<div{{ bem('wrapper', [], 'locale-translation-update') }} tabindex="0" role="button">
17-
<span{{ bem('prefix', [], 'locale-translation-update', ['visually-hidden']) }}>Show description</span>
16+
{% set locale_translation_update_block = 'locale-translation-update' %}
17+
{% set locale_translation_update_wrapper_attributes = {
18+
class: bem('wrapper', [], locale_translation_update_block),
19+
tabindex: '0',
20+
role: 'button',
21+
} %}
22+
<div{{ add_attributes(locale_translation_update_wrapper_attributes) }}>
23+
<span{{ bem('prefix', [], locale_translation_update_block, ['visually-hidden']) }}>Show description</span>
1824
{% if modules %}
1925
{% set module_list = modules|safe_join(', ') %}
20-
<span{{ bem('message', [], 'locale-translation-update') }}>{% trans %}Updates for: {{ module_list }}{% endtrans %}</span>
26+
<span{{ bem('message', [], locale_translation_update_block) }}>{% trans %}Updates for: {{ module_list }}{% endtrans %}</span>
2127
{% elseif not_found %}
22-
<span{{ bem('message', [], 'locale-translation-update') }}>
28+
<span{{ bem('message', [], locale_translation_update_block) }}>
2329
{%- trans -%}
2430
Missing translations for one project
2531
{%- plural not_found|length -%}
@@ -28,7 +34,7 @@
2834
</span>
2935
{% endif %}
3036
{% if updates or not_found %}
31-
<div{{ bem('details', [], 'locale-translation-update') }}>
37+
<div{{ bem('details', [], locale_translation_update_block) }}>
3238
{% if updates %}
3339
<ul>
3440
{% for update in updates %}

templates/admin/status-report-general-info.html.twig

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,18 @@
2929
* server.
3030
*/
3131
#}
32+
{% set system_status_general_info_block = 'system-status-general-info' %}
3233

3334
<h2>{{ 'General System Information'|t }}</h2>
34-
<div{{ bem('item', [], 'system-status-general-info') }}>
35-
<h3{{ bem('item-title', [], 'system-status-general-info') }}>{{ 'Drupal Version'|t }}</h3>
35+
<div{{ bem('item', [], system_status_general_info_block) }}>
36+
<h3{{ bem('item-title', [], system_status_general_info_block) }}>{{ 'Drupal Version'|t }}</h3>
3637
{{ drupal.value }}
3738
{% if drupal.description %}
3839
{{ drupal.description }}
3940
{% endif %}
4041
</div>
41-
<div{{ bem('item', [], 'system-status-general-info') }}>
42-
<h3{{ bem('item-title', [], 'system-status-general-info') }}>{{ 'Last Cron Run'|t }}</h3>
42+
<div{{ bem('item', [], system_status_general_info_block) }}>
43+
<h3{{ bem('item-title', [], system_status_general_info_block) }}>{{ 'Last Cron Run'|t }}</h3>
4344
{{ cron.value }}
4445
{% if cron.run_cron %}
4546
{{ cron.run_cron }}
@@ -48,15 +49,15 @@
4849
{{ cron.description }}
4950
{% endif %}
5051
</div>
51-
<div{{ bem('item', [], 'system-status-general-info') }}>
52-
<h3{{ bem('item-title', [], 'system-status-general-info') }}>{{ 'Web Server'|t }}</h3>
52+
<div{{ bem('item', [], system_status_general_info_block) }}>
53+
<h3{{ bem('item-title', [], system_status_general_info_block) }}>{{ 'Web Server'|t }}</h3>
5354
{{ webserver.value }}
5455
{% if webserver.description %}
5556
{{ webserver.description }}
5657
{% endif %}
5758
</div>
58-
<div{{ bem('item', [], 'system-status-general-info') }}>
59-
<h3{{ bem('item-title', [], 'system-status-general-info') }}>{{ 'PHP'|t }}</h3>
59+
<div{{ bem('item', [], system_status_general_info_block) }}>
60+
<h3{{ bem('item-title', [], system_status_general_info_block) }}>{{ 'PHP'|t }}</h3>
6061
<h4>{{ 'Version'|t }}</h4> {{ php.value }}
6162
{% if php.description %}
6263
{{ php.description }}
@@ -67,8 +68,8 @@
6768
{{ php_memory_limit.description }}
6869
{% endif %}
6970
</div>
70-
<div{{ bem('item', [], 'system-status-general-info') }}>
71-
<h3{{ bem('item-title', [], 'system-status-general-info') }}>{{ 'Database'|t }}</h3>
71+
<div{{ bem('item', [], system_status_general_info_block) }}>
72+
<h3{{ bem('item-title', [], system_status_general_info_block) }}>{{ 'Database'|t }}</h3>
7273
<h4>{{ 'Version'|t }}</h4>{{ database_system_version.value }}
7374
{% if database_system_version.description %}
7475
{{ database_system_version.description }}

templates/admin/update-project-status.html.twig

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,33 @@
3434
project.status == constant('Drupal\\update\\UpdateManagerInterface::CURRENT') ? 'current',
3535
]|filter(v => v is not empty)
3636
%}
37+
{% set project_update_block = 'project-update' %}
38+
{% set project_updates_block = 'project-updates' %}
3739
{% with { attributes: status.attributes } %}
3840
{% set project_status_attributes = {
39-
class: bem('status', status_modifiers, 'project-update'),
41+
class: bem('status', status_modifiers, project_update_block),
4042
} %}
4143
<div{{ add_attributes(project_status_attributes) }}>
4244
{%- if status.label -%}
4345
<span>{{ status.label }}</span>
4446
{%- else -%}
4547
{{ status.reason }}
4648
{%- endif %}
47-
<span{{ bem('status-icon', [], 'project-update') }}>
49+
<span{{ bem('status-icon', [], project_update_block) }}>
4850
{{ status.icon }}
4951
</span>
5052
</div>
5153
{% endwith %}
5254

53-
<div{{ bem('title', [], 'project-update') }}>
55+
<div{{ bem('title', [], project_update_block) }}>
5456
{%- if url -%}
5557
<a href="{{ url }}">{{ title }}</a>
5658
{%- else -%}
5759
{{ title }}
5860
{%- endif %}
5961
{{ existing_version }}
6062
{% if install_type == 'dev' and datestamp %}
61-
<span{{ bem('version-date', [], 'project-update') }}>({{ datestamp }})</span>
63+
<span{{ bem('version-date', [], project_update_block) }}>({{ datestamp }})</span>
6264
{% endif %}
6365
</div>
6466

@@ -75,7 +77,7 @@
7577
project.status == constant('Drupal\\update\\UpdateManagerInterface::NOT_SUPPORTED') ? 'project-not-supported',
7678
]
7779
%}
78-
<div{{ bem('details', [], 'project-updates') }}>
80+
<div{{ bem('details', [], project_updates_block) }}>
7981
{% if extras %}
8082
<div class="extra">
8183
{% for extra in extras %}

templates/admin/update-version.html.twig

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,29 @@
2323
* @see \Drupal\update\Hook\UpdateThemeHooks::preprocessUpdateVersion()
2424
*/
2525
#}
26+
{% set project_update_block = 'project-update' %}
2627
{% set update_version_attributes = {
27-
class: bem('version', [], 'project-update'),
28+
class: bem('version', [], project_update_block),
2829
} %}
2930
<div{{ add_attributes(update_version_attributes) }}>
3031
<div class="clearfix">
31-
<div{{ bem('version-title', [], 'project-update', ['layout-column', 'layout-column--quarter']) }}>{{ title }}</div>
32-
<div{{ bem('version-details', [], 'project-update', ['layout-column', 'layout-column--quarter']) }}>
32+
<div{{ bem('version-title', [], project_update_block, ['layout-column', 'layout-column--quarter']) }}>{{ title }}</div>
33+
<div{{ bem('version-details', [], project_update_block, ['layout-column', 'layout-column--quarter']) }}>
3334
<a href="{{ version.release_link }}">{{ version.version }}</a>
34-
<span{{ bem('version-date', [], 'project-update') }}>({{ version.date|date('Y-M-d') }})</span>
35+
<span{{ bem('version-date', [], project_update_block) }}>({{ version.date|date('Y-M-d') }})</span>
3536
</div>
3637
<div class="layout-column layout-column--half">
37-
<ul{{ bem('version-links', [], 'project-update') }}>
38+
<ul{{ bem('version-links', [], project_update_block) }}>
3839
{% if version.core_compatible is not defined or version.core_compatible %}
39-
<li{{ bem('download-link', [], 'project-update') }}>
40+
<li{{ bem('download-link', [], project_update_block) }}>
4041
<a href="{{ version.download_link }}">{{ 'Download'|t }}</a>
4142
</li>
4243
{% endif %}
43-
<li{{ bem('release-notes-link', [], 'project-update') }}>
44+
<li{{ bem('release-notes-link', [], project_update_block) }}>
4445
<a href="{{ version.release_link }}">{{ 'Release notes'|t }}</a>
4546
</li>
4647
{% if core_compatibility_details %}
47-
<li{{ bem('compatibility-details', [], 'project-update') }}>
48+
<li{{ bem('compatibility-details', [], project_update_block) }}>
4849
{{ core_compatibility_details }}
4950
</li>
5051
{% endif %}

templates/media-library/progress-bar.html.twig

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,20 @@
1111
* - message: A string containing information to be displayed.
1212
*/
1313
#}
14-
<div{{ bem('progress') }} data-drupal-progress>
14+
{% set progress_block = 'progress' %}
15+
{% set progress_attributes = {
16+
class: bem(progress_block),
17+
'data-drupal-progress': true,
18+
} %}
19+
{% set progress_bar_attributes = {
20+
class: bem('bar', [], progress_block),
21+
style: 'width: ' ~ percent ~ '%',
22+
} %}
23+
<div{{ add_attributes(progress_attributes) }}>
1524
{% if label %}
16-
<div{{ bem('label', [], 'progress') }}>{{ label }}</div>
25+
<div{{ bem('label', [], progress_block) }}>{{ label }}</div>
1726
{% endif %}
18-
<div{{ bem('track', [], 'progress') }}><div{{ bem('bar', [], 'progress') }} style="width: {{ percent }}%"></div></div>
19-
<div{{ bem('percentage', [], 'progress') }}>{{ percent }}%</div>
20-
<div{{ bem('description', [], 'progress') }}>{{ message }}</div>
27+
<div{{ bem('track', [], progress_block) }}><div{{ add_attributes(progress_bar_attributes) }}></div></div>
28+
<div{{ bem('percentage', [], progress_block) }}>{{ percent }}%</div>
29+
<div{{ bem('description', [], progress_block) }}>{{ message }}</div>
2130
</div>

templates/navigation/navigation--message.html.twig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
* @ingroup themeable
1010
*/
1111
#}
12+
{% set toolbar_message_block = 'toolbar-message' %}
1213
{%
13-
set classes = bem('toolbar-message', ['type--' ~ type])
14+
set classes = bem(toolbar_message_block, ['type--' ~ type])
1415
%}
1516
{% set navigation_message_link_attributes = {
1617
class: classes,
@@ -25,14 +26,14 @@
2526
{% if url is not empty %}
2627
<a{{ add_attributes(navigation_message_link_attributes) }}>
2728
{{ icon('navigation', type, { class: 'toolbar-message__icon', size: 20 }) }}
28-
<div{{ bem('label', [], 'toolbar-message') }}>
29+
<div{{ bem('label', [], toolbar_message_block) }}>
2930
{{ content }}
3031
</div>
3132
</a>
3233
{% else %}
3334
<div{{ add_attributes(navigation_message_attributes) }}>
3435
{{ icon('navigation', type, { class: 'toolbar-message__icon', size: 20 }) }}
35-
<div{{ bem('label', [], 'toolbar-message') }}>
36+
<div{{ bem('label', [], toolbar_message_block) }}>
3637
{{ content }}
3738
</div>
3839
</div>

0 commit comments

Comments
 (0)