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

Replace style with css in CSP plugin #202487

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

Conversation

albertoblaz
Copy link
Contributor

Summary

Part of the resolution of this issue:

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.

  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines

@albertoblaz albertoblaz added release_note:skip Skip the PR/issue when compiling release notes Team:Cloud Security Cloud Security team related backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) backport:version Backport to applied version labels v8.18.0 labels Dec 2, 2024
@albertoblaz albertoblaz self-assigned this Dec 2, 2024
@albertoblaz albertoblaz requested a review from a team as a code owner December 2, 2024 14:34
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security)

@albertoblaz albertoblaz force-pushed the replace-style-cloud-security-posture branch from bc09a92 to d50e01f Compare December 3, 2024 16:22
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
cloudSecurityPosture 502.7KB 503.8KB +1.0KB

Page load bundle

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

id before after diff
cloudSecurityPosture 17.9KB 17.9KB +25.0B

History

cc @albertoblaz

Copy link
Contributor

@seanrathier seanrathier left a comment

Choose a reason for hiding this comment

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

Left a few comments.

@@ -24,6 +25,7 @@ interface ChartPanelProps {
isError?: boolean;
rightSideItems?: ReactNode[];
styles?: React.CSSProperties;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we still need the styles if we are using css?

@@ -24,6 +25,7 @@ interface ChartPanelProps {
isError?: boolean;
rightSideItems?: ReactNode[];
styles?: React.CSSProperties;
css?: Interpolation<Theme>;
Copy link
Contributor

Choose a reason for hiding this comment

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

I saw how we are using this prop here, can we use a size prop instead if there are other components using this with different sizes?

Suggested change
css?: Interpolation<Theme>;
size?: 'small' | 'medium' | `large`;

@@ -104,7 +104,7 @@ const TotalIntegrationsCount = ({
pageCount,
totalCount,
}: Record<'pageCount' | 'totalCount', number>) => (
<EuiText size="xs" style={{ marginLeft: 8 }}>
<EuiText size="xs" css={{ marginLeft: 8 }}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use an euiTheme.size here?

@@ -87,12 +87,14 @@ const CounterButtonLink = ({
<EuiText
color={color}
css={css`
font-weight: ${euiTheme.font.weight.medium};
font-size: 18px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use an euiTheme.size here? ( or the typography equivalent)

@@ -72,7 +72,7 @@ const AccountDropDown = ({
options: Array<{ value: string; label: string }>;
}) => (
<EuiComboBox
style={{ width: 320 }}
css={{ width: 320 }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this responsive?

If it's not we should raise this in a follow-up issue to use breakpoints if we can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes Team:Cloud Security Cloud Security team related v8.18.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants