Skip to content

Commit 20b8308

Browse files
authored
fix(hero): 50/50 with no image is laid out in split columns (#5450)
* fix(hero): 50/50 with no image is laid out in split columns * drive-by: remove old change status labels
1 parent 8cba2e8 commit 20b8308

File tree

8 files changed

+54
-9
lines changed

8 files changed

+54
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vanilla-framework",
3-
"version": "4.20.0",
3+
"version": "4.20.1",
44
"author": {
55
"email": "webteam@canonical.com",
66
"name": "Canonical Webteam"

releases.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
- version: 4.20.1
2+
features:
3+
- component: Hero
4+
url: /docs/patterns/hero#5050-with-no-image-new
5+
status: Updated
6+
notes: We've added support for 50/50 hero sections with no image.
17
- version: 4.20.0
28
features:
39
- component: List

templates/_macros/vf_hero.jinja

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
{% set layout = 'fallback' %}
3333
{% endif %}
3434

35+
{% set is_50_50_no_image = (layout == "50-50" and not has_image) %}
36+
3537
{% if layout == '50-50-full-width-image' and has_image %}
3638
{% set layout = '50-50' %}
3739
{% set has_full_width_image = true %}
@@ -72,9 +74,9 @@
7274
{% endif %}
7375

7476
{%- macro _hero_title_block() -%}
75-
{%- if has_full_width_image -%}
77+
{%- if has_full_width_image or is_50_50_no_image -%}
7678
{%- if has_subtitle -%}
77-
{#- On full-width-image, the h1 and h2 are in separate columns, so there must be no margin-bottom to keep h1 close to h2 on smaller screens -#}
79+
{#- On full-width-image and 50/50 with no image, the h1 and h2 are in separate columns, so there must be no margin-bottom to keep h1 close to h2 on smaller screens -#}
7880
{% set title_class = "u-no-margin--bottom" %}
7981
{%- endif -%}
8082
{%- endif -%}
@@ -139,7 +141,7 @@
139141
{{ image_content }}
140142
</div>
141143
{% endif -%}
142-
{% elif has_full_width_image and not has_signpost_image %}
144+
{% elif (has_full_width_image and not has_signpost_image) or is_50_50_no_image %}
143145
<div class="{{ col_classes[0] }}">
144146
{{ _hero_title_block() }}
145147
</div>

templates/docs/examples/patterns/hero/combined.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
<section>{% include 'docs/examples/patterns/hero/hero-50-50-split-on-medium.html' %}</section>
2424
<section>{% include 'docs/examples/patterns/hero/hero-75-25.html' %}</section>
2525
<section>{% include 'docs/examples/patterns/hero/hero-fallback.html' %}</section>
26+
<section>{% include 'docs/examples/patterns/hero/hero-50-50-no-image.html' %}</section>
2627
{% endwith %}
2728
{% endblock %}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{% extends "_layouts/examples.html" %}
2+
{% from "_macros/vf_hero.jinja" import vf_hero %}
3+
4+
{% block title %}Hero / 50/50 / Without image{% endblock %}
5+
{% block standalone_css %}patterns_all{% endblock %}
6+
7+
{% set is_paper = true %}
8+
{% block content %}
9+
10+
{% call(slot) vf_hero(
11+
title_text='H1 - ideally one line, up to two',
12+
subtitle_text='H2 placeholder - aim for one line, 2 is acceptable, more - use a paragraph',
13+
layout='50/50'
14+
) -%}
15+
{%- if slot == 'description' -%}
16+
<p>
17+
Generally, the height of the right hand side of a 50/50 split should contain more content than the left
18+
hand side.
19+
</p>
20+
{%- endif -%}
21+
{%- if slot == 'cta' -%}
22+
<a href="#" class="p-button--positive">Learn more</a>
23+
<a href="#">Contact us ›</a>
24+
{%- endif -%}
25+
{% endcall -%}
26+
27+
{% endblock %}

templates/docs/patterns/hero/index.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Depending on the size and composition of your content, you can choose from a var
1313

1414
- [50/50](#5050)
1515
- [50/50 with full-width image](#5050-with-full-width-image)
16+
- [50/50 with no image](#5050-with-no-image-new)
1617
- [25/75 Signpost](#2575-signpost)
1718
- [75/25](#7525)
1819
- [Fallback](#fallback)
@@ -64,6 +65,14 @@ This will make the image take up the full width of the hero.
6465
View example of the hero pattern in 50/50 split with a full-width image
6566
</a></div>
6667

68+
### 50/50 with no image {{ status("new") }}
69+
70+
This layout positions the title in the left half of the hero, and the rest of the text content in the right half.
71+
72+
<div class="embedded-example"><a href="/docs/examples/patterns/hero/hero-50-50-no-image" class="js-example" data-lang="jinja">
73+
View example of the hero pattern in 50/50 split with no image
74+
</a></div>
75+
6776
## 25/75 "signpost"
6877

6978
If you have a small image that you want to associate with the hero title, you can use the "signpost" layout.
@@ -104,7 +113,7 @@ This places the title and subtitle in their own row above the rest of the hero c
104113
View example of the hero pattern in fallback configuration
105114
</a></div>
106115

107-
## Jinja Macro {{ status("new") }}
116+
## Jinja Macro
108117

109118
The `vf_hero` Jinja macro can be used to generate a hero pattern. The API for the macro is shown below.
110119

@@ -261,7 +270,7 @@ The `vf_hero` Jinja macro can be used to generate a hero pattern. The API for th
261270
</table>
262271
</div>
263272

264-
## Import {{ status("updated") }}
273+
## Import
265274

266275
### Jinja Macro
267276

templates/docs/patterns/tiered-list/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ View example of the tiered list pattern
103103
View example of the tiered list pattern
104104
</a></div>
105105

106-
## Jinja Macro {{ status("new") }}
106+
## Jinja Macro
107107

108108
The `vf_tiered_list` Jinja macro can be used to generate a tiered list pattern. The API for the macro is shown below.
109109

@@ -231,7 +231,7 @@ The `vf_tiered_list` Jinja macro can be used to generate a tiered list pattern.
231231
</table>
232232
</div>
233233

234-
## Import {{ status("updated") }}
234+
## Import
235235

236236
### Jinja Macro
237237

templates/docs/utilities/align.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ If you only need text to be aligned, you can use the `u-align-text` utilities.
2222
View example of the text align utility
2323
</a></div>
2424

25-
## Vertical alignment {{ status("new") }}
25+
## Vertical alignment
2626

2727
If you need to vertically align inline elements to the middle of their
2828
container, you can use the `u-vertical-align--middle` utility.

0 commit comments

Comments
 (0)