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

[Amsterdam] Updating base text sizing #2936

Merged
merged 11 commits into from
Mar 13, 2020

Conversation

daveyholler
Copy link
Contributor

@daveyholler daveyholler commented Feb 26, 2020

Summary

  • Changing the text sizes to be calculated off of a smaller 14px base font size.
  • Headings (h1- h6) and EuiTitle now use $euiFontWeightBold

Consumers

The titles and headings in EUI Amsterdam are now bold. When migrating to the Amsterdam theme you'll want to pay close attention to areas like dashboards or other high-density screens to ensure that the bold headings haven't caused your layouts to break.

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in IE11 and Firefox
    - [ ] Props have proper autodocs
    - [ ] Added documentation examples
    - [ ] Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
    - [ ] Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@daveyholler daveyholler requested a review from cchaos February 26, 2020 17:38
@daveyholler daveyholler marked this pull request as ready for review February 26, 2020 17:38
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_2936/

@daveyholler daveyholler changed the title Am/updating text [Amsterdam] updating text Feb 27, 2020
@cchaos cchaos force-pushed the am/updating-text branch from cc52b1e to 1d7070e Compare March 4, 2020 19:28
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_2936/

@cchaos cchaos force-pushed the am/updating-text branch from 1d7070e to 3183c31 Compare March 5, 2020 00:09
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_2936/

@snide
Copy link
Contributor

snide commented Mar 5, 2020

Do you need review on this one @daveyholler / @cchaos ?

@cchaos cchaos changed the title [Amsterdam] updating text [WIP] [Amsterdam] updating text Mar 5, 2020
@cchaos
Copy link
Contributor

cchaos commented Mar 5, 2020

Sorry, no not quite yet, I'll get bette at adding the [WIP] labels and titles.

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_2936/

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've commented on the code to describe what's going on. Figured its easier to point to the bits. But here are some accompanying screenshots.

Text scales remain the same
Screen Shot 2020-03-11 at 19 22 38 PM

Title sizes are similar but have changed slightly, mostly weight but font-size and line-height too
Screen Shot 2020-03-11 at 19 24 47 PM

Components like buttons get the smaller font size while EuiText remains the same (16px for medium)
Screen Shot 2020-03-11 at 19 27 22 PM

Components that used font size variables directly get basically no change unless it was the default $euiTextSize. So things like forms don't get smaller (they're already small)
Screen Shot 2020-03-11 at 19 29 23 PM

