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] Convert EuiTitle #5842

Merged
merged 16 commits into from
Apr 27, 2022
Merged

[Emotion] Convert EuiTitle #5842

merged 16 commits into from
Apr 27, 2022

Conversation

cee-chen
Copy link
Member

@cee-chen cee-chen commented Apr 25, 2022

Summary

I strongly recommend following along by commit.

What this PR does:

  • Converts EuiTitle fully over to CSS-in-JS
  • Removes extra CSS modifier classes (5404cb8)
    • I grepped through Kibana and this will only affect in snapshot changes and 1 source code usage that should be converted to <EuiTitle /> in any case
  • Adds an euiTextBreakWord CSS 'mixin' that matches what EuiBeacon did with euiCanAnimate
  • Creates a CSS-in-JS version of the euiTitle() Sass mixin, that now lives in the component directory and not in global_styling
    • This is a deliberate breaking change away from our previous Sass theme variables that allowed styling titles per-sizes
    • Per @thompsongl: Moving more styling into the component makes it easier for a component to react to theme differences, rather than needing the theme to account for each component

What this PR does not do:

  • Look through internal usage of the euiTitle() Sass mixin and potentially convert them <EuiTitle /> (TBD, hopefully my next PR)
  • Delete the euiTitle() Sass mixin or $euiTitles Sass variable/JSON mappings
  • Update documentation around the Sass mixin or variable

Checklist

  • Does the output CSS match the previous CSS / as expected
  • Does the rendered class read as expected

src/components/title/title.styles.ts Outdated Show resolved Hide resolved
src/components/title/title.styles.ts Outdated Show resolved Hide resolved
src/components/title/title.styles.ts Outdated Show resolved Hide resolved
upcoming_changelogs/5842.md Show resolved Hide resolved
@kibanamachine
Copy link

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

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.

Update documentation around the Sass mixin or variable

I highly suggest adding documentation around the new JS version of euiTextBreakWord. You can just follow the same pattern as we did for Scroll and create a new Utility page for Text and move the CSS utilities there too. If you really want to do that in a follow up, that's fine as long as we're tracking those somewhere. But I'm hoping not to fall into the trap where we had so many undocumented but helpful Sass helpers/mixins.

src/global_styling/variables/typography.ts Outdated Show resolved Hide resolved
src/components/title/title.styles.ts Outdated Show resolved Hide resolved
src/components/title/title.styles.ts Outdated Show resolved Hide resolved
src/components/title/title.styles.ts Outdated Show resolved Hide resolved
src/components/title/title.styles.ts Outdated Show resolved Hide resolved
src/components/title/title.styles.ts Outdated Show resolved Hide resolved
src/components/title/title.styles.ts Outdated Show resolved Hide resolved
src/components/title/title.styles.ts Outdated Show resolved Hide resolved
@cee-chen
Copy link
Member Author

I think that should be all your comments addressed @cchaos (excepting euiTextBreakWord, if you're fine with that being a follow-up PR). Let me know what you think!

@kibanamachine
Copy link

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

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.

Just a couple code nits while I spot check some of these downstream components

upcoming_changelogs/5842.md Outdated Show resolved Hide resolved

export interface _EuiThemeTitle {
/**
* A font weight key for setting the base title weight
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* A font weight key for setting the base title weight
* A font weight key for setting the base weight for titles and headings

Copy link
Contributor

Choose a reason for hiding this comment

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

We'll also need to add this to the Customizing section of the theme docs at some point. No rush now since we don't have anything setup yet for selecting from a list.

Also, do you think we should actually move the colors.title into this new theme key specifically? So we'd get:

euiTheme.title.weight and euiTheme.title.color

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 good with that! I'll make that change here in a little bit

Copy link
Member Author

@cee-chen cee-chen Apr 27, 2022

Choose a reason for hiding this comment

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

Oh actually, spoke too soon. Looks like we can't easily do that because colors has its own custom computed logic plus light vs dark mode settings. We should probably just leave it where it is 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

No problem, we can check it out in a later PR.

src/components/title/title.styles.ts Show resolved Hide resolved
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
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 checked through the updated snapshot components for any regressions, didn't find anything too big. I think just one small thing we can do here, the rest will follow up on.

@cee-chen
Copy link
Member Author

jenkins test this

1 similar comment
@leathekd
Copy link

jenkins test this

@kibanamachine
Copy link

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

@cee-chen cee-chen merged commit a66b23c into elastic:main Apr 27, 2022
@cee-chen cee-chen deleted the emotion/eui-title branch April 27, 2022 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants