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

chore(slo): remove deprecated theme provider and usage of styled-components #200248

Merged
merged 7 commits into from
Nov 20, 2024

Conversation

kdelemme
Copy link
Contributor

@kdelemme kdelemme commented Nov 14, 2024

Resolves #200247

🖌️ Summary

This PR removes all usage of styled-components from the SLO plugin, replacing them with @emotions/react. It also removes the deprecated Eui ThemeProvider.

🍵 Testing

  • Check all pages for UI glitches
  • Check all embeddables for UI glitches
Screenshots Screenshots
screencapture-localhost-5601-kibana-app-dashboards-2024-11-14-14_34_29 screencapture-localhost-5601-kibana-app-slos-2024-11-14-14_33_35
screencapture-localhost-5601-kibana-app-slos-2024-11-14-14_34_47 screencapture-localhost-5601-kibana-app-slos-afd56a7c-f21f-42aa-933d-5f703dc32b27-2024-11-14-14_33_49
screencapture-localhost-5601-kibana-app-slos-afd56a7c-f21f-42aa-933d-5f703dc32b27-alerts-2024-11-14-14_34_12 screencapture-localhost-5601-kibana-app-slos-afd56a7c-f21f-42aa-933d-5f703dc32b27-history-2024-11-14-14_34_01
screencapture-localhost-5601-kibana-app-slos-create-2024-11-14-14_35_11

@kdelemme kdelemme added release_note:skip Skip the PR/issue when compiling release notes backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Team:obs-ux-management Observability Management User Experience Team v8.17.0 labels Nov 14, 2024
@kdelemme kdelemme marked this pull request as ready for review November 14, 2024 19:37
@kdelemme kdelemme requested review from a team as code owners November 14, 2024 19:37
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

@botelastic botelastic bot added the ci:project-deploy-observability Create an Observability project label Nov 14, 2024
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@@ -116,15 +114,13 @@ export const renderApp = ({
}}
>
<Router history={history}>
<EuiThemeProvider darkMode={isDarkMode}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removing this deprecated theme provider, kept <KibanaThemeProvider {...{ theme: { theme$ } }}> from above

Copy link
Contributor

@cee-chen cee-chen left a comment

Choose a reason for hiding this comment

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

I left some optional suggestions around using EUI size tokens (rather than hardcoded px values), as well as taking advantage of Emotion's css theme callbacks, but they're mostly optional. Overall this looks solid and I love how much code it cleans up!

