Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 1.x] Introduce $ouiLegibilityMaxWidth variable and ouiLegibilityMaxWidth mixin #1361

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 */
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
Loading