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

Migrate styles from styled-components to emotion #105071

Open
thompsongl opened this issue Jul 9, 2021 · 8 comments
Open

Migrate styles from styled-components to emotion #105071

thompsongl opened this issue Jul 9, 2021 · 8 comments
Labels
old Used to help sort old issues on GH Projects which don't support the Created search term. Team:Platform-Design Team Label for Kibana Design Team. Support the Analyze group of plugins. Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience)

Comments

@thompsongl
Copy link
Contributor

thompsongl commented Jul 9, 2021

#98157 solves the immediate need of enabling @emotion/react in Kibana for the purposes of EUI and (more immediately) Canvas. We will want to convert components currently using styled-component to the emotion ecosystem, but there is further discussion to be had on the correct approach. For instance, a 1:1 conversion is possible from styled-components to @emotion/styled; at present this lib is not required for EUI or Canvas but could be added later to support conversions and simplify the babel configuration.
EUI intends to use the css prop API, not the styled API, and the team will have supporting documentation for such when EUI component conversion begin.

The list of plugins that currently use styled-components is currently maintained here:

/**
* Synchronized regex list of files that use `styled-components`.
* Used by `kbn-babel-preset` and `elastic-eslint-config-kibana`.
*/
export const USES_STYLED_COMPONENTS = [
/packages[\/\\]kbn-ui-shared-deps[\/\\]/,
/src[\/\\]plugins[\/\\](data|kibana_react)[\/\\]/,
/x-pack[\/\\]plugins[\/\\](apm|beats_management|cases|fleet|infra|lists|observability|osquery|security_solution|timelines|uptime)[\/\\]/,
/x-pack[\/\\]test[\/\\]plugin_functional[\/\\]plugins[\/\\]resolver_test[\/\\]/,
];

@botelastic botelastic bot added the needs-team Issues missing a team label label Jul 9, 2021
@thompsongl
Copy link
Contributor Author

@smith likely has insight on the current state of styled-component use
@cqliu1 and @clintandrewhall are currently exploring emotion in Canvas

@smith
Copy link
Contributor

smith commented Jul 12, 2021

It looks like there's about a 50/50 split between using the typed euiStyled from kibanaReact and just using import styled from 'styled-components'.

If we could get more usage of euiStyled it might make it easier to make a change all in one place.

@vadimkibana vadimkibana added Team:Platform-Design Team Label for Kibana Design Team. Support the Analyze group of plugins. and removed needs-team Issues missing a team label labels Sep 3, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-design (Team:Kibana-Design)

@tsullivan
Copy link
Member

@elastic/kibana-design I think this issue isn't getting enough attention.

  • Based on the git log packages/kbn-babel-preset/styled_components_files.js, teams have not been chopping away at this migration. That file is not steadily shrinking, it is slightly growing over time.
  • Typically, an issue like this would have a task list that calls out the areas that need to be fixed, and ping the team that owns the component for each call-out.

Also:

For instance, a 1:1 conversion is possible from styled-components to @emotion/styled

I'm confused by this. After looking at the FAQ (here), I learned that a module which is tooled to support styled-components can only be converted to use @emotion/css, but the preferred way to tool our components is to use @emotion/react, but that requires a change in the plugin's babel settings. So I don't know what that phrase I quoted is supposed to mean.

@MichaelMarcialis
Copy link
Contributor

CCing @elastic/eui-team.

@cee-chen
Copy link
Member

cee-chen commented Aug 13, 2024

For instance, a 1:1 conversion is possible from styled-components to @emotion/styled

I'm confused by this. After looking at the FAQ (here), I learned that a module which is tooled to support styled-components can only be converted to use @emotion/css, but the preferred way to tool our components is to use @emotion/react, but that requires a change in the plugin's babel settings. So I don't know what that phrase I quoted is supposed to mean.

For migrations over timing (e.g. only migrating 1 instance of styled-components to Emotion), a 1:1 conversion is likely not possible due to the babel plugin setup you mentioned. A 1:1 conversion could theoretically be more possible if the listed plugin were willing to migrate all styled component usages at once to @emotion/styled. Which would be by necessity a larger effort/single PR (depending on number of usages), but shouldn't be overwhelmingly impossible.

@JasonStoltz
Copy link
Member

@tsullivan I think we really just need someone to own this effort and commit some time to coordinating it. As you mention, we'll need a clearer call to action that makes the ask more explicit and establishes some expectations.

@petrklapka petrklapka added the Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) label Aug 14, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/appex-sharedux (Team:SharedUX)

@petrklapka petrklapka added the old Used to help sort old issues on GH Projects which don't support the Created search term. label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
old Used to help sort old issues on GH Projects which don't support the Created search term. Team:Platform-Design Team Label for Kibana Design Team. Support the Analyze group of plugins. Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience)
Projects
None yet
Development

No branches or pull requests

9 participants