Skip to content

Commit

Permalink
feat(utilities): add classes to limit the extent of line lengths (#883)
Browse files Browse the repository at this point in the history
  • Loading branch information
louismaximepiton authored Nov 22, 2021
1 parent 68ec471 commit 578d907
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .bundlewatch.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"files": [
{
"path": "./dist/css/boosted-grid.css",
"maxSize": "9.8 kB"
"maxSize": "9.9 kB"
},
{
"path": "./dist/css/boosted-grid.min.css",
Expand Down
8 changes: 8 additions & 0 deletions scss/_utilities.scss
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,14 @@ $utilities: map-merge(
lg: $line-height-lg,
)
),
"line-length": (
property: max-width,
class: ll,
values: (
sm: $line-length-sm,
md: $line-length-md,
)
),
"text-align": (
responsive: true,
property: text-align,
Expand Down
4 changes: 4 additions & 0 deletions scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,10 @@ $line-height-base: calc(18 / 16) !default;
$line-height-sm: calc(16 / 14) !default;
$line-height-lg: calc(30 / 16) !default;
// stylelint-enable function-disallowed-list

$line-length-sm: 40ch !default;
$line-length-md: 80ch !default;

$letter-spacing-base: $spacer * -.005 !default; // -0.1px

$h1-font-size: $font-size-base * 2.125 !default; // 34px
Expand Down
6 changes: 6 additions & 0 deletions site/content/docs/5.1/getting-started/accessibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ When using a fixed (or sticky) header, tabbing backward often hides focused elem
Boosted provides `target-size()` mixin to ensure a minimum target size, adding a centered pseudo-element with a minimum size —defaulting to `44px` to pass [WCAG 2.1 "Target Size" Success Criterion (2.5.5)](https://www.w3.org/WAI/WCAG21/Understanding/target-size.html)— alongside a few arguments to fit specific needs (eg. different width and height, using `::after` instead of `::before`, etc.).

{{< scss-docs name="target-size" file="scss/mixins/_target-size.scss" >}}

### Maximum line length

When writing a paragraph, it is commonly admitted that a line should have 80 characters as a maximum. This phenomenon is carefully explained in the [C20 website: Using relative measurements to set column widths](https://www.w3.org/TR/2016/NOTE-WCAG20-TECHS-20161007/C20).

For more information, please [read text utilities]({{< docsref "/utilities/text#line-length" >}}).
<!-- End mod -->

## Additional resources
Expand Down
11 changes: 11 additions & 0 deletions site/content/docs/5.1/utilities/text.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ Change the line height with `.lh-*` utilities.
<p class="lh-lg">This is a long paragraph written to show how the line-height of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.</p>
{{< /example >}}

## Line length

Limit the line length with `.ll-*` utilities. It applies `max-width` rule to an element with a width based on `ch` dimension, only on block-level elements and not on inline elements.

{{< example >}}
<p class="ll-sm">This is a long paragraph written to show how the line-length of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.</p>
<p class="ll-md">This is a long paragraph written to show how the line-length of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.</p>
<p><span class="ll-md"><strong>Inline element.</strong> This is a long paragraph written to show how the line-length of an inline element isn't affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.</span></p>
<p class="ll-md fs-3">This is a long paragraph written to show how the line-length of an element is affected by our utilities. Classes are applied to the element itself or sometimes the parent element. These classes can be customized as needed with our utility API.</p>
{{< /example >}}

## Monospace

Change a selection to our monospace font stack with `.font-monospace`.
Expand Down

0 comments on commit 578d907

Please sign in to comment.