-
Notifications
You must be signed in to change notification settings - Fork 0
/
two-column-paragraph.twig
93 lines (87 loc) · 3.25 KB
/
two-column-paragraph.twig
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
{#
/**
* @file
* Default theme implementation to display a paragraph.
*
* Available variables:
* - paragraph: Full paragraph entity.
* Only method names starting with "get", "has", or "is" and a few common
* methods such as "id", "label", and "bundle" are available. For example:
* - paragraph.getCreatedTime() will return the paragraph creation timestamp.
* - paragraph.id(): The paragraph ID.
* - paragraph.bundle(): The type of the paragraph, for example, "image" or "text".
* - paragraph.getOwnerId(): The user ID of the paragraph author.
* See Drupal\paragraphs\Entity\Paragraph for a full list of public properties
* and methods for the paragraph object.
* - content: All paragraph items. Use {{ content }} to print them all,
* or print a subset such as {{ content.field_example }}. Use
* {{ content|without('field_example') }} to temporarily suppress the printing
* of a given child element.
* - attributes: HTML attributes for the containing element.
* The attributes.class element may contain one or more of the following
* classes:
* - paragraphs: The current template type (also known as a "theming hook").
* - paragraphs--type-[type]: The current paragraphs type. For example, if the paragraph is an
* "Image" it would result in "paragraphs--type--image". Note that the machine
* name will often be in a short form of the human readable label.
* - paragraphs--view-mode--[view_mode]: The View Mode of the paragraph; for example, a
* preview would result in: "paragraphs--view-mode--preview", and
* default: "paragraphs--view-mode--default".
* - view_mode: View mode; for example, "preview" or "full".
* - logged_in: Flag for authenticated user status. Will be true when the
* current user is a logged-in member.
* - is_admin: Flag for admin user status. Will be true when the current user
* is an administrator.
*
* @see template_preprocess_paragraph()
*
* @ingroup themeable
*/
#}
{%
set classes = [
'paragraph',
'paragraph--type--' ~ paragraph.bundle|clean_class,
view_mode ? 'paragraph--view-mode--' ~ view_mode|clean_class,
not paragraph.isPublished() ? 'paragraph--unpublished',
'l-section',
'l-section--border',
'l-inner'
]
%}
{% set layout = paragraph.field_column_layout.value %}
{% block paragraph %}
<div{{ attributes.addClass(classes) }}>
{# For equal column layout. #}
{% if layout == 'equal' %}
<div class="row grid-2-up">
<div class="grid-item">
{{ content.field_column_one }}
</div>
<div class="grid-item">
{{ content.field_column_two }}
</div>
</div>
{# For left dominant layout. #}
{% elseif layout == 'left' %}
<div class="row desktop-row flex-start">
<div class="col-desktop-8 col-12">
{{ content.field_column_one }}
</div>
<div class="col-desktop-4 col-12">
{{ content.field_column_two }}
</div>
</div>
{# For right dominant layout. #}
{% else %}
<div class="row desktop-row flex-start">
<div class="col-desktop-4 col-12">
{{ content.field_column_one }}
</div>
<div class="col-desktop-8 col-12">
{{ content.field_column_two }}
</div>
</div>
{% endif %}
</div>
{% endblock paragraph %}