Skip to content

Commit 2f32fec

Browse files
committed
initial update to test that the _attrs update is working
1 parent f428294 commit 2f32fec

File tree

3 files changed

+33
-19
lines changed

3 files changed

+33
-19
lines changed

templates/_macros/vf_tiered-list.jinja

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@
55
# own row on tablet vs. 50/50 split between title/description
66
# is_media_full_width: whether the media is full width
77
# media_placement: where the image is placed relative to the description. Options are "after_description" or "before_description".
8+
# img_attrs: attributes for the image element, e.g. src, alt, class
9+
# video_attrs: attributes for the video element, e.g. src, class
810
# Slots
911
# title: top-level title element
1012
# description: top-level description element
11-
# video: top-level video element. Mutually exclusive with image, and takes priority over the image.
12-
# image: top-level image element. Mutually exclusive with video. Is not rendered if the video is provided.
1313
# list_item_title_[1-25]: title element of each child list item
1414
# list_item_description_[1-25]: description element of each child list item
1515
# cta: CTA block element
1616
{% macro vf_tiered_list(
1717
is_description_full_width_on_desktop=true,
1818
is_list_full_width_on_tablet=true,
1919
is_media_full_width=false,
20-
media_placement="after_description"
20+
media_placement="after_description",
21+
img_attrs={},
22+
video_attrs={}
2123
) -%}
2224
{%- set title_content = caller('title') -%}
2325
{%- set description_content = caller('description') -%}
2426
{%- set has_description = description_content|trim|length > 0 -%}
25-
{%- set image_content = caller('image') -%}
26-
{%- set has_image = image_content|trim|length > 0 -%}
2727
{%- set cta_content = caller('cta') -%}
2828
{%- set has_cta = cta_content|trim|length > 0 -%}
29-
{%- set video_content = caller('video') -%}
30-
{%- set has_video = video_content|trim|length > 0 -%}
29+
{%- set has_image = img_attrs['src']|trim|length > 0 -%}
30+
{%- set has_video = video_attrs['src']|trim|length > 0 -%}
3131
{%- set has_media = has_image or has_video -%}
3232

3333
{% if media_placement not in ["before_description", "after_description"] %}
@@ -45,15 +45,27 @@
4545
<div class="p-section--shallow">
4646
{#- u-embedded-media applies 16:9 aspect ratio via padding. -#}
4747
<div class="u-embedded-media">
48-
{#- Assume u-embedded-media__element on the content -#}
49-
{{- video_content -}}
48+
<iframe class="u-embedded-media__element {{ video_attrs['class'] }}"
49+
{% for attr, value in video_attrs.items() %}
50+
{% if attr != "class" %}
51+
{{- attr }}="{{ value }}"
52+
{% endif %}
53+
{% endfor %}
54+
></iframe>
5055
</div>
5156
</div>
5257
{%- elif has_image -%}
5358
<div class="p-section--shallow">
5459
<div class="p-image-container--{{ image_aspect_ratio }} is-cover">
55-
{#- Assume p-image-container__image on the content -#}
56-
{{- image_content -}}
60+
<img
61+
{#- Forward classes from the img_attrs. This is optional, on a per-pattern basis. #}
62+
class="p-image-container__image {{ img_attrs['class'] }}"
63+
{% for attr, value in img_attrs.items() %}
64+
{% if attr != "class" %}
65+
{{- attr }}="{{ value }}"
66+
{% endif %}
67+
{% endfor %}
68+
>
5769
</div>
5870
</div>
5971
{%- endif -%}

templates/docs/examples/patterns/tiered-list/50-50-desktop-with-description-with-full-width-image.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@
66
{% block standalone_css %}patterns_all{% endblock %}
77

88
{% block content %}
9-
{%- call(slot) vf_tiered_list(is_description_full_width_on_desktop=false, is_list_full_width_on_tablet=true, is_media_full_width=true) -%}
9+
{%- call(slot) vf_tiered_list(is_description_full_width_on_desktop=false, is_list_full_width_on_tablet=true, is_media_full_width=true, img_attrs=image(
10+
url="https://assets.ubuntu.com/v1/3f63a18c-data-center.png",
11+
alt="",
12+
width="2464",
13+
height="1028",
14+
hi_def=True,
15+
loading="auto|lazy",
16+
output_mode="attrs"
17+
)) -%}
1018
{%- if slot == 'title' -%}
1119
<h2>H2 - up to two lines; ideally one.</h2>
1220
{%- endif -%}
1321

14-
{%- if slot == "image" -%}
15-
<img class="p-image-container__image"
16-
src="https://assets.ubuntu.com/v1/3f63a18c-data-center.png"
17-
width="2464" height="1028" alt="">
18-
{%- endif -%}
19-
2022
{%- if slot == 'description' -%}
2123
<p>A <a href="#">private cloud</a> provides organisations with on-demand
2224
compute, storage and other resources that can be accessed over the network

templates/docs/examples/patterns/tiered-list/video.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{% block standalone_css %}patterns_all{% endblock %}
77

88
{% block content %}
9-
{%- call(slot) vf_tiered_list(is_description_full_width_on_desktop=true, is_list_full_width_on_tablet=true) -%}
9+
{%- call(slot) vf_tiered_list(is_description_full_width_on_desktop=true, is_list_full_width_on_tablet=true, video_attrs={"src": "https://www.youtube.com/embed/TShKZLeZzWE", "allowfullscreen": ""}) -%}
1010
{%- if slot == 'title' -%}
1111
<h2>H2 - up to two lines; ideally one.</h2>
1212
{%- endif -%}

0 commit comments

Comments
 (0)