localgov_alert_banner-1.8.5/templates/localgov-alert-banner.html.twig
templates/localgov-alert-banner.html.twig
{#
/**
* @file localgov_alert_banner.html.twig
* Default theme implementation to present Alert banner data.
*
* This template is used when viewing Alert banner pages.
*
*
* Available variables:
* - content: A list of content items. Use 'content' to print all content, or
* - attributes: HTML attributes for the container element.
* - display_title: Boolean indicating if alert banner title should be displayed
* - remove_hide_link: Boolean indicating if the link to close the banner should be hidden
* - type_of_alert: Type of alert banner
*
* @see template_preprocess_localgov_alert_banner()
*
* @ingroup themeable
*/
#}
{{ attach_library('localgov_alert_banner/alert_banner') }}
{% set has_link = content.link|render is not empty %}
{% set type_of_alert = type_of_alert|split('--')[1]|clean_class %}
{% set classes = [
'js-localgov-alert-banner',
'localgov-alert-banner',
type_of_alert ? 'localgov-alert-banner--' ~ type_of_alert,
is_front ? 'localgov-alert-banner--homepage',
has_link ? 'localgov-alert-banner--has-link' : 'localgov-alert-banner--no-link'
]
%}
<article {{ attributes.addClass(classes) }}>
{# Begin Wrapper #}
<div class="localgov-alert-banner__wrapper">
{# Begin Inner #}
<div class="localgov-alert-banner__inner">
{# Begin Content #}
<div class="localgov-alert-banner__content">
{% if display_title %}
<h2 class="localgov-alert-banner__title">
{{ content.title }}
</h2>
{% endif %}
<div class="localgov-alert-banner__body">
{{ content|without('title', 'link') }}
</div>
{% if has_link %}
<div class="localgov-alert-banner__content-link">{{ content.link }}</div>
{% endif %}
</div> {# End Content #}
{% if not remove_hide_link %}
<div class="localgov-alert-banner__actions">
<div class="localgov-alert-banner__dismiss">
<button class="localgov-alert-banner__close js-localgov-alert-banner__close" aria-label="{{ 'Hide alert'|t ~ ': ' ~ content.title|render|striptags|trim }}">{{ 'Hide'|t }}</button>
</div>
</div>
{% endif %}
</div> {# End Inner #}
</div> {# End Wrapper #}
</article>