Comment on lines +28 to +35
@if (map-has-key($euiTitles, $size)) {
@each $property, $value in map-get($euiTitles, $size) {
@if ($property == 'font-size') {
@include fontSize($value);
} @else {
#{$property}: $value;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The euiTitle() mixin now loops through the new $euiTitle map, finding the matching key first, then looping through that object and parsing the keys ('line-height') as properties and their values.

Comment on lines +30 to +31
@if ($property == 'font-size') {
@include fontSize($value);
Copy link
Contributor

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 both px and rem values of the 'font-size' provided which should be a px value.

Comment on lines +70 to +76
@each $property, $value in map-get($euiTitles, 'm') {
@if ($property == 'font-size') {
@include fontSize($value);
} @else {
#{$property}: $value;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The 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 euiTitles() mixin.

You'll see the mismatch in mixin name euiFontSizeXL to the key lookup 'm', because we didn't use a proper titling scale that matched our sass vars and now we're stuck with it 🤣

Comment on lines +24 to +26
@function lineHeightFromBaseline($multiplier: 3) {
@return convertToRem(($euiFontSize/2)*$multiplier);
}
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Comment on lines +57 to +62
$euiTitles: (
'xxxs': (
'font-size': $euiFontSizeXS,
'line-height': lineHeightFromBaseline(3),
'font-weight': $euiFontWeightBold,
),
Copy link
Contributor

Choose a reason for hiding this comment

The 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))

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@@ -0,0 +1,51 @@
// 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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay for finalized Inter not Inter UI !

Comment on lines 4 to 11
// 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;
// This is a new list because changing the base list messes with EuiText
// So it's only being used to calculate the font size variables
$amsTextScale: 2.429, 1.929, 1.571, 1.285, 1.143, 1, .857;

$euiFontSize: $euiSize - 2; // 14px
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where it starts to get crazy...

THE GOAL: 14px base font size

  • Plain ole text inherits font-size: 14px from html,body
  • Anything using base $euiFontSize is 14px, buttons, tabs, etc...
  • EuiTitle sizing are the largest they'll ever be in scale
  • EuiText's headings in size medium match EuiTitle sizes

However:
EuiText size medium is still a base of 16px so that we can continue to have large-form (wall of text, blog style, etc) text be larger for legibility. Which means all the text scales for EuiText pretty much remain the same. Small is 14, Xsmall is 12 just as before.

Also
EuiTitle sizes only change ever so slightly to still be a major third scale but with the base being at position 6 instead of 5 as previously. But we want the EuiText.medium heading sizes (h1-16) to match our EuiTitle sizes, so we adjust the original $euiTextScale's numbers to calculate to the equivalent of the new title sizes below. This means as it's passed to EuiText, it properly calculates off of 16px... trust me it works 😉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self for review:

The only downside to something like this that I can think of is that having $euiSize and $euiFontSize different means that anything heavily relying on both (I'm thinking loose line heights) will lose some balance. Specifically, looking at some spots where line height of 1.5 (the most common value) will create odd pixel numbers against $euiSize derived values. Tabs are now 45px...etc. In isolation, this will be fine, but when components line up next to each other but have mixed value calcs... I anticipate this will cause some small breaks in places that might mean we might need to not rely on padding + font size to make the height of something. Should likely lead to more tolerant code as we spot those breaks and fix the trouble spots.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it'll be interesting to see what this effects downstream. But it's essentially the same as doing:

font-size: $euiFontSizeSmall;
padding: $euiSize;

Comment on lines 13 to 18
$euiFontSizeXS: ceil($euiFontSize * nth($amsTextScale, 7)); // 12px // h6
$euiFontSizeS: floor($euiFontSize * nth($amsTextScale, 6)); // 14px // h5 --> Now the same as the base $euiFontSize
$euiFontSizeM: floor($euiFontSize * nth($amsTextScale, 5)); // 16px // h4
$euiFontSizeL: ceil($euiFontSize * nth($amsTextScale, 3)); // 22px // h3
$euiFontSizeXL: floor($euiFontSize * nth($amsTextScale, 2)); // 27px // h2
$euiFontSizeXXL: floor($euiFontSize * nth($amsTextScale, 1)); // 34px // h1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then the $amsTextScale is only used in this file to calculate these new font sizes, based on the new $euiFontSize;

Because $euiFontSizeS is the same as $euiFontSize, it almost makes the plain $euiFontSize moot, which is kind of a good thing since it was confusing where it'd lie within the scale.

Comment on lines +2 to +5
.euiText--medium {
@include fontSize($euiFontSizeM);
@include euiScaleText($euiFontSizeM);
}
Copy link
Contributor

Choose a reason for hiding this comment

The 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 .euiText

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bonus feature of me leaving selectors that don't do anything 😈

@cchaos cchaos requested a review from snide March 11, 2020 23:31
@cchaos cchaos changed the title [WIP] [Amsterdam] updating text [Amsterdam] Updating base text sizing Mar 11, 2020
@cchaos
Copy link
Contributor

cchaos commented Mar 11, 2020

This PR is now ready for review.

Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While eating a slice of pizza I made the mistake of looking at this code. These are mostly notes for when I need look closer at the output. Looking at how you wrote this I can see it has pretty much zero impact on current EUI which means it's fairly safe to merge as is. I want to do a pretty thorough scan of the display tomorrow to see what falls out from the size change. Off hand every time I think I see an AHA moment, I see the same error in current EUI.

As suspicious as I am of a change this big ... everything looks ok ⛹️‍♀️

Comment on lines 4 to 11
// 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;
// This is a new list because changing the base list messes with EuiText
// So it's only being used to calculate the font size variables
$amsTextScale: 2.429, 1.929, 1.571, 1.285, 1.143, 1, .857;

$euiFontSize: $euiSize - 2; // 14px
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self for review:

The only downside to something like this that I can think of is that having $euiSize and $euiFontSize different means that anything heavily relying on both (I'm thinking loose line heights) will lose some balance. Specifically, looking at some spots where line height of 1.5 (the most common value) will create odd pixel numbers against $euiSize derived values. Tabs are now 45px...etc. In isolation, this will be fine, but when components line up next to each other but have mixed value calcs... I anticipate this will cause some small breaks in places that might mean we might need to not rely on padding + font size to make the height of something. Should likely lead to more tolerant code as we spot those breaks and fix the trouble spots.

Comment on lines +57 to +62
$euiTitles: (
'xxxs': (
'font-size': $euiFontSizeXS,
'line-height': lineHeightFromBaseline(3),
'font-weight': $euiFontWeightBold,
),
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Comment on lines +2 to +5
.euiText--medium {
@include fontSize($euiFontSizeM);
@include euiScaleText($euiFontSizeM);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bonus feature of me leaving selectors that don't do anything 😈

Comment on lines +24 to +26
@function lineHeightFromBaseline($multiplier: 3) {
@return convertToRem(($euiFontSize/2)*$multiplier);
}
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

src-docs/src/theme_amsterdam_light.scss Outdated Show resolved Hide resolved
@@ -5,6 +5,8 @@ $euiColorPrimary: #006DE4;
$euiColorSecondary: #00BFB3;
$euiColorAccent: #FC358E;

$euiLinkColor: $euiColorPrimary; // Weirdly this one wasn't updating with new primary color
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: look into this mystery.

Comment on lines +24 to +26
@function lineHeightFromBaseline($multiplier: 3) {
@return convertToRem(($euiFontSize/2)*$multiplier);
}
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_2936/

@cchaos cchaos force-pushed the am/updating-text branch from 6739067 to a41398a Compare March 12, 2020 15:10
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_2936/

@snide
Copy link
Contributor

snide commented Mar 12, 2020

@cchaos I did a more thorough scan on the display side of this and I think it looks good. I know there will be some breaks from this, specifically because of the odd pixel 1.5 line-height, but nothing in here looks dangerous in regards to current EUI themes. My questions from above still stand, but I think this is generally OK to merge and we'll just deal with any issues as we notice them.

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_2936/

Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to merge. We'll see what shakes out on this one over time.

@cchaos cchaos merged commit 2f04008 into elastic:master Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants