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

[Emotion][Theming] Add new consumer-configurable font.defaultUnits token #7133

Merged
merged 8 commits into from
Aug 29, 2023

Conversation

cee-chen
Copy link
Member

@cee-chen cee-chen commented Aug 28, 2023

Summary

closes #7124

Currently, all Emotion component font sizes use rem sizing and this isn't something that we allow configuration for (e.g. to px or em) values. Adding a new font.defaultUnits token to our EUI theme will enable consumers to easily and quickly customize our component font size CSS output in one place.

⚠️ Note that there are a few components that do need to set a custom measurement override that does not use this new token - primarily <EuiText size="relative"> is the (current) one instance of this in EUI where em is enforced.

Screencap of example usage:

QA

General checklist

@kibanamachine
Copy link

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

@cee-chen cee-chen marked this pull request as ready for review August 28, 2023 20:16
@cee-chen cee-chen requested review from a team and 1Copenut August 28, 2023 20:16
@@ -34,6 +34,7 @@ export const fontBase: _EuiThemeFontBase = {

// Careful using ligatures. Code editors like ACE will often error because of width calculations
featureSettings: "'calt' 1, 'kern' 1, 'liga' 1",
fontSizeUnit: 'rem',
Copy link
Member Author

@cee-chen cee-chen Aug 28, 2023

Choose a reason for hiding this comment

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

[naming things is hard] now that I realize line-height is using this as well as font-size, I'm wondering if this var name still makes sense. Maybe just

Suggested change
fontSizeUnit: 'rem',
sizeUnit: 'rem',

or

Suggested change
fontSizeUnit: 'rem',
unit: 'rem',

orrrr

Suggested change
fontSizeUnit: 'rem',
defaultUnits: 'rem',

??

Copy link
Contributor

Choose a reason for hiding this comment

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

I lean toward defaultUnits myself. When I see the object font.defaultUnits I immediately think "pixesl, ems, or rems."

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm leaning towards defaultUnits as well! Going to make that change here 🎉

Copy link
Member Author

@cee-chen cee-chen Aug 28, 2023

Choose a reason for hiding this comment

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

Token rename: c94844c

Far more opinionated rename of all measurement-adjacent variable names to unit instead: 7d3c34a

I'd be curious to hear what you think about the 2nd commit - for me personally, as a dev with over a decade of CSS experience, measurement means very little to me, whereas unit has a very specific connotation within CSS font sizes and I feel it more accurately describes the enum. That being said, I'm being pretty opinionated with that change, so if you're not a fan of it or are worried about downstream implications, I'm definitely open to reverting it!

Copy link
Contributor

@1Copenut 1Copenut Aug 29, 2023

Choose a reason for hiding this comment

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

I'm looking at the changes now and I think you're onto something with this new naming convention.

To my thinking

  • 16 is a measurement
  • px are the units

Units mean a lot more to me too. The functions are clearer with the new names. I trust your call to make this change and support it 100%.

Copy link
Member Author

@cee-chen cee-chen Aug 29, 2023

Choose a reason for hiding this comment

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

Great call on the distinction. It sounds like you're good with moving ahead with the full rename - if so, I'll merge the PR once you've approved. Thanks again Trevor!

@kibanamachine
Copy link

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

Copy link
Contributor

@1Copenut 1Copenut left a comment

Choose a reason for hiding this comment

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

Just two comments on naming. I'll update my review to Approved when teammates have had a chance to weigh in.

@@ -34,6 +34,7 @@ export const fontBase: _EuiThemeFontBase = {

// Careful using ligatures. Code editors like ACE will often error because of width calculations
featureSettings: "'calt' 1, 'kern' 1, 'liga' 1",
fontSizeUnit: 'rem',
Copy link
Contributor

Choose a reason for hiding this comment

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

I lean toward defaultUnits myself. When I see the object font.defaultUnits I immediately think "pixesl, ems, or rems."

src/global_styling/variables/typography.ts Outdated Show resolved Hide resolved
…riables to `unit` instead

- this feels like a far more understandable nomenclature that native CSS already uses

- it's technically a breaking change, but I'm not even sure who's using these types or utilities, so tbh I'm more inclined to file it under our Emotion header
@cee-chen cee-chen changed the title [Emotion][Theming] Add new consumer-configurable fontSizeUnit token [Emotion][Theming] Add new consumer-configurable font.defaultUnits token Aug 28, 2023
@kibanamachine
Copy link

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

Copy link
Contributor

@1Copenut 1Copenut left a comment

Choose a reason for hiding this comment

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

💯 LGTM!

@kibanamachine
Copy link

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

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

@cee-chen cee-chen merged commit 86e6702 into elastic:main Aug 29, 2023
6 of 7 checks passed
@cee-chen cee-chen deleted the font-unit-token branch August 29, 2023 18:22
jbudz pushed a commit to elastic/kibana that referenced this pull request Sep 5, 2023
## PR change summary

`v87.2.0`⏩`v88.1.0`

⚠️ The biggest thing to QA in this PR is several **breaking changes** to
`EuiDescriptionList`.

### Description list `columnWidths` prop

This PR introduces a new `columnWidths` prop and removes several Kibana
instances of custom CSS overrides to title/description column widths.

The primary motivation behind this is not just to reduce custom CSS, but
also because v88.0.0 introduced an underlying CSS change of `column`
description lists to using [`display: grid`
CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout).
The new prop allows us to support existing description list custom
widths while not requiring Kibana developers to understand or write grid
CSS (except for 1 or two scenarios around `max-width`).

⚠️ **No user-facing UI around column widths should have regressed as a
result of these changes. If they have, please let us know in this PR.**

### Description list gutter size changes

The prop `gutterSize` has been renamed to `rowGutterSize` and the
default size is now `s` instead of `m`.

The change to `s` from `m` means there is an **expected** smaller gap
between list items (see below screenshots):

**Current `EuiDescriptionList` with default `rowGutterSize="s"`**
<img width="753" alt=""
src="https://github.com/elastic/kibana/assets/934879/c17aef28-ed3b-40c4-84c3-396e788b13bb">

**Prior `EuiDescriptionList` with default `gutterSize="m"`**
<img width="721" alt=""
src="https://github.com/elastic/kibana/assets/934879/84d5f5a2-8fa6-4f99-9dc0-73fd143aa1e1">

If Kibana teams prefer to keep the previous `m` gutter for their
instances of `EuiDescriptionList`, you have a couple of options:

1. Let EUI team know in the PR and we can set usage back to what it was
before
2. Set `rowGutterSize="m"` yourselves manually

---

## [`88.1.0`](https://github.com/elastic/eui/tree/v88.1.0)

- Added `font.defaultUnits` theme token. EUI component font sizes
default to `rem` units - this token allows consumers to configure this
to `px` or `em` ([#7133](elastic/eui#7133))
- Updated `EuiDescriptionList` with new `columnWidths` prop
([#7146](elastic/eui#7146))

**Bug fixes**

- Fixed `EuiDataGrid`'s keyboard shortcuts popover display
([#7146](elastic/eui#7146))

**CSS-in-JS conversions**

- Renamed `useEuiFontSize()`'s `measurement` option to `unit` for
clarity ([#7133](elastic/eui#7133))

## [`88.0.0`](https://github.com/elastic/eui/tree/v88.0.0)

- Updated `EuiDescriptionList` with a new `columnGutterSize` prop
([#7062](elastic/eui#7062))

**Deprecations**

- Deprecated `EuiSuggest`. We recommend using `EuiSelectable` or
`EuiComboBox` instead
([#7122](elastic/eui#7122))
- Deprecated `EuiControlBar`. We recommend using `EuiBottomBar` instead
([#7122](elastic/eui#7122))
- Deprecated `EuiColorStops`. We recommend copying the component to your
application if necessary
([#7122](elastic/eui#7122))
- Deprecated `EuiNotificationEvent`. We recommend copying the component
to your application if necessary
([#7122](elastic/eui#7122))

**Breaking changes**

- Renamed `EuiDescriptionList`'s `gutterSize` prop to `rowGutterSize`
([#7062](elastic/eui#7062))
- `EuiDescriptionList`'s `rowGutterSize` prop now defaults to a size of
`s` (was previously `m`)
([#7062](elastic/eui#7062))

**Accessibility**

- Fixed the dark mode colors of inline `EuiDescriptionListTitle`s to
meet WCAG color contrast requirements
([#7062](elastic/eui#7062))

**CSS-in-JS conversions**

- Converted `EuiKeyPadMenuItem` to Emotion; Removed `$euiKeyPadMenuSize`
and `$euiKeyPadMenuMarginSize`
([#7118](elastic/eui#7118))

---------

Co-authored-by: Cee Chen <constance.chen@elastic.co>
Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Nikita Indik <nikita.indik@elastic.co>
bryce-b pushed a commit to bryce-b/kibana that referenced this pull request Sep 19, 2023
## PR change summary

`v87.2.0`⏩`v88.1.0`

⚠️ The biggest thing to QA in this PR is several **breaking changes** to
`EuiDescriptionList`.

### Description list `columnWidths` prop

This PR introduces a new `columnWidths` prop and removes several Kibana
instances of custom CSS overrides to title/description column widths.

The primary motivation behind this is not just to reduce custom CSS, but
also because v88.0.0 introduced an underlying CSS change of `column`
description lists to using [`display: grid`
CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout).
The new prop allows us to support existing description list custom
widths while not requiring Kibana developers to understand or write grid
CSS (except for 1 or two scenarios around `max-width`).

⚠️ **No user-facing UI around column widths should have regressed as a
result of these changes. If they have, please let us know in this PR.**

### Description list gutter size changes

The prop `gutterSize` has been renamed to `rowGutterSize` and the
default size is now `s` instead of `m`.

The change to `s` from `m` means there is an **expected** smaller gap
between list items (see below screenshots):

**Current `EuiDescriptionList` with default `rowGutterSize="s"`**
<img width="753" alt=""
src="https://github.com/elastic/kibana/assets/934879/c17aef28-ed3b-40c4-84c3-396e788b13bb">

**Prior `EuiDescriptionList` with default `gutterSize="m"`**
<img width="721" alt=""
src="https://github.com/elastic/kibana/assets/934879/84d5f5a2-8fa6-4f99-9dc0-73fd143aa1e1">

If Kibana teams prefer to keep the previous `m` gutter for their
instances of `EuiDescriptionList`, you have a couple of options:

1. Let EUI team know in the PR and we can set usage back to what it was
before
2. Set `rowGutterSize="m"` yourselves manually

---

## [`88.1.0`](https://github.com/elastic/eui/tree/v88.1.0)

- Added `font.defaultUnits` theme token. EUI component font sizes
default to `rem` units - this token allows consumers to configure this
to `px` or `em` ([elastic#7133](elastic/eui#7133))
- Updated `EuiDescriptionList` with new `columnWidths` prop
([elastic#7146](elastic/eui#7146))

**Bug fixes**

- Fixed `EuiDataGrid`'s keyboard shortcuts popover display
([elastic#7146](elastic/eui#7146))

**CSS-in-JS conversions**

- Renamed `useEuiFontSize()`'s `measurement` option to `unit` for
clarity ([elastic#7133](elastic/eui#7133))

## [`88.0.0`](https://github.com/elastic/eui/tree/v88.0.0)

- Updated `EuiDescriptionList` with a new `columnGutterSize` prop
([elastic#7062](elastic/eui#7062))

**Deprecations**

- Deprecated `EuiSuggest`. We recommend using `EuiSelectable` or
`EuiComboBox` instead
([elastic#7122](elastic/eui#7122))
- Deprecated `EuiControlBar`. We recommend using `EuiBottomBar` instead
([elastic#7122](elastic/eui#7122))
- Deprecated `EuiColorStops`. We recommend copying the component to your
application if necessary
([elastic#7122](elastic/eui#7122))
- Deprecated `EuiNotificationEvent`. We recommend copying the component
to your application if necessary
([elastic#7122](elastic/eui#7122))

**Breaking changes**

- Renamed `EuiDescriptionList`'s `gutterSize` prop to `rowGutterSize`
([elastic#7062](elastic/eui#7062))
- `EuiDescriptionList`'s `rowGutterSize` prop now defaults to a size of
`s` (was previously `m`)
([elastic#7062](elastic/eui#7062))

**Accessibility**

- Fixed the dark mode colors of inline `EuiDescriptionListTitle`s to
meet WCAG color contrast requirements
([elastic#7062](elastic/eui#7062))

**CSS-in-JS conversions**

- Converted `EuiKeyPadMenuItem` to Emotion; Removed `$euiKeyPadMenuSize`
and `$euiKeyPadMenuMarginSize`
([elastic#7118](elastic/eui#7118))

---------

Co-authored-by: Cee Chen <constance.chen@elastic.co>
Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Nikita Indik <nikita.indik@elastic.co>
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.

Support specifying _FontScaleOptions globally
4 participants