Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@

**Theme: Amsterdam**

- Text sizes are now based on a 14px base font size. Headings are now bold. ([#2936](https://github.com/elastic/eui/pull/2936))
- Altered `secondary`, `accent` colors to be more saturated ([#2873](https://github.com/elastic/eui/pull/2873))

## [`20.0.2`](https://github.com/elastic/eui/tree/v20.0.2)
Expand Down
3 changes: 1 addition & 2 deletions src-docs/src/theme_amsterdam_dark.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// sass-lint:disable no-url-domains, no-url-protocols
@import url('https://fonts.googleapis.com/css?family=Roboto+Mono:400,400i,700,700i');
@import url('https://rsms.me/inter/inter-ui.css');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Roboto+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap');

@import '../../src/theme_amsterdam_dark';
@import './components/guide_components';
Expand Down
3 changes: 1 addition & 2 deletions src-docs/src/theme_amsterdam_light.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// sass-lint:disable no-url-domains, no-url-protocols
@import url('https://fonts.googleapis.com/css?family=Roboto+Mono:400,400i,700,700i');
@import url('https://rsms.me/inter/inter-ui.css');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Roboto+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap');

@import '../../src/theme_amsterdam_light';
@import './components/guide_components';
Expand Down
53 changes: 22 additions & 31 deletions src/global_styling/mixins/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Comment on lines +30 to +31

Copy link
Copy Markdown
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.

} @else {
#{$property}: $value;
}
}
Comment on lines +28 to +35

Copy link
Copy Markdown
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.

} @else {
@include fontSize($size);
@include lineHeightFromBaseline(3);
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
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 🤣

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 {
Expand Down
48 changes: 41 additions & 7 deletions src/global_styling/variables/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
}

// Spit out rem and px

@mixin fontSize($size: $euiFontSize) {
font-size: $size;
font-size: convertToRem($size);
Expand All @@ -22,10 +21,11 @@
@mixin lineHeightFromBaseline($multiplier: 3) {
line-height: convertToRem(($euiFontSize/2)*$multiplier);
}

@function lineHeightFromBaseline($multiplier: 3) {
@return convertToRem(($euiFontSize/2)*$multiplier);
}
Comment on lines +21 to +23

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.


// 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;

Expand All @@ -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
Expand All @@ -45,14 +44,49 @@ $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
$euiTitles: (
'xxxs': (
'font-size': $euiFontSizeXS,
'line-height': lineHeightFromBaseline(3),
'font-weight': $euiFontWeightBold,
),
Comment on lines +59 to +64

Copy link
Copy Markdown
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
Copy Markdown
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.

'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;
2 changes: 2 additions & 0 deletions src/themes/eui-amsterdam/eui_amsterdam_colors_light.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ $euiColorPrimary: #006DE4;
$euiColorSecondary: #00BFB3;
$euiColorAccent: #FC358E;

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

Copy link
Copy Markdown
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.


// Contrasty text variants
$euiColorPrimaryText: makeHighContrastColor($euiColorPrimary);
$euiColorSecondaryText: makeHighContrastColor($euiColorSecondary);
Expand Down
2 changes: 1 addition & 1 deletion src/themes/eui-amsterdam/global_styling/mixins/_index.scss
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';
51 changes: 51 additions & 0 deletions src/themes/eui-amsterdam/global_styling/variables/_typography.scss
Original file line number Diff line number Diff line change
@@ -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
Copy Markdown
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 !


// 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;
Comment thread
snide marked this conversation as resolved.
Outdated

$euiFontSize: $euiSize - 2; // 14px
Comment on lines +4 to +8

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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;


$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
Copy Markdown
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.


$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,
),
);
1 change: 1 addition & 0 deletions src/themes/eui-amsterdam/overrides/_index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import 'button';
@import 'button_empty';
@import 'button_group';
@import 'text';
5 changes: 5 additions & 0 deletions src/themes/eui-amsterdam/overrides/_text.scss
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

Copy link
Copy Markdown
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
Copy Markdown
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 😈