-
Notifications
You must be signed in to change notification settings - Fork 840
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 Sass typography mixins to JS #5854
Conversation
+ add optional arg for max-width property
…her than `mixin` - per feedback from Caroline, this util is mostly used internally and does not need to be publicly exported/documented
…bottom - to group a class utility and its mixin together visually
@@ -64,7 +64,7 @@ export const useEuiTitle = ( | |||
*/ | |||
export const euiTitleStyles = ({ euiTheme }: UseEuiTheme) => ({ | |||
euiTitle: css` | |||
${euiTextBreakWord} | |||
${euiTextBreakWord()} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up converting this into a function to match other mixin usages. From a JS perspective I think it makes 'mixin' usage a bit clearer
Preview documentation changes for this PR: https://eui.elastic.co/pr_5854/ |
…style page later This reverts commit 9fe7b65.
Preview documentation changes for this PR: https://eui.elastic.co/pr_5854/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing all these conversions and adding tests. Lots of comments, but mostly repetitive stuff around language and just a few comments about the mixins themselves.
export const euiNumberFormat = () => ` | ||
font-feature-settings: 'calt' 1, 'kern' 1, 'liga' 1, 'tnum' 1; | ||
`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is actually an opprtunity to merge global styles. We have euiTheme.font.featureSettings
which is set to 'calt' 1, 'kern' 1, 'liga' 1
. In sass, there wasn't a good way to merge these, but here we can make this a hook and append just the 'tnum' 1
portion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah fantastic, I totally missed that variable!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making the mixin use euiTheme
now requires euiTheme as an arg, so I ended up making a hook version of this and documenting the hook version instead. I'd be curious to hear your thoughts on whether documenting both hook and non hook mixins feels confusing.
description={ | ||
<p> | ||
Changes the element’s text alignment property to{' '} | ||
<EuiCode language="sass">text-align: left;</EuiCode> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized we need to be changing these all to logical properties. 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would still keep the name of the thing as left
and right
, but the output should be logical.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As in I should be changing this in Sass itself? Could we maybe wait until we convert our Sass-only text utils to CSS-in-JS globals before doing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry no, I didn't realize this PR didn't contain the JS version of the Sass utility. When we do convert the pure utility, we need to make sure output uses the logical properties. Then in this description, instead of explicitly saying what the output style is, we'd just say something like:
<EuiCode language="sass">text-align: left;</EuiCode> | |
be aligned to the left (starting) side of its container. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh gotcha! Makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made that documentation tweak while here since I figured it was easy enough - LMK if you'd rather revert/wait until we tackle Sass/Emotion globals b4d2c2d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An optional idea.
+ add hook version, since this util now references euiTheme
@cchaos by the way, any thoughts on whether this PR needs a changelog? I'm unsure as Sass mixins were previously undocumented. |
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
Preview documentation changes for this PR: https://eui.elastic.co/pr_5854/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@constancecchen , Yes it needs a changelog stating these new additions. It doesn't need to be under the conversion header. Just something like
Add
euiNumberFormat()
, ..., ... text utilities.
54e470d
to
e38cd3a
Compare
Preview documentation changes for this PR: https://eui.elastic.co/pr_5854/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me!
Summary
For QA, please see: https://eui.elastic.co/pr_5854/#/utilities/text
For code review, I recommend following along by commit.
What this PR does:
_typography.scss
to JSeuiTextShift
, this was moved tofunctions/typography.ts
and notmixins/_typography.ts
as it's mostly an internal-only utilWhat this PR does not do:
Checklist
Not sure if a changelog is needed here Sass mixins were not previously documented - thoughts?