-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fully integrating vanilla Emotion as the canonical style system for CSS-in-JS in Gutenberg #30503
Comments
Thank you @sarayourfriend for actively seeking better ways to integrate the new Component System. I think it makes perfect sense to try a bit different approach based on all the experience you collected when working on integration so far. In fact, it's closer to what I imagined in the early phase of planning. I hoped we can switch a few lower-level components to their revised implementation and bring all the necessary machinery to make them work with all the new features the that Component System brings. At that stage (#27484 (comment)), I wasn't aware of the limitation you listed but it only shows that the sooner you start integrating components the more you learn about the potential issues that should be addressed with higher priority. I agree that #30509 is the most important blocker to resolve before we can start using some of the components that are already added to the |
Question, as the new system is getting integrated, does it make sense to rename |
@jasmussen Yes I think ultimately that should be the goal. For now the new style system, as it is integrated, has the gutenberg/packages/components/src/ui/create-styles/create-style-system/constants.js Line 4 in b53c5e5
|
I appreciate you clarifying that to me, thank you! |
Note! I've updated the issue to reflect the current plan. Please review when y'all have time @mtias @gziolo @youknowriad. Thanks! |
Thank you for the update. It looks like everything is on track. 👍🏻 |
Migrating a G2 component into Gutenberg.Helpful example PRs:
The rough outline of the process is as follows
Usages of the |
Regarding base styles, I've added a new comment copied here for ease:
What do y'all think? The goal is that we want reduced motion to be respected automagically, but maybe there's no way to do that and we just need to use the Overall just a little stuck thinking about this and curious what other people think. |
I may lack some perspective of the high-level strategy for the components package, but it makes sense to me that, whatever solution we may go for, we would be able to affect all components. Having implementation discrepancies in between components would make it quite hard to maintain and implement features effectively.
Hopefully not a silly question, but — Can't we make changes so that all components are based on
Wouldn't be able to wrap some CSS into a |
Not a silly question. All of the new components ultimately render a Previously, when we were using our own wrapper around Emotion, we were able to make all
As far as I understand it, the |
Closing this out as it appears much of this work has been completed or is no longer relevant today (it's been three years since last updated). Happy to reopen if that's incorrect! |
Note: This issue has been updated significantly, please view the revision history for insight into what's changed!
This is the next step in fully ingrating Emotion as the canonical style system for Gutenberg.
Recently we made the decision to ditch the new custom style system for the following reasons:
Because @youknowriad was able to figure out how to integrate the
StyleFrame
component using the methods from upstream Emotion for iframe support (thanks Riad!) we're able to fully commit to vanilla Emotion for the Gutenberg style system. This means we do not need a custom wrapper around it.What are we losing by doing this?
Basically "base styles" which were styles that were being applied to each and every element produced by the style system. Practically this meant the ability to force all components to respect reduced motion automagically. I think we can figure out a solution around this using
injectGlobal
and adding it to theStyleProvider
, but it's not a blocker, just something to call out.Okay, so what are the next steps?
create-styles
Removecreate-styles
in favor of vanilla emotion. #31048context
to use vanilla emotion Components: Add component systemcontext
#30877ui
components to vanilla emotionView
which has a cascading effect of needing to handle all components created withcreateComponent
and their dependencies, especially variable dependencies. Because we won't be importing from@wp-g2/styles
anymore, the variables won't exist and we need to port them over to theCOLORS
andCONFIG
constants from the existing style system inpackages/components/src/utils
. components: Use vanilla emotion forview
#31099BaseField
#32250View
and ensure all components use the View component for their base renderingView
components: Fix Shortcut polymorphism #31555View
View
isn't the basis of thestyled
components so this will only cover a small set of components that would actually get the base styles. Should we just useinjectGlobal
to apply the base styles to*
with an!important
on the reduced motion ones?isReversed
prop #31297css
fromemotion
doesn't use the correct emotion cache.Upgrade to Emotion 11 #31476Upgrade to Emotion 11 #32216preactjs/compressed-size-check
Local dir is not clean up properly before switching to target branch preactjs/compressed-size-action#59components/src/ui
intocomponents/src
and export them as experimental or unstableSeparator components: Add Separator #31612Separator is just a Divider with some default props, in that case... just use Divider.withNext
wrappers #32205Card
component with the new version fromui
Components: update<Card />
implementation to g2 version #32243Surface
Components: promoteSurface
#32439Scrollable
Components: promoteScrollable
#32446Popover
asFlyout
#32197Miscellaneous tasks
color
andconfig
utility functions and just use theCOLORS
andCONFIG
objects directlycolor
Components: removecolor()
utility function, use values directly #31661config
Components: removeconfig()
utility function, use values directly #31646children
prop fromViewOwnProps
and addchildren
to all components that need it explicitly rather than relying on the implicit definition. Components: require explicitchildren
prop for all components #31817components/src/utils/space
function and just useui/utils/space
. components: Remove duplicated space utilities #32852ViewOwnProps
to a clearer name likePolymorphicComponentProps
Components: RenameViewOwnProps
toPolymorphicComponentProps
#32053context/polymorphic-component.ts
Component uplifting tasks
isPrimary
,isSecondary
etc. props onButton
in favor of a singlevariant
prop. Button: deprecateisPrimary
,isSecondary
,isTertiary
andisLink
props in favour ofvariant
prop #31713isPrimary
,isSecondary
,isTertiary
andisLink
props in favour ofvariant
prop #31713 (plus theisPrimary
key used in the notice component)Button
parts ofButton
into aBaseButton
orPrimitiveButton
component that does not include theTooltip
stuff.CSS-in-JS tasks
A list of high priority components to be refactored is tracked in #35744
Context connecting tasks
A list of high priority components to be refactored is tracked in #35744
ui/context
Documentation tasks
@wordpress/components
README.md to describe the structure of the package including the differences between primitive components (like Text) and composed components (like ColorPicker)@wordpress/components
structure #33111Deprecating `@emotion/css`
@emotion/css
as a restricted import components: Restrict imports of @emotion/css #33051@emotion/css
from the codebase and replace with@emotion/styled
and@emotion/react
@emotion/css
from ZStack #33053@emotion/css
from Divider #33054@emotion/css
from Spacer #33055The text was updated successfully, but these errors were encountered: