-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Replace style
with emotion.css
#149246
Comments
Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security) |
style
with emotion.css
style
with emotion.css
Hi @Omolola-Akinleye @JordanSh - I would like to also help here. can you please share list of files which needs to replace |
style
with emotion.css
style
with emotion.css
My initial approach was too ambitious and wanted to do this change for the whole repo. That's why I started replacing all static inline styles in the
The problem is it requires approvals from many teams before merging, slowing down the overall progress. After looking at
|
## Summary Part of the resolution of this issue: - #149246 Removes the `style` prop in React components and elements to avoid using inline styles. Instead, it uses now the `emotion.css` prop to dynamically attach all styles to the native `class` attribute. ### Motivation Using inline styles at scale causes a performance penalty at rendering time. It's way more efficient to attach styles to a single or several classnames instead. ### How to review From [Emotion's official docs](https://emotion.sh/docs/css-prop#style-precedence): > [!NOTE] > Any component or element that accepts a `className` prop can also use the `css` prop. The styles supplied to the `css` prop are evaluated and the computed class name is applied to the `className` prop. Components that are safe to migrate from `style` to `css`: - React elements - React components exposed by EUI (they all support a `className` prop and the [Babel plugin](https://www.npmjs.com/package/@emotion/babel-preset-css-prop) is enabled throughout Kibana) Components where styling might break: - Custom component we wrote that currently don't accept a `className` prop. - Specific 3P components that pass in a `style` prop to our components i.e. `react-window` (it calculates the dynamic position of all virtualized elements and hides the ones outside the visible fold) - Specific 3P components that expect a `style` prop to be styled i.e. charts, etc. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks Main risk is breaking the UI by not applying or incorrectly applying the styling. This was explained in the "How to review" section above. The risk has **low severity** though. The mitigation plan will simply be reverting the commit asap not to affect production and test locally until it's fixed./
## Summary Part of the resolution of this issue: - elastic#149246 Removes the `style` prop in React components and elements to avoid using inline styles. Instead, it uses now the `emotion.css` prop to dynamically attach all styles to the native `class` attribute. ### Motivation Using inline styles at scale causes a performance penalty at rendering time. It's way more efficient to attach styles to a single or several classnames instead. ### How to review From [Emotion's official docs](https://emotion.sh/docs/css-prop#style-precedence): > [!NOTE] > Any component or element that accepts a `className` prop can also use the `css` prop. The styles supplied to the `css` prop are evaluated and the computed class name is applied to the `className` prop. Components that are safe to migrate from `style` to `css`: - React elements - React components exposed by EUI (they all support a `className` prop and the [Babel plugin](https://www.npmjs.com/package/@emotion/babel-preset-css-prop) is enabled throughout Kibana) Components where styling might break: - Custom component we wrote that currently don't accept a `className` prop. - Specific 3P components that pass in a `style` prop to our components i.e. `react-window` (it calculates the dynamic position of all virtualized elements and hides the ones outside the visible fold) - Specific 3P components that expect a `style` prop to be styled i.e. charts, etc. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks Main risk is breaking the UI by not applying or incorrectly applying the styling. This was explained in the "How to review" section above. The risk has **low severity** though. The mitigation plan will simply be reverting the commit asap not to affect production and test locally until it's fixed./ (cherry picked from commit 6aaecd0)
## Summary Part of the resolution of this issue: - #149246 Removes the `style` prop in React components and elements to avoid using inline styles. Instead, it uses now the `emotion.css` prop to dynamically attach all styles to the native `class` attribute. ### Motivation Using inline styles at scale causes a performance penalty at rendering time. It's way more efficient to attach styles to a single or several classnames instead. ### Screenshots <details><summary>Default Edge</summary> <img width="1028" alt="Screenshot 2024-12-02 at 16 27 47" src="https://github.com/user-attachments/assets/4c913a69-ee26-4cda-829c-2b26799ead81"> </details> <details><summary>Graph Popovers</summary> <img width="175" alt="Screenshot 2024-12-02 at 16 27 57" src="https://github.com/user-attachments/assets/55054b05-9cb4-4ca7-a19a-319277d7961d"> </details> <details><summary>Graph Stacked Edge Cases</summary> <img width="1319" alt="Screenshot 2024-12-02 at 16 28 03" src="https://github.com/user-attachments/assets/11ec7a03-e8cf-4090-9443-56288bf78a2c"> </details> ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks - Minor risk with low impact and severity: - Only risk is CSP graph nodes showing with a different background and border
## Summary Part of the resolution of this issue: - elastic#149246 Removes the `style` prop in React components and elements to avoid using inline styles. Instead, it uses now the `emotion.css` prop to dynamically attach all styles to the native `class` attribute. ### Motivation Using inline styles at scale causes a performance penalty at rendering time. It's way more efficient to attach styles to a single or several classnames instead. ### Screenshots <details><summary>Default Edge</summary> <img width="1028" alt="Screenshot 2024-12-02 at 16 27 47" src="https://github.com/user-attachments/assets/4c913a69-ee26-4cda-829c-2b26799ead81"> </details> <details><summary>Graph Popovers</summary> <img width="175" alt="Screenshot 2024-12-02 at 16 27 57" src="https://github.com/user-attachments/assets/55054b05-9cb4-4ca7-a19a-319277d7961d"> </details> <details><summary>Graph Stacked Edge Cases</summary> <img width="1319" alt="Screenshot 2024-12-02 at 16 28 03" src="https://github.com/user-attachments/assets/11ec7a03-e8cf-4090-9443-56288bf78a2c"> </details> ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks - Minor risk with low impact and severity: - Only risk is CSP graph nodes showing with a different background and border (cherry picked from commit a32d9c7)
The initiative was great! But splitting it really sounds like the way to go in this case |
## Summary Part of the resolution of this issue: - elastic#149246 Removes the `style` prop in React components and elements to avoid using inline styles. Instead, it uses now the `emotion.css` prop to dynamically attach all styles to the native `class` attribute. ### Motivation Using inline styles at scale causes a performance penalty at rendering time. It's way more efficient to attach styles to a single or several classnames instead. ### Screenshots <details><summary>Default Edge</summary> <img width="1028" alt="Screenshot 2024-12-02 at 16 27 47" src="https://github.com/user-attachments/assets/4c913a69-ee26-4cda-829c-2b26799ead81"> </details> <details><summary>Graph Popovers</summary> <img width="175" alt="Screenshot 2024-12-02 at 16 27 57" src="https://github.com/user-attachments/assets/55054b05-9cb4-4ca7-a19a-319277d7961d"> </details> <details><summary>Graph Stacked Edge Cases</summary> <img width="1319" alt="Screenshot 2024-12-02 at 16 28 03" src="https://github.com/user-attachments/assets/11ec7a03-e8cf-4090-9443-56288bf78a2c"> </details> ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks - Minor risk with low impact and severity: - Only risk is CSP graph nodes showing with a different background and border
## Summary Part of the resolution of this issue: - elastic#149246 Removes the `style` prop in React components and elements to avoid using inline styles. Instead, it uses now the `emotion.css` prop to dynamically attach all styles to the native `class` attribute. ### Motivation Using inline styles at scale causes a performance penalty at rendering time. It's way more efficient to attach styles to a single or several classnames instead. ### How to review From [Emotion's official docs](https://emotion.sh/docs/css-prop#style-precedence): > [!NOTE] > Any component or element that accepts a `className` prop can also use the `css` prop. The styles supplied to the `css` prop are evaluated and the computed class name is applied to the `className` prop. Components that are safe to migrate from `style` to `css`: - React elements - React components exposed by EUI (they all support a `className` prop and the [Babel plugin](https://www.npmjs.com/package/@emotion/babel-preset-css-prop) is enabled throughout Kibana) Components where styling might break: - Custom component we wrote that currently don't accept a `className` prop. - Specific 3P components that pass in a `style` prop to our components i.e. `react-window` (it calculates the dynamic position of all virtualized elements and hides the ones outside the visible fold) - Specific 3P components that expect a `style` prop to be styled i.e. charts, etc. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks Main risk is breaking the UI by not applying or incorrectly applying the styling. This was explained in the "How to review" section above. The risk has **low severity** though. The mitigation plan will simply be reverting the commit asap not to affect production and test locally until it's fixed./
## Summary Part of the resolution of this issue: - elastic#149246 Removes the `style` prop in React components and elements to avoid using inline styles. Instead, it uses now the `emotion.css` prop to dynamically attach all styles to the native `class` attribute. ### Motivation Using inline styles at scale causes a performance penalty at rendering time. It's way more efficient to attach styles to a single or several classnames instead. ### Screenshots <details><summary>Default Edge</summary> <img width="1028" alt="Screenshot 2024-12-02 at 16 27 47" src="https://github.com/user-attachments/assets/4c913a69-ee26-4cda-829c-2b26799ead81"> </details> <details><summary>Graph Popovers</summary> <img width="175" alt="Screenshot 2024-12-02 at 16 27 57" src="https://github.com/user-attachments/assets/55054b05-9cb4-4ca7-a19a-319277d7961d"> </details> <details><summary>Graph Stacked Edge Cases</summary> <img width="1319" alt="Screenshot 2024-12-02 at 16 28 03" src="https://github.com/user-attachments/assets/11ec7a03-e8cf-4090-9443-56288bf78a2c"> </details> ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks - Minor risk with low impact and severity: - Only risk is CSP graph nodes showing with a different background and border
## Summary Part of the resolution of this issue: - #149246 Removes the `style` prop in React components and elements to avoid using inline styles. Instead, it uses now the `emotion.css` prop to dynamically attach all styles to the native `class` attribute. ### Motivation Using inline styles at scale causes a performance penalty at rendering time. It's way more efficient to attach styles to a single or several classnames instead. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) Co-authored-by: Elastic Machine <[email protected]>
## Summary Part of the resolution of this issue: - elastic#149246 Removes the `style` prop in React components and elements to avoid using inline styles. Instead, it uses now the `emotion.css` prop to dynamically attach all styles to the native `class` attribute. ### Motivation Using inline styles at scale causes a performance penalty at rendering time. It's way more efficient to attach styles to a single or several classnames instead. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) Co-authored-by: Elastic Machine <[email protected]> (cherry picked from commit c1addc9)
## Summary Part of the resolution of this issue: - elastic#149246 Removes the `style` prop in React components and elements to avoid using inline styles. Instead, it uses now the `emotion.css` prop to dynamically attach all styles to the native `class` attribute. ### Motivation Using inline styles at scale causes a performance penalty at rendering time. It's way more efficient to attach styles to a single or several classnames instead. ### How to review From [Emotion's official docs](https://emotion.sh/docs/css-prop#style-precedence): > [!NOTE] > Any component or element that accepts a `className` prop can also use the `css` prop. The styles supplied to the `css` prop are evaluated and the computed class name is applied to the `className` prop. Components that are safe to migrate from `style` to `css`: - React elements - React components exposed by EUI (they all support a `className` prop and the [Babel plugin](https://www.npmjs.com/package/@emotion/babel-preset-css-prop) is enabled throughout Kibana) Components where styling might break: - Custom component we wrote that currently don't accept a `className` prop. - Specific 3P components that pass in a `style` prop to our components i.e. `react-window` (it calculates the dynamic position of all virtualized elements and hides the ones outside the visible fold) - Specific 3P components that expect a `style` prop to be styled i.e. charts, etc. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks Main risk is breaking the UI by not applying or incorrectly applying the styling. This was explained in the "How to review" section above. The risk has **low severity** though. The mitigation plan will simply be reverting the commit asap not to affect production and test locally until it's fixed./
## Summary Part of the resolution of this issue: - elastic#149246 Removes the `style` prop in React components and elements to avoid using inline styles. Instead, it uses now the `emotion.css` prop to dynamically attach all styles to the native `class` attribute. ### Motivation Using inline styles at scale causes a performance penalty at rendering time. It's way more efficient to attach styles to a single or several classnames instead. ### Screenshots <details><summary>Default Edge</summary> <img width="1028" alt="Screenshot 2024-12-02 at 16 27 47" src="https://github.com/user-attachments/assets/4c913a69-ee26-4cda-829c-2b26799ead81"> </details> <details><summary>Graph Popovers</summary> <img width="175" alt="Screenshot 2024-12-02 at 16 27 57" src="https://github.com/user-attachments/assets/55054b05-9cb4-4ca7-a19a-319277d7961d"> </details> <details><summary>Graph Stacked Edge Cases</summary> <img width="1319" alt="Screenshot 2024-12-02 at 16 28 03" src="https://github.com/user-attachments/assets/11ec7a03-e8cf-4090-9443-56288bf78a2c"> </details> ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks - Minor risk with low impact and severity: - Only risk is CSP graph nodes showing with a different background and border
## Summary Part of the resolution of this issue: - elastic#149246 Removes the `style` prop in React components and elements to avoid using inline styles. Instead, it uses now the `emotion.css` prop to dynamically attach all styles to the native `class` attribute. ### Motivation Using inline styles at scale causes a performance penalty at rendering time. It's way more efficient to attach styles to a single or several classnames instead. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) Co-authored-by: Elastic Machine <[email protected]>
Many of our components use the React
style
native property to add styles.We would like to replace as many of those as we can with @emotion/react
Attaching GH Thread to reference the motivations for the proposed changes
The text was updated successfully, but these errors were encountered: