-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhero.twig
More file actions
132 lines (119 loc) · 5.03 KB
/
hero.twig
File metadata and controls
132 lines (119 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
{#
{% embed '@hdbt/component/hero.twig' with {
design: content.field_hero_design[0]['#markup'],
title: content.field_hero_title,
description: content.field_hero_desc,
image: content.field_hero_image,
} %}
{% endembed %}
#}
{% if design == "background-image" %}
{% set design_class = "hero--with-image-bottom" %}
{% elseif design == "diagonal" %}
{% set design_class = "hero--diagonal" %}
{% elseif design == "with-image-bottom" %}
{% set design_class = "hero--with-image-bottom" %}
{% elseif design == "with-image-left" %}
{% set design_class = "hero--with-image-left" %}
{% elseif design == "with-image-right" %}
{% set design_class = "hero--with-image-right" %}
{% elseif design == "without-image-center" %}
{% set design_class = "hero--without-image-left" %}
{% elseif design == "without-image-left" %}
{% set design_class = "hero--without-image-left" %}
{% elseif design == "with-search" %}
{% set design_class = "hero--with-search" %}
{% elseif design == "with-helsinki-near-you" %}
{% set design_class = "hero--with-helsinki-near-you" %}
{% elseif design == "with-search-form" %}
{% set design_class = "hero--with-search-form" %}
{% endif %}
{% set hero_wrapper_attributes = {
'class': [
'hero',
design_class ? design_class,
]
} %}
{% set updated_string = ', ' ~ 'updated'|t({}, {'context': 'The helper text before the news article changed timestamp'}) %}
{# Open figure if image_author is set #}
{% if image_author %}
<figure>
{% endif %}
<div{{ create_attribute(hero_wrapper_attributes) }}>
{% embed "@hdbt/misc/container.twig" with {container_element: 'hero'} %}
{% block container_content %}
<div class="hero__text-content" {{ is_search ? 'role="search"' }}>
{# Hyphenate the visible title, but share to screen readers unhyphenated version as for example NVDA reads hyphenated text poorly #}
<h1 class="hero__title hyphenate" aria-labelledby="page_title">{{ title }}</h1>
<span class="is-hidden" id="page_title">{{ title }}</span>
{% if design == "with-search" %}
{% include "@hdbt/component/helfi-search-form.twig" with {
label: 'What are you looking for?'|t({}, {'context': 'Header and hero search label'}),
search_id: 'hero',
} %}
{% endif %}
{% if description|render|striptags|trim is not empty %}
{% if
design == "without-image-left" or
design == "without-image-center" or
design == "with-image-right" or
design == "with-image-left" or
design == "with-image-bottom" or
design == "diagonal" or
design == "with-helsinki-near-you" or
design == "with-search-form"
%}
<div class="hero__description user-edited-content">
{{ description }}
</div>
{% endif %}
{% endif %}
{% if form %}
{{ form }}
{% endif %}
{% if published_time|render|striptags|trim is not empty and html_published_time|render|striptags|trim is not empty %}
<div class="hero__publish-information">
<span class="visually-hidden">{{ 'Published'|t({}, {'context': 'The helper text before the news article published timestamp'}) }}</span>
<time datetime="{{ html_published_time }}" class="hero__publish-information__datetime hero__publish-information__datetime--published">{{ published_time }}</time>
{%- if updated_time|render|striptags|trim is not empty and html_updated_time|render|striptags|trim is not empty and html_updated_time > html_published_time -%}
{{- updated_string }}
<time datetime="{{ html_updated_time }}" class="hero__publish-information__datetime hero__publish-information__datetime--updated">{{ updated_time }}</time>
{%- endif -%}
</div>
{% endif %}
</div>
<span class="hero__arrow" aria-hidden="true"></span>
{% endblock %}
{% endembed %}
{% if
design == "with-image-right" or
design == "with-image-left" or
design == "with-image-bottom" or
design == "diagonal" or
design == "with-search"
%}
{% if image|render %}
<div class="hero__image-container">
{% if design == "diagonal" or design == "with-search" %}
{% include '@hdbt/misc/koro.twig' with { flip: true, diagonal: true, koro_override: koro_override } %}
{% else %}
{% include '@hdbt/misc/koro.twig' with { flip: true, koro_override: koro_override } %}
{% endif %}
{{ image }}
</div>
{% endif %}
{% endif %}
{% include '@hdbt/misc/koro.twig' with { flip: true, koro_override: koro_override } %}
</div>
{# Add figcaption image_author is set #}
{% if image_author %}
{% embed "@hdbt/misc/container.twig" with {container_element: 'hero__image-author'} %}
{% block container_content %}
{% embed '@hdbt/misc/caption.twig' with {
caption_identifier_class: 'hero__image-author',
credit: image_author,
} %}
{% endembed %}
{% endblock %}
{% endembed %}
{% endif %}