Skip to content

Commit

Permalink
Introduce $ouiLegibilityMaxWidth variable and `ouiLegibilityMaxWidt…
Browse files Browse the repository at this point in the history
…h` mixin (#1359)

Signed-off-by: Miki <[email protected]>
(cherry picked from commit b049275)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
github-actions[bot] committed Aug 16, 2024
1 parent ce1daa0 commit 206fbdc
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/global_styling/mixins/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,19 @@
}
}

// Lowest max-width
//
// Legibility research specific to digital text has shown that line length can affect reading
// speed. If lines are too long it is difficult for the reader to quickly return to the start
// of the next line, whereas if lines are too short more scrolling or paging will be required.
//
// This mixin will choose the lesser of the magic $ouiLegibilityMaxWidth number and the
// supplied $maxWidth to allow controlling the max-width without needing media-queries.

@mixin ouiLegibilityMaxWidth($maxWidth) {
max-width: min($ouiLegibilityMaxWidth, $maxWidth);
}



/* OUI -> EUI Aliases */
Expand All @@ -165,4 +178,5 @@
@mixin euiTextTruncate { @include ouiTextTruncate; }
@mixin euiNumberFormat { @include ouiNumberFormat; }
@mixin euiTextShift($fontWeight: $ouiFontWeightBold, $attr: 'data-text') { @include ouiTextShift($fontWeight, $attr); }
@mixin euiLegibilityMaxWidth($maxWidth) { @include ouiLegibilityMaxWidth($maxWidth); }
/* End of Aliases */
4 changes: 4 additions & 0 deletions src/global_styling/variables/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ $ouiFontSizeL: $ouiFontSize * nth($ouiTextScale, 3) !default; // 20px
$ouiFontSizeXL: $ouiFontSize * nth($ouiTextScale, 2) !default; // 28px
$ouiFontSizeXXL: $ouiFontSize * nth($ouiTextScale, 1) !default; // 36px

// This value is impacted by font-size
$ouiLegibilityMaxWidth: 80ch !default;

// Line height
$ouiLineHeight: 1.5 !default;
$ouiBodyLineHeight: 1 !default;
Expand Down Expand Up @@ -122,6 +125,7 @@ $euiFontSizeM: $ouiFontSizeM;
$euiFontSizeL: $ouiFontSizeL;
$euiFontSizeXL: $ouiFontSizeXL;
$euiFontSizeXXL: $ouiFontSizeXXL;
$euiLegibilityMaxWidth: $ouiLegibilityMaxWidth;
$euiLineHeight: $ouiLineHeight;
$euiBodyLineHeight: $ouiBodyLineHeight;
$euiFontWeightLight: $ouiFontWeightLight;
Expand Down
14 changes: 14 additions & 0 deletions src/themes/oui-next/global_styling/mixins/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,19 @@
}
}

// Lowest max-width
//
// Legibility research specific to digital text has shown that line length can affect reading
// speed. If lines are too long it is difficult for the reader to quickly return to the start
// of the next line, whereas if lines are too short more scrolling or paging will be required.
//
// This mixin will choose the lesser of the magic $ouiLegibilityMaxWidth number and the
// supplied $maxWidth to allow controlling the max-width without needing media-queries.

@mixin ouiLegibilityMaxWidth($maxWidth) {
max-width: min($ouiLegibilityMaxWidth, $maxWidth);
}



/* OUI -> EUI Aliases */
Expand All @@ -165,4 +178,5 @@
@mixin euiTextTruncate { @include ouiTextTruncate; }
@mixin euiNumberFormat { @include ouiNumberFormat; }
@mixin euiTextShift($fontWeight: $ouiFontWeightBold, $attr: 'data-text') { @include ouiTextShift($fontWeight, $attr); }
@mixin euiLegibilityMaxWidth($maxWidth) { @include ouiLegibilityMaxWidth($maxWidth); }
/* End of Aliases */
4 changes: 4 additions & 0 deletions src/themes/oui-next/global_styling/variables/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ $ouiFontSizeL: $ouiFontSize * nth($ouiTextScale, 3) !default; // 20px
$ouiFontSizeXL: $ouiFontSize * nth($ouiTextScale, 2) !default; // 28px
$ouiFontSizeXXL: $ouiFontSize * nth($ouiTextScale, 1) !default; // 36px

// This value is impacted by font-size
$ouiLegibilityMaxWidth: 80ch !default;

// Line height
$ouiLineHeight: 1.333333 !default;
$ouiBodyLineHeight: 1 !default;
Expand Down Expand Up @@ -125,6 +128,7 @@ $euiFontSizeM: $ouiFontSizeM;
$euiFontSizeL: $ouiFontSizeL;
$euiFontSizeXL: $ouiFontSizeXL;
$euiFontSizeXXL: $ouiFontSizeXXL;
$euiLegibilityMaxWidth: $ouiLegibilityMaxWidth;
$euiLineHeight: $ouiLineHeight;
$euiBodyLineHeight: $ouiBodyLineHeight;
$euiFontWeightLight: $ouiFontWeightLight;
Expand Down
14 changes: 14 additions & 0 deletions src/themes/v9/global_styling/mixins/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,19 @@
}
}

// Lowest max-width
//
// Legibility research specific to digital text has shown that line length can affect reading
// speed. If lines are too long it is difficult for the reader to quickly return to the start
// of the next line, whereas if lines are too short more scrolling or paging will be required.
//
// This mixin will choose the lesser of the magic $ouiLegibilityMaxWidth number and the
// supplied $maxWidth to allow controlling the max-width without needing media-queries.

@mixin ouiLegibilityMaxWidth($maxWidth) {
max-width: min($ouiLegibilityMaxWidth, $maxWidth);
}



/* OUI -> EUI Aliases */
Expand All @@ -165,4 +178,5 @@
@mixin euiTextTruncate { @include ouiTextTruncate; }
@mixin euiNumberFormat { @include ouiNumberFormat; }
@mixin euiTextShift($fontWeight: $ouiFontWeightBold, $attr: 'data-text') { @include ouiTextShift($fontWeight, $attr); }
@mixin euiLegibilityMaxWidth($maxWidth) { @include ouiLegibilityMaxWidth($maxWidth); }
/* End of Aliases */
4 changes: 4 additions & 0 deletions src/themes/v9/global_styling/variables/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ $ouiFontSizeL: $ouiFontSize * nth($ouiTextScale, 3) !default; // 20px
$ouiFontSizeXL: $ouiFontSize * nth($ouiTextScale, 2) !default; // 28px
$ouiFontSizeXXL: $ouiFontSize * nth($ouiTextScale, 1) !default; // 36px

// This value is impacted by font-size
$ouiLegibilityMaxWidth: 80ch !default;

// Line height
$ouiLineHeight: 1.5 !default;
$ouiBodyLineHeight: 1 !default;
Expand Down Expand Up @@ -125,6 +128,7 @@ $euiFontSizeM: $ouiFontSizeM;
$euiFontSizeL: $ouiFontSizeL;
$euiFontSizeXL: $ouiFontSizeXL;
$euiFontSizeXXL: $ouiFontSizeXXL;
$euiLegibilityMaxWidth: $ouiLegibilityMaxWidth;
$euiLineHeight: $ouiLineHeight;
$euiBodyLineHeight: $ouiBodyLineHeight;
$euiFontWeightLight: $ouiFontWeightLight;
Expand Down

0 comments on commit 206fbdc

Please sign in to comment.