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

[SharedUX] Remove SCSS from kibana_react #204497

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

tsullivan
Copy link
Member

@tsullivan tsullivan commented Dec 16, 2024

Summary

Part of https://github.com/elastic/kibana-team/issues/1082

Removes all Sass files in src/plugins/kibana_react to replace with styles declared with Emotion. This PR does not include any changes that would be noticeable by end-users. It changes the internals to use a different technology for styling components.

References

  1. https://emotion.sh/docs/globals
  2. https://emotion.sh/docs/best-practices
  3. [FAQ] Kibana and Emotion / CSS-in-JS usage eui#6828 (comment)

@tsullivan tsullivan force-pushed the remove-sass/kibana-react branch 2 times, most recently from b052f17 to d4c9f09 Compare December 17, 2024 17:05
@tsullivan tsullivan force-pushed the remove-sass/kibana-react branch from cbe14e7 to a6c5da4 Compare December 17, 2024 20:09
@@ -7,9 +7,5 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

export type { KibanaPageTemplateSolutionNavProps } from './solution_nav';
export { KibanaPageTemplateSolutionNav } from './solution_nav';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KibanaPageTemplateSolutionNav is unused in Kibana!

export type { KibanaPageTemplateSolutionNavAvatarProps } from './solution_nav_avatar';
export { KibanaPageTemplateSolutionNavAvatar } from './solution_nav_avatar';
export type { KibanaPageTemplateSolutionNavCollapseButtonProps } from './solution_nav_collapse_button';
export { KibanaPageTemplateSolutionNavCollapseButton } from './solution_nav_collapse_button';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KibanaPageTemplateSolutionNavCollapseButton is unused in Kibana!

<div className={'urlTemplateEditor__container'} onKeyDown={handleKeyDown}>
<div
data-test-subj="url-template-editor-container"
className={editorStyle}
Copy link
Member Author

@tsullivan tsullivan Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure why we're not able to leverage @emotion/react and set the css property on the div.

Copy link
Contributor

@Heenawter Heenawter Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you be using import { css } from '@emotion/react' instead of import { css } from '@emotion/css' (see elastic/eui#6828 (comment))? When I tried that, it works 🤔

{
[`kbnPageTemplateSolutionNavAvatar--${size}`]: size,
[pageTemplateSolutionNavAvatarStyles.xxl]: size === 'xxl',
Copy link
Member Author

@tsullivan tsullivan Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure why we're not able to leverage @emotion/react and set the css property on the EuiAvatar.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering the same. Is there a reason?
It should just be something like:

css={[pageTemplateSolutionNavAvatarStyles.base, size === 'xxl' && pageTemplateSolutionNavAvatarStyles.xxl]}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried a few variations, including removing the className prop altogether, but unfortunately I haven't found the magical incantation needed. I wonder if it's a Babel configuration thing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The css prop needs to be supported via babel preset, yes. I thought this is done for Kibana globally, but maybe not? 🤔

base: css`
${css(useEuiShadow('s'))};
`,
xxl: css`
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elastic/cloud-security-posture can you review and test this? The xxl style is only used in src/plugins/kibana_react/public/page_template/no_data_page/no_data_page_body/no_data_page_body.tsx and that is only used in:

  • x-pack/solutions/security/plugins/cloud_security_posture
  • x-pack/solutions/security/plugins/cloud_defend

@tsullivan tsullivan marked this pull request as ready for review December 17, 2024 20:32
@tsullivan tsullivan requested review from a team as code owners December 17, 2024 20:32
@tsullivan tsullivan added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting v9.0.0 labels Dec 17, 2024
@tsullivan tsullivan requested a review from a team December 17, 2024 20:44
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
kibanaReact 212 201 -11

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
kibanaReact 197.2KB 197.1KB -4.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
kibanaReact 39.8KB 38.5KB -1.3KB
Unknown metric groups

miscellaneous assets size

id before after diff
kibanaReact 68.4KB 0.0B -68.4KB

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants