Skip to content

Commit 9c55401

Browse files
Split can now be nested with class
1 parent fcf9016 commit 9c55401

File tree

5 files changed

+65
-7
lines changed

5 files changed

+65
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Introducing theme variables! CSS variables beginning with `--theme-` will adjust
1616

1717
## Split Component
1818

19+
* **component:** Split can now be nested inside content containers with the `mzp-l-split-nested` class
1920
* **component:** (breaking) Removed `mzp-l-split-pop-top`, `mzp-l-split-pop-bottom`, and `mzp-l-split-pop` layout classes from Split component
2021
* **component:** (breaking) Removed `mzp-l-split-media-overflow` and `mzp-l-split-media-constrain-height` layout classes from Split component
2122

assets/sass/protocol/components/_split.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@
3737
.mzp-t-content-xl & {
3838
max-width: $content-xl;
3939
}
40+
41+
// Allow split to be nested inside another container (e.g. mzp-l-content)
42+
.mzp-l-split-nested & {
43+
max-width: none;
44+
padding-left: 0;
45+
padding-right: 0;
46+
}
4047
}
4148

4249
.mzp-c-split-body {

components/split/readme.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@ variations.
4949
- `mzp-l-split-center-on-sm-md` - content is centered on small to medium screens.
5050
- `mzp-l-split-hide-media-on-sm-md` - media is hidden on small to medium screens.
5151

52-
### No-nos:
52+
### Nesting inside a container
5353

54-
**Note:** This component is intended to be a full-width section of a page, with
55-
an outer container that spans the width of the viewport and generous spacing
56-
above and below. Split has an inner container to define its content width, so
57-
don't place Split inside another `mzp-l-content` [container](content-container).
58-
The nested spacing will get weird.
54+
By default, Split is intended to be a full-width section of a page, with an
55+
outer container that spans the width of the viewport. Split has its own inner
56+
container to define its content width.
57+
58+
If you need to nest Split inside another container (e.g. `mzp-l-content`), add
59+
the `mzp-l-split-nested` class to the outermost element (`mzp-c-split`). This
60+
removes the inner container's max-width and padding so it fills the parent
61+
container without doubling up on spacing.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{# @split--nested
2+
#
3+
# parameters:
4+
# block_class - string
5+
# background_class - string
6+
# body_class - string
7+
# content - string, markup
8+
# image - path
9+
#}
10+
<div class="mzp-l-content">
11+
<section class="mzp-c-split mzp-l-split-nested {{ block_class }}">
12+
{%- if background_class -%}<div class="mzp-c-split-bg {{ background_class }}">{%- endif -%}
13+
<div class="mzp-c-split-container">
14+
<div class="mzp-c-split-body {{ body_class }}">
15+
{% if content %}
16+
{{ content | safe }}
17+
{% else %}
18+
<h1 class="mzp-u-heading-md">Lorem ipsum dolor sit amet</h1>
19+
<p>Lorem ipsum dolor sit amet, amet dolores tincidunt te sea. His aliquid epicuri detraxit in, cum tantas populo periculis te. Ei vix idque noster.</p>
20+
<p>{% render '@button', { link: '#', label: 'Call to action' } %}</p>
21+
{% endif %}
22+
</div>
23+
<div class="mzp-c-split-media {{ media_class }}">
24+
{% if image -%}
25+
<img class="mzp-c-split-media-asset" src="{{ image | path }}" alt="">
26+
{% else -%}
27+
<img class="mzp-c-split-media-asset" src="{{ '/img/image-16-9.jpg' | path }}" alt="" srcset="{{ '/img/image-16-9-high-res.jpg' | path }} 2x">
28+
{%- endif -%}
29+
</div>
30+
</div>
31+
{%- if background_class -%}</div>{%- endif -%}
32+
</section>
33+
</div>

components/split/split.config.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ variants:
7373
image: '/img/image-portrait.jpg'
7474
- name: Media Alignment
7575
notes: |
76-
Align the media in different positions, horizontally and vertically (its
76+
Align the media in different positions, horizontally and vertically (it's
7777
aligned left by default in LTR languages, and vertically centered).
7878
7979
Apply these classes to the media container (`mzp-c-split-media`):
@@ -89,3 +89,17 @@ variants:
8989
context:
9090
media_class: mzp-l-split-h-end mzp-l-split-v-end
9191
image: '/img/image-1-1-sm.jpg'
92+
- name: Nested
93+
notes: |
94+
If you need to nest Split inside another container (e.g. `mzp-l-content`),
95+
add the `mzp-l-split-nested` class to the outermost element (`mzp-c-split`).
96+
This removes the inner container's max-width and horizontal padding so it
97+
fills the parent container without doubling up on spacing.
98+
- name: No Space
99+
notes: |
100+
Add the class `mzp-t-split-nospace` to the outer container (`mzp-c-split`)
101+
to remove the vertical spacing above and below. This is useful when stacking
102+
multiple Splits together or when placing a Split at the very top of a page
103+
as a hero section.
104+
context:
105+
block_class: mzp-t-split-nospace

0 commit comments

Comments
 (0)