@@ -84,7 +74,7 @@ export function BurnRate({ sloId, sloInstanceId, duration, reloadSubject }: Embe
<EuiFlexItem>
<EuiLink
data-test-subj="sloBurnRateLink"
className={link}
css={link}
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to use EUI variables for the link CSS defined at the bottom of the page here instead of hard coded values. Something like:

const link = ({ euiTheme }: UseEuiTheme) => css`
  font-size: ${euiTheme.size.base};
  font-weight: ${euiTheme.font.weight.bold};
`;

Comment on lines 169 to 177
css={css`
width: 100%;
padding: 5px 15px;
overflow: scroll;

.euiAccordion__buttonContent {
min-width: 100px;
}
`}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we opt to use EUI token sizes here instead? The translations won't be exact but IMO it's probably good enough?

Suggested change
css={css`
width: 100%;
padding: 5px 15px;
overflow: scroll;
.euiAccordion__buttonContent {
min-width: 100px;
}
`}
css={({ euiTheme}) => css`
width: 100%;
padding: ${euiTheme.size.xs} ${euiTheme.size.base};
overflow: scroll;
.euiAccordion__buttonContent {
min-width: ${euiTheme.base * 6}px;
}
`}

Comment on lines 181 to 183
css={css`
margin-top: 20px;
`}
Copy link
Contributor

Choose a reason for hiding this comment

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

see above comment re: using EUI tokens

Suggested change
css={css`
margin-top: 20px;
`}
css={({ euiTheme }) => css`
margin-top: ${euiTheme.base * 1.25}px;
`}

Comment on lines 51 to 54
css={css`
display: inline-block;
margin-top: 5px;
`}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
css={css`
display: inline-block;
margin-top: 5px;
`}
css={({ euiTheme }) => css`
display: inline-block;
margin-top: ${euiTheme.size.xs};
`}

Comment on lines 28 to 41
const borderRadius = useEuiTheme().euiTheme.border.radius.medium;

return (
<Container boxShadow={euiShadow} position={'relative'}>
<div
css={css`
display: inline-block;
position: relative;
bottom: 42px;
left: 12px;
z-index: 1;
border-radius: ${borderRadius};
${useEuiShadow('l')}
`}
>
Copy link
Contributor

Choose a reason for hiding this comment

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

[optional] You can skip line 28 by using the Emotion's css theme callback:

Suggested change
const borderRadius = useEuiTheme().euiTheme.border.radius.medium;
return (
<Container boxShadow={euiShadow} position={'relative'}>
<div
css={css`
display: inline-block;
position: relative;
bottom: 42px;
left: 12px;
z-index: 1;
border-radius: ${borderRadius};
${useEuiShadow('l')}
`}
>
return (
<div
css={({ euiTheme }) => css`
display: inline-block;
position: relative;
bottom: ${euiTheme.size.xxl};
left: ${euiTheme.size.m};
z-index: 1;
border-radius: ${euiTheme.border.radius.medium};
${useEuiShadow('l')}
`}
>

@kdelemme
Copy link
Contributor Author

Thanks @cee-chen for the review, I'll implement the suggestions

@kdelemme
Copy link
Contributor Author

@cee-chen finally got time to make the changes. Thanks for the suggested changes

padding: ${euiTheme.size.xs} ${euiTheme.size.base};
overflow: scroll;

.euiAccordion__buttonContent {
Copy link
Contributor

Choose a reason for hiding this comment

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

might be something we can apply directly in the acordion in group list view.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to keep the goal of this PR solely on removing the deprecated theme provider and migrating to emotion.

@elasticmachine
Copy link
Contributor

elasticmachine commented Nov 20, 2024

💛 Build succeeded, but was flaky

  • Buildkite Build
  • Commit: 8a4add9
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-200248-8a4add95945a

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #13 / AllCases empty table should render the create new case link when the user has create privileges
  • [job] [logs] Jest Tests #12 / Policy Advanced Settings section should expand and collapse section when button is clicked

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
slo 867 854 -13

Async chunks

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

id before after diff
slo 865.7KB 842.8KB -22.9KB

Page load bundle

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

id before after diff
slo 28.7KB 28.6KB -95.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
slo 16 17 +1

Total ESLint disabled count

id before after diff
slo 20 21 +1

History

Copy link
Contributor

@shahzad31 shahzad31 left a comment

Choose a reason for hiding this comment

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

Smoke testing looks good !

@kdelemme kdelemme merged commit 684a130 into elastic:main Nov 20, 2024
26 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11936684050

@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Nov 20, 2024
…d-components (#200248) (#200969)

# Backport

This will backport the following commits from `main` to `8.x`:
- [chore(slo): remove deprecated theme provider and usage of
styled-components
(#200248)](#200248)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Kevin
Delemme","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-20T15:37:32Z","message":"chore(slo):
remove deprecated theme provider and usage of styled-components
(#200248)","sha":"684a1308d279acbdff7f49bcce204854c2a95681","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-management","v8.17.0"],"title":"chore(slo):
remove deprecated theme provider and usage of
styled-components","number":200248,"url":"https://github.com/elastic/kibana/pull/200248","mergeCommit":{"message":"chore(slo):
remove deprecated theme provider and usage of styled-components
(#200248)","sha":"684a1308d279acbdff7f49bcce204854c2a95681"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200248","number":200248,"mergeCommit":{"message":"chore(slo):
remove deprecated theme provider and usage of styled-components
(#200248)","sha":"684a1308d279acbdff7f49bcce204854c2a95681"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Kevin Delemme <[email protected]>
TattdCodeMonkey pushed a commit to TattdCodeMonkey/kibana that referenced this pull request Nov 21, 2024
paulinashakirova pushed a commit to paulinashakirova/kibana that referenced this pull request Nov 26, 2024
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
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) ci:project-deploy-observability Create an Observability project release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-management Observability Management User Experience Team v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SLO] Remove deprecated usage of ThemeProvider and styled-components
6 participants