-
Notifications
You must be signed in to change notification settings - Fork 842
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
[Amsterdam] Updating base text sizing #2936
Changes from all commits
7db8d3a
b8d423b
b6b5156
51cd9dc
7118768
967b3ba
ddbe267
282532a
a41398a
a0e8a4d
b998d02
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,31 +25,14 @@ | |
@mixin euiTitle($size: 'm') { | ||
color: $euiTitleColor; | ||
|
||
@if $size == 'xxxs' { | ||
@include euiFontSizeXS; | ||
@include lineHeightFromBaseline(3); | ||
font-weight: $euiFontWeightBold; | ||
} @else if $size == 'xxs' { | ||
@include euiFontSizeS; | ||
@include lineHeightFromBaseline(3); | ||
font-weight: $euiFontWeightBold; | ||
} @else if $size == 'xs' { | ||
@include euiFontSize; | ||
@include lineHeightFromBaseline(3); | ||
font-weight: $euiFontWeightSemiBold; | ||
letter-spacing: -.02em; | ||
} @else if $size == 's' { | ||
@include euiFontSizeL; | ||
@include lineHeightFromBaseline(4); | ||
font-weight: $euiFontWeightMedium; | ||
letter-spacing: -.025em; | ||
} @else if $size == 'm' { | ||
@include euiFontSizeXL; | ||
@include lineHeightFromBaseline(5); | ||
letter-spacing: -.04em; | ||
} @else if $size == 'l' { | ||
@include euiFontSizeXXL; | ||
@include lineHeightFromBaseline(6); | ||
@if (map-has-key($euiTitles, $size)) { | ||
@each $property, $value in map-get($euiTitles, $size) { | ||
@if ($property == 'font-size') { | ||
@include fontSize($value); | ||
} @else { | ||
#{$property}: $value; | ||
} | ||
} | ||
Comment on lines
+28
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
} @else { | ||
@include fontSize($size); | ||
@include lineHeightFromBaseline(3); | ||
|
@@ -84,17 +67,25 @@ | |
} | ||
|
||
@mixin euiFontSizeXL { | ||
@include fontSize($euiFontSizeXL); | ||
@each $property, $value in map-get($euiTitles, 'm') { | ||
@if ($property == 'font-size') { | ||
@include fontSize($value); | ||
} @else { | ||
#{$property}: $value; | ||
} | ||
} | ||
Comment on lines
+70
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid duplicating the same styles from the titles map, but wanting the xl & xxl large fonts to look the same as titles, we do the same procedure as in the You'll see the mismatch in mixin name |
||
line-height: 1.25; | ||
font-weight: $euiFontWeightLight; // always apply light weight to x-large type | ||
letter-spacing: -.05em; | ||
} | ||
|
||
@mixin euiFontSizeXXL { | ||
@include fontSize($euiFontSizeXXL); | ||
@each $property, $value in map-get($euiTitles, 'l') { | ||
@if ($property == 'font-size') { | ||
@include fontSize($value); | ||
} @else { | ||
#{$property}: $value; | ||
} | ||
} | ||
line-height: 1.25; | ||
font-weight: $euiFontWeightLight; // always apply light weight to xx-large type | ||
letter-spacing: -.03em; | ||
} | ||
|
||
@mixin euiTextBreakWord { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
} | ||
|
||
// Spit out rem and px | ||
|
||
@mixin fontSize($size: $euiFontSize) { | ||
font-size: $size; | ||
font-size: convertToRem($size); | ||
|
@@ -19,13 +18,14 @@ | |
// EX: A proper line-height for text is 1.5 times the font-size. | ||
// If our base font size (euiFontSize) is 16, our baseline is 8 (16*1.5 / 3). To ensure the | ||
// text stays on the baseline, we pass a multiplier to calculate a line-height in rems. | ||
@function lineHeightFromBaseline($multiplier: 3) { | ||
@return convertToRem(($euiFontSize/2)*$multiplier); | ||
} | ||
Comment on lines
+21
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needed to duplicate this mixin as a function so it could be used in the map There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe remove the mixin and replace with the function usage in other parts of the code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or at the least, use the function in the in the mixin inception style. |
||
@mixin lineHeightFromBaseline($multiplier: 3) { | ||
line-height: convertToRem(($euiFontSize/2)*$multiplier); | ||
line-height: lineHeightFromBaseline($multiplier); | ||
} | ||
|
||
|
||
// Families | ||
|
||
$euiFontFamily: 'Inter UI', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol' !default; | ||
$euiCodeFontFamily: 'Roboto Mono', Consolas, Menlo, Courier, monospace !default; | ||
|
||
|
@@ -36,7 +36,6 @@ $euiFontFeatureSettings: 'calt' 1, 'kern' 1, 'liga' 1 !default; | |
$euiTextScale: 2.25, 1.75, 1.25, 1.125, 1, .875, .75 !default; | ||
|
||
$euiFontSize: $euiSize !default; // 5th position in scale | ||
|
||
$euiFontSizeXS: $euiFontSize * nth($euiTextScale, 7) !default; // 12px | ||
$euiFontSizeS: $euiFontSize * nth($euiTextScale, 6) !default; // 14px | ||
$euiFontSizeM: $euiFontSize * nth($euiTextScale, 4) !default; // 18px | ||
|
@@ -45,14 +44,51 @@ $euiFontSizeXL: $euiFontSize * nth($euiTextScale, 2) !default; // 28px | |
$euiFontSizeXXL: $euiFontSize * nth($euiTextScale, 1) !default; // 36px | ||
|
||
// Line height | ||
|
||
$euiLineHeight: 1.5; | ||
|
||
|
||
// Font weights | ||
|
||
$euiFontWeightLight: 300 !default; | ||
$euiFontWeightRegular: 400 !default; | ||
$euiFontWeightMedium: 500 !default; | ||
$euiFontWeightSemiBold: 600 !default; | ||
$euiFontWeightBold: 700 !default; | ||
|
||
// Titles map | ||
// Lists all the properties per EuiTitle size that then gets looped through to create the selectors. | ||
// The map allows for tokenization and easier customization per theme, otherwise you'd have to override the selectors themselves | ||
$euiTitles: ( | ||
'xxxs': ( | ||
'font-size': $euiFontSizeXS, | ||
'line-height': lineHeightFromBaseline(3), | ||
'font-weight': $euiFontWeightBold, | ||
), | ||
Comment on lines
+59
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a new map that has keys that match our EuiTitle scales. You can add any property as a quoted key and it will get applied to that title size (in both EuiTitle and EuiText(size medium)) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand this and know that it's replacing old code that did something similar, but you should likely comment on WHY this is set up this way. Letter-spacing is super uncommon in most CSS, and more so as a scale. Just some comments in here to describe why it's important would be nice for someone coming to this code for the first time. |
||
'xxs': ( | ||
'font-size': $euiFontSizeS, | ||
'line-height': lineHeightFromBaseline(3), | ||
'font-weight': $euiFontWeightBold, | ||
), | ||
'xs': ( | ||
'font-size': $euiFontSize, | ||
'line-height': lineHeightFromBaseline(3), | ||
'font-weight': $euiFontWeightSemiBold, | ||
'letter-spacing': -.02em, | ||
), | ||
's': ( | ||
'font-size': $euiFontSizeL, | ||
'line-height': lineHeightFromBaseline(4), | ||
'font-weight': $euiFontWeightMedium, | ||
'letter-spacing': -.025em, | ||
), | ||
'm': ( | ||
'font-size': $euiFontSizeXL, | ||
'line-height': lineHeightFromBaseline(5), | ||
'font-weight': $euiFontWeightLight, | ||
'letter-spacing': -.04em, | ||
), | ||
'l': ( | ||
'font-size': $euiFontSizeXXL, | ||
'line-height': lineHeightFromBaseline(6), | ||
'font-weight': $euiFontWeightLight, | ||
'letter-spacing': -.03em, | ||
), | ||
) !default; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ $euiColorPrimary: #006DE4; | |
$euiColorSecondary: #00BFB3; | ||
$euiColorAccent: #FC358E; | ||
|
||
$euiLinkColor: $euiColorPrimary; // Weirdly this one wasn't updating with new primary color | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note to self: look into this mystery. |
||
|
||
// Contrasty text variants | ||
$euiColorPrimaryText: makeHighContrastColor($euiColorPrimary); | ||
$euiColorSecondaryText: makeHighContrastColor($euiColorSecondary); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
@import 'panel'; | ||
@import 'button'; | ||
@import 'panel'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
@import 'buttons'; | ||
@import 'borders'; | ||
@import 'typography'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Finally start using the non-beta version of Inter | ||
$euiFontFamily: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yay for finalized |
||
|
||
// Font sizes -- scale is loosely based on Major Third (1.250) with a base of 14px | ||
// Base list is an altered scale based on 16px to match the resulted values below | ||
$euiTextScale: 2.125, 1.6875, 1.375, 1.125, 1, .875, .75; | ||
|
||
$euiFontSize: $euiSize - 2; // 14px | ||
|
||
$euiFontSizeXS: floor($euiFontSize * .86); // 12px // h6 | ||
$euiFontSizeS: floor($euiFontSize * 1); // 14px // h5 --> Now the same as the base $euiFontSize | ||
$euiFontSizeM: ceil($euiFontSize * 1.14); // 16px // h4 | ||
$euiFontSizeL: ceil($euiFontSize * 1.57); // 22px // h3 | ||
$euiFontSizeXL: floor($euiFontSize * 1.93); // 27px // h2 | ||
$euiFontSizeXXL: floor($euiFontSize * 2.43); // 34px // h1 | ||
|
||
$euiTitles: ( | ||
'xxxs': ( | ||
'font-size': $euiFontSizeXS, | ||
'line-height': lineHeightFromBaseline(3), | ||
'font-weight': $euiFontWeightBold, | ||
), | ||
'xxs': ( | ||
'font-size': $euiFontSizeS, | ||
'line-height': lineHeightFromBaseline(3), | ||
'font-weight': $euiFontWeightBold, | ||
), | ||
'xs': ( | ||
'font-size': $euiFontSizeM, | ||
'line-height': lineHeightFromBaseline(3), | ||
'font-weight': $euiFontWeightBold, | ||
), | ||
's': ( | ||
'font-size': $euiFontSizeL, | ||
'line-height': lineHeightFromBaseline(4), | ||
'font-weight': $euiFontWeightBold, | ||
), | ||
'm': ( | ||
'font-size': $euiFontSizeXL, | ||
'line-height': lineHeightFromBaseline(5), | ||
'font-weight': $euiFontWeightBold, | ||
), | ||
'l': ( | ||
'font-size': $euiFontSizeXXL, | ||
'line-height': lineHeightFromBaseline(6), | ||
'font-weight': $euiFontWeightBold, | ||
), | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
@import 'button'; | ||
@import 'button_empty'; | ||
@import 'button_group'; | ||
@import 'text'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Increase the medium (currently default) size of EuiText to original 16px | ||
.euiText--medium { | ||
@include fontSize($euiFontSizeM); | ||
@include euiScaleText($euiFontSizeM); | ||
} | ||
Comment on lines
+2
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't exist as a selector in the default theme. So it works great as an override selector for plain There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A bonus feature of me leaving selectors that don't do anything 😈 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is where we need to us the
fontSize()
mixin to provide bothpx
andrem
values of the'font-size'
provided which should be apx
value.