@openeuropa/bcl-listing 0.1.202408021145

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020-2021 Mark Otto
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,199 @@
1
+ {% apply spaceless %}
2
+
3
+ {# Parameters:
4
+ - title: (string) (default: '')
5
+ - title_tag: (string) (default: 'h2')
6
+ - title_link: (link object) (default: {})
7
+ - title_attributes (drupal attrs)
8
+ - items: (card[])
9
+ - variant: (string) (default: 'default-1-col')
10
+ options [ default-1-col, highlight-1-col, default-2-col, default-3-col, highlight-2-col, highlight-3-col ]
11
+ - link: (object of type link)
12
+ - alignment: (string) (default: '')
13
+ options ['start', 'end', 'center', 'baseline', 'stretch']
14
+ - image_size: (string) (default: '')
15
+ options ['small', 'large', 'extra-large']
16
+ - attributes (drupal attrs)
17
+ #}
18
+
19
+ {% set _title = title|default('') %}
20
+ {% set _title_tag = title_tag|default('h2') %}
21
+ {% set _title_link = title_link|default({}) %}
22
+ {% set _title_attributes = title_attributes ?: create_attribute() %}
23
+ {% set _items = items|default([]) %}
24
+ {% set _variant = variant|default('default-1-col') %}
25
+ {% set _link = link|default({}) %}
26
+ {% set _alignment = alignment|default('') %}
27
+ {% set _image_size = image_size|default('') %}
28
+
29
+ {% set _classes = ['bcl-listing', 'bcl-listing--' ~ _variant] %}
30
+ {% set _cards = [] %}
31
+ {% set _card_layout = {
32
+ type: 'grid',
33
+ responsiveness: 'md',
34
+ gutter: '4',
35
+ attributes: create_attribute(),
36
+ } %}
37
+
38
+ {% if attributes is empty %}
39
+ {% set attributes = create_attribute() %}
40
+ {% endif %}
41
+
42
+ {% set attributes = attributes.addClass(_classes) %}
43
+
44
+ <div {{ attributes }}>
45
+
46
+ {% if _title is not empty %}
47
+ {% include '@oe-bcl/bcl-heading/heading.html.twig' with {
48
+ title: _title,
49
+ title_tag: _title_tag,
50
+ title_link: _title_link,
51
+ title_attributes: _title_attributes,
52
+ } only %}
53
+ {% endif %}
54
+
55
+ {% if _items is not empty %}
56
+ {% for _card in _items %}
57
+ {% set _alignment_class = '' %}
58
+ {% set _image_classes = _card.image.classes ?: '' %}
59
+ {% set _start_col_classes = 'bcl-card-start-col mb-3 mb-lg-0' %}
60
+ {% set _end_col_classes = 'col-12 col-md' %}
61
+ {% if _image_size is not empty %}
62
+ {% set _start_col_classes = _start_col_classes ~ ' bcl-size-' ~ _image_size %}
63
+ {% endif %}
64
+ {% if 'd-none' in _image_classes %}
65
+ {% set _start_col_classes = _start_col_classes ~ ' d-none d-md-block' %}
66
+ {% endif %}
67
+ {% if _alignment is not empty %}
68
+ {% set _alignment_class = ' align-self-' ~ _alignment %}
69
+ {% endif %}
70
+ {% set _card_classes = [] %}
71
+ {% set _card_attributes = card.attributes ? card.attributes : create_attribute() %}
72
+ {% set _card_title_attributes = card.title_attributes ? card.title_attributes : create_attribute() %}
73
+ {% set _card = _card|merge({
74
+ title_attributes: _card_title_attributes.addClass(['fs-5'])
75
+ }) %}
76
+
77
+ {% if _variant == 'default-1-col' or _variant == 'default-2-col' or _variant == 'default-3-col' %}
78
+ {% set _card_classes = [
79
+ 'listing-item',
80
+ 'border-bottom',
81
+ 'border-md-0',
82
+ 'border-0',
83
+ ] %}
84
+ {% set _card_attributes = _card_attributes.addClass(_card_classes) %}
85
+ {% set _card = _card|merge({
86
+ horizontal: true,
87
+ extra_classes_body: 'p-0 pb-md-0 pb-3',
88
+ attributes: _card_attributes,
89
+ horizontal_grid: {
90
+ left_col_classes: _start_col_classes ~ _alignment_class,
91
+ right_col_classes: _end_col_classes ~ _alignment_class,
92
+ }
93
+ }) %}
94
+
95
+ {% if _variant == 'default-2-col' %}
96
+ {% set _card_layout = _card_layout|merge({
97
+ responsive_columns: 2,
98
+ }) %}
99
+ {% elseif _variant == 'default-3-col' %}
100
+ {% set _card_layout = _card_layout|merge({
101
+ attributes: _card_layout.attributes.addClass(['row-cols-md-2']),
102
+ responsive_columns: 3,
103
+ responsiveness: 'xl',
104
+ }) %}
105
+ {% endif %}
106
+ {% endif %}
107
+
108
+ {% if _variant == 'highlight-1-col' %}
109
+ {% set _card_classes = [
110
+ 'listing-item--highlight',
111
+ 'border-0',
112
+ 'bg-lighter'
113
+ ] %}
114
+ {% set _card_attributes = _card_attributes.addClass(_card_classes) %}
115
+ {% set _card = _card|merge({
116
+ wrapper_class: 'col',
117
+ attributes: _card_attributes,
118
+ }) %}
119
+ {% if _card.image is defined and _card.image is not empty %}
120
+ {% set _card = _card|merge({
121
+ extra_classes_body: "pt-0",
122
+ }) %}
123
+ {% endif %}
124
+ {% set _card_layout = _card_layout|merge({
125
+ cols_extra_classes: 'mt-4-5',
126
+ }) %}
127
+ {% if _card.image is not empty %}
128
+ {% set _image_classes = _card.image.classes ?: '' %}
129
+ {% if not _alignment == 'center' %}
130
+ {% set _image_classes = _image_classes ? _image_classes ~ ' mb-3' : 'mb-3' %}
131
+ {% endif %}
132
+ {% set _card = _card|merge({image: _card.image|merge({
133
+ classes: _image_classes,
134
+ })}) %}
135
+ {% endif %}
136
+
137
+ {% endif %}
138
+
139
+ {% if _variant == 'highlight-2-col' or variant == 'highlight-3-col' %}
140
+ {% set _card_classes = [
141
+ 'listing-item--highlight',
142
+ 'border-0',
143
+ 'bg-lighter',
144
+ 'h-100',
145
+ 'rounded-2'
146
+ ] %}
147
+ {% set _card_attributes = _card_attributes.addClass(_card_classes) %}
148
+ {% set _card = _card|merge({
149
+ wrapper_class: 'col',
150
+ attributes: _card_attributes,
151
+ }) %}
152
+ {% if _card.image is defined and _card.image is not empty %}
153
+ {% set _card = _card|merge({
154
+ extra_classes_body: 'pt-0',
155
+ }) %}
156
+ {% endif %}
157
+ {% if _card.image is not empty %}
158
+ {% set _image_classes = _card.image.classes ?: '' %}
159
+ {% if not _alignment == 'center' %}
160
+ {% set _image_classes = _image_classes ? _image_classes ~ ' mb-3' : 'mb-3' %}
161
+ {% endif %}
162
+ {% set _card = _card|merge({image: _card.image|merge({
163
+ classes: _image_classes,
164
+ })}) %}
165
+ {% endif %}
166
+ {% set _card_layout = _card_layout|merge({ gutter: '4' }) %}
167
+ {% if variant == 'highlight-2-col' %}
168
+ {% set _card_layout = _card_layout|merge({ responsive_columns: 2 }) %}
169
+ {% else %}
170
+ {% set _card_layout = _card_layout|merge({ responsive_columns: 3 }) %}
171
+ {% endif %}
172
+ {% endif %}
173
+
174
+ {% if _card.image is empty and _card.date is empty %}
175
+ {% set _card = _card|merge({
176
+ horizontal: false,
177
+ }) %}
178
+ {% endif %}
179
+
180
+ {% set _cards = _cards|merge([_card]) %}
181
+ {% endfor %}
182
+ {% endif %}
183
+
184
+ {% include "@oe-bcl/bcl-card-layout/card-layout.html.twig" with _card_layout|merge({ items: _cards }) only %}
185
+
186
+ {% if _link is not empty %}
187
+ {% set _link_attributes = _link.attributes ? _link.attributes : create_attribute() %}
188
+ {% set _link_attributes = _link_attributes.addClass(['mt-3-5', 'd-inline-block']) %}
189
+ {% include '@oe-bcl/bcl-link/link.html.twig' with _link|merge({
190
+ attributes: _link_attributes,
191
+ icon: _link.icon|merge({
192
+ name: 'chevron-right',
193
+ size: 'xs',
194
+ }),
195
+ }) only %}
196
+ {% endif %}
197
+ </div>
198
+
199
+ {% endapply %}
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@openeuropa/bcl-listing",
3
+ "author": "European Commission",
4
+ "license": "EUPL-1.2",
5
+ "version": "0.1.202408021145",
6
+ "description": "OE - BCL Listing",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "dependencies": {
11
+ "@openeuropa/bcl-card-layout": "^0.1.202408021145",
12
+ "@openeuropa/bcl-heading": "^0.1.202408021145",
13
+ "@openeuropa/bcl-link": "^0.1.202408021145"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/openeuropa/bootstrap-component-library.git"
18
+ },
19
+ "bugs": {
20
+ "url": "https://github.com/openeuropa/bootstrap-component-library.git/issues"
21
+ },
22
+ "homepage": "https://github.com/openeuropa/bootstrap-component-library",
23
+ "keywords": [
24
+ "openeuropa",
25
+ "bootstrap-component-library",
26
+ "design-system",
27
+ "twig"
28
+ ],
29
+ "gitHead": "7ee2013f7f64a70ddfa35228a9a65967dd71eec3"
30
+ }