|
5 | 5 | # own row on tablet vs. 50/50 split between title/description |
6 | 6 | # is_media_full_width: whether the media is full width |
7 | 7 | # 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 |
8 | 10 | # Slots |
9 | 11 | # title: top-level title element |
10 | 12 | # 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. |
13 | 13 | # list_item_title_[1-25]: title element of each child list item |
14 | 14 | # list_item_description_[1-25]: description element of each child list item |
15 | 15 | # cta: CTA block element |
16 | 16 | {% macro vf_tiered_list( |
17 | 17 | is_description_full_width_on_desktop=true, |
18 | 18 | is_list_full_width_on_tablet=true, |
19 | 19 | is_media_full_width=false, |
20 | | - media_placement="after_description" |
| 20 | + media_placement="after_description", |
| 21 | + img_attrs={}, |
| 22 | + video_attrs={} |
21 | 23 | ) -%} |
22 | 24 | {%- set title_content = caller('title') -%} |
23 | 25 | {%- set description_content = caller('description') -%} |
24 | 26 | {%- set has_description = description_content|trim|length > 0 -%} |
25 | | - {%- set image_content = caller('image') -%} |
26 | | - {%- set has_image = image_content|trim|length > 0 -%} |
27 | 27 | {%- set cta_content = caller('cta') -%} |
28 | 28 | {%- 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 -%} |
31 | 31 | {%- set has_media = has_image or has_video -%} |
32 | 32 |
|
33 | 33 | {% if media_placement not in ["before_description", "after_description"] %} |
|
45 | 45 | <div class="p-section--shallow"> |
46 | 46 | {#- u-embedded-media applies 16:9 aspect ratio via padding. -#} |
47 | 47 | <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> |
50 | 55 | </div> |
51 | 56 | </div> |
52 | 57 | {%- elif has_image -%} |
53 | 58 | <div class="p-section--shallow"> |
54 | 59 | <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 | + > |
57 | 69 | </div> |
58 | 70 | </div> |
59 | 71 | {%- endif -%} |
|
0 commit comments