Skip to content

Commit 7840dce

Browse files
authored
Add text-wrap to typographic elements (#2225)
* Add `text-wrap` to typographic elements * Reduce scope of change to headings * Remove `u-rescue-orphan` utility.
1 parent e62228d commit 7840dce

File tree

6 files changed

+7
-20
lines changed

6 files changed

+7
-20
lines changed

.changeset/loud-paws-tease.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudfour/patterns': major
3+
---
4+
5+
Improved text wrapping for headings and subheadings with `text-wrap`. Removes the `u-rescue-orphan` utility, which is now redundant.

src/base/_typography.scss

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ body {
5959
h#{$i} {
6060
@include headings.level($i);
6161
color: var(--theme-color-text-emphasis);
62+
text-wrap: balance;
6263
}
6364
}
6465

src/components/heading/heading.scss

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ $max-width-permalink-shift: math.div($min-width-permalink-shift * 16 - 1, 16);
140140
font-weight: font-weight.$medium;
141141
line-height: line-height.$tight;
142142
max-inline-size: 100%;
143+
text-wrap: balance;
143144

144145
.c-heading--light & {
145146
font-weight: font-weight.$normal;

src/utilities/display/demo/rescue-orphan.twig

-5
This file was deleted.

src/utilities/display/display.scss

-6
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,3 @@
1212
content: '';
1313
display: block;
1414
}
15-
16-
/// Attempt to keep chunks of text together as space allows
17-
.u-rescue-orphan {
18-
display: inline-block;
19-
text-decoration: inherit;
20-
}

src/utilities/display/display.stories.mdx

-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Canvas, Meta, Story } from '@storybook/addon-docs';
22
import hiddenVisuallyDemo from './demo/hidden-visually.twig';
33
import clearfixDemo from './demo/clearfix.twig';
4-
import rescueOrphanDemo from './demo/rescue-orphan.twig';
54

65
<Meta title="Utilities/Display" />
76

@@ -31,11 +30,3 @@ The `u-clearfix` class forces a container to expand to fit floated children.
3130
<Canvas>
3231
<Story name="Clearfix">{clearfixDemo}</Story>
3332
</Canvas>
34-
35-
## Rescue Orphan
36-
37-
The `u-rescue-orphan` class can wrap the last few words of a chunk of text, attempting to keep them together unless space limitations force a break. This can help reduce the chance of [a typographic orphan](https://en.wikipedia.org/wiki/Widows_and_orphans) in some situations.
38-
39-
<Canvas>
40-
<Story name="Rescue Orphan">{rescueOrphanDemo}</Story>
41-
</Canvas>

0 commit comments

Comments
 (0)