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 EuiText, EuiTextAlign, and EuiTextColor #5895

Merged
merged 57 commits into from
May 26, 2022

Conversation

cee-chen
Copy link
Member

@cee-chen cee-chen commented May 11, 2022

Summary

Woof, this ended up being much larger than I thought it would be 💦 I strongly recommend following along by commit, in the following order:

  • EuiText conversion: (involves adding a new customScale property to our typography utils and creating an optional obj of properties instead of passing 4+ args)
  • Partial EuiMarkdownFormat conversion (the portions of the mixin that really belong to EuiMarkdownFormat and not EuiText):
  • EuiTextAlign conversion: (also contains updates to the logicals utilities, LMK if we are OK with this, if not I can revert and just use border-inline-start-width directly)
  • EuiTextColor conversion: (I'm unsure whether this conversion requires using our makeHighContrastColor function or if that's already baked in)

Checklist

  • Anything in the backlog that could be a quick fix for that component? (specific requests made by @cchaos)
  • Convert component-specific Sass vars to exported JS versions
  • Convert side specific padding, margin, and position to -inline and -block (Logical properties)
  • Reduce specificity where possible (usually by reducing class name chaining)

- [ ] Convert global Sass vars to JS version like sizing
- [ ] Use gap property to add margin between items if using flex
- [ ] Can any still existing .js files be converted to TS?
- [ ] All animations or transitions are wrapped in euiCanAnimate

QA

  • Does the output CSS match the previous CSS / as expected (I checked each and every single CSS output and confirmed that they were the same as before, aside from line height changes that already existed in our new typography utils)
  • Does the rendered class read as expected

@cee-chen cee-chen requested a review from cchaos May 11, 2022 19:06
src/components/text/text.tsx Show resolved Hide resolved
Comment on lines 34 to 41
const classes = classNames(
'euiTextAlign',
alignmentToClassNameMap[textAlign],
className
);
const styles = euiTextAlignStyles();
const cssStyles = [styles.euiTextAlign, styles[textAlign]];

return (
<div className={classes} {...rest}>
Copy link
Member Author

Choose a reason for hiding this comment

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

Similarly, I felt safe completely removing the CSS classNames for this component due to low Kibana usage, that can all be quickly and easily replaced with our CSS text utilities in any case:

src/components/text/text_color.tsx Show resolved Hide resolved
src/global_styling/functions/logicals.ts Show resolved Hide resolved
src/components/text/text_color.styles.ts Outdated Show resolved Hide resolved
src/components/link/link.styles.ts Show resolved Hide resolved
@kibanamachine
Copy link

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

@cee-chen cee-chen changed the title [Emotion] Convert[EuiText, EuiTextAlign, and EuiTextColor [Emotion] Convert EuiText, EuiTextAlign, and EuiTextColor May 11, 2022
@cchaos cchaos added this to the Elastic Stack 8.4 milestone May 16, 2022
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.

Some early feedback after a quick scan of the code except for the styles.

src-docs/src/views/theme/typography/_typography_js.tsx Outdated Show resolved Hide resolved
src/global_styling/functions/logicals.ts Show resolved Hide resolved
src/components/text/text_color.styles.ts Outdated Show resolved Hide resolved
src/components/markdown_editor/markdown_format.styles.ts Outdated Show resolved Hide resolved
src/components/text/text.tsx Outdated Show resolved Hide resolved
src/global_styling/functions/typography.ts Show resolved Hide resolved
src/global_styling/functions/typography.ts Outdated Show resolved Hide resolved
src/components/empty_prompt/_empty_prompt.scss Outdated Show resolved Hide resolved
@kibanamachine
Copy link

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

TODO: EuiCode variables were not converted, per direction from Caroline
+ convert optional params to an options object

+ clean up euiFontSize and euiTitle fns - remove `scale` fallback since the utils don't really make sense without that param, and remove rem fallbacks in place of just single options fallback
- since there isn't a .9 scale size, we should just use `em` to make it relative

- since `.euiCode` also uses `.9em`, we can now remove the `:not()` selector
- attempting to account for `em` margins

+ add :not(:last-child) selector per Caroline's request
…file

- might as well do it while I'm here and thinking about it

+ expanded our logicals helper to include all logical `border` properties, since the converted CSS uses this
+ switch to logical properties
- text alignment already has its own CSS utils that users can call directly (that we can also convert any Kibanau sage into), so I feel very safe making this change, and I'd rather people not continue to hook into these classNames
- since they're no longer setting CSS - we should convert Kibana usages to the component
@cchaos
Copy link
Contributor

cchaos commented May 24, 2022

I'll do a final check, but I think it's important to also get an eng review.

@kibanamachine
Copy link

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

1 similar comment
@kibanamachine
Copy link

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

@cee-chen
Copy link
Member Author

but I think it's important to also get an eng review.

I don't especially want to throw a brand new engineer into a super large PR (2k~ lines and 70+ files) that's had a bunch of disparate changes and back and forth (i.e., no easy git commit history to follow). I strongly think this is a waste of their time and ours.

Can we limit the code review we're requesting to a specific set of files you feel concerned about in terms of code quality? For example, would you want them to examine only the text.tsx/text_color.tsx/text_align.tsx files and maybe the euiFontSize mixin/font changes and all corresponding tests?

@cchaos
Copy link
Contributor

cchaos commented May 25, 2022

Yes exactly, I mean to look at the trickier bits of code like you mentioned, the tests, clones, and mixins.

@cee-chen
Copy link
Member Author

Thanks for clarifying Caroline! @thompsongl, would you mind doing engineering review on only the following components/files:

@cee-chen cee-chen requested a review from thompsongl May 25, 2022 17:04
@cee-chen
Copy link
Member Author

jenkins test this

@kibanamachine
Copy link

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

Copy link
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

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

Code changes look good 👍

@cee-chen cee-chen requested a review from cchaos May 25, 2022 19:28
@kibanamachine
Copy link

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

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.

LGTM! Wasn't that fun!?

upcoming_changelogs/5895.md Show resolved Hide resolved
@cchaos
Copy link
Contributor

cchaos commented May 26, 2022

Jenkins, test this

@kibanamachine
Copy link

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

Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
@kibanamachine
Copy link

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

@cee-chen cee-chen mentioned this pull request May 26, 2022
@cee-chen cee-chen enabled auto-merge (squash) May 26, 2022 19:51
@kibanamachine
Copy link

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

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.

5 participants