-
Notifications
You must be signed in to change notification settings - Fork 4.6k
AnglePickerColor: migrate Emotion to style.module #73786
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
base: trunk
Are you sure you want to change the base?
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
066b192 to
f76881d
Compare
| <div | ||
| ref={ angleCircleRef } | ||
| onMouseDown={ startDrag } | ||
| className="components-angle-picker-control__angle-circle" |
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.
All the components-angle-picker-control-* class names are unused, so I removed them.
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.
We've been keeping all these for back compat, unfortunately 😅
For example:
gutenberg/packages/components/src/date-time/time/index.tsx
Lines 141 to 143 in b9e9788
| <DayInput | |
| key="day" | |
| className="components-datetime__time-field components-datetime__time-field-day" // Unused, for backwards compatibility. |
|
Size Change: +547 B (+0.02%) Total Size: 2.58 MB
ℹ️ View Unchanged
|
| const classes = clsx( 'components-angle-picker-control', className ); | ||
|
|
||
| const unitText = <UnitText>°</UnitText>; | ||
| const unitText = <Text className={ styles[ 'unit-text' ] }>°</Text>; |
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.
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.
This is interesting, my Storybook displays this correctly. The margin and color styles are potentially conflicting, but in my case the .unit-text one wins:
Both class names have the same specificity, so it all depends on insertion order. Either Emotion inserts its PolymorphicDiv-Text styles first, or the style.module.scss inserts its styles first. Both are dynamically added <style> elements.
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.
Is the something fixable? Don’t like the idea of relying on random order.
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 think we could remove the Text component and the custom CSS styles, and just use InputControlSuffixWrapper for the padding. It doesn't make sense that the degree symbol is blue, it's not interactive.
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.
Is the something fixable? Don’t like the idea of relying on random order.
When both styles used Emotion, like
const Text = styled.div`color: blue`;
const UnitText = styled(Text)`color: red`;
then Emotion guaranteed that the red color always wins. But now when the red style is not Emotion, we don't have that guarantee any more and have to implement it ourselves somehow. Let me see what we can do.
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 think we could remove the
Textcomponent and the custom CSS styles, and just useInputControlSuffixWrapperfor the padding
@mirka Would you mind pushing a commit that implements this? You probably know much better than me what exactly needs to be done.
We have at least one learning for further migration: if one styled component depends on another styled component, we should migrate the dependency first. That keeps the order of stylesheets.
style.module.css styles are inserted early, immediately when the using module is initialized. And Emotion styles are inserted lazily, at the moment when the component that uses them is mounted.
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.
Done in 4203b46 ✅
We have at least one learning for further migration
And also to remove this instruction 😄
- if the style element already has an additional class name, like
components-something, verify if that class name is really used in CSS styles. Remove it if it isn't.
0892056 to
4203b46
Compare
| : [ null, unitText ]; | ||
| const prefixOrSuffixProp = isRTL() | ||
| ? { prefix: <InputControlPrefixWrapper>°</InputControlPrefixWrapper> } | ||
| : { suffix: <InputControlSuffixWrapper>°</InputControlSuffixWrapper> }; |
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.
By the way, while we are here, is it really correct to use either prefix or suffix depending on RTL? I'd expect that "prefix" and "suffix" are semantic terms, something like CSS logical properties (*-start, *-end), and that the NumberControl would take care of displaying them in the right order.
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 reminding me, there should be a code comment here (169ecc3). I was actually confused too and looked up the history to make sure.
The prefix and suffix slots reposition themselves "semantically" by default, but we're intentionally overriding that behavior here.

Migrates the
AnglePickerColorcomponent from Emotion to astyle.module.scssstyle.I did the migration with the following Cursor prompt:
After reviewing the results, I had to add several additional clarifications: