-
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
chore(slo): remove deprecated theme provider and usage of styled-components #200248
chore(slo): remove deprecated theme provider and usage of styled-components #200248
Conversation
Pinging @elastic/obs-ux-management-team (Team:obs-ux-management) |
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
@@ -116,15 +114,13 @@ export const renderApp = ({ | |||
}} | |||
> | |||
<Router history={history}> | |||
<EuiThemeProvider darkMode={isDarkMode}> |
There was a problem hiding this comment.
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
There was a problem hiding this 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} |
There was a problem hiding this comment.
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};
`;
css={css` | ||
width: 100%; | ||
padding: 5px 15px; | ||
overflow: scroll; | ||
|
||
.euiAccordion__buttonContent { | ||
min-width: 100px; | ||
} | ||
`} |
There was a problem hiding this comment.
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?
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; | |
} | |
`} |
css={css` | ||
margin-top: 20px; | ||
`} |
There was a problem hiding this comment.
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
css={css` | |
margin-top: 20px; | |
`} | |
css={({ euiTheme }) => css` | |
margin-top: ${euiTheme.base * 1.25}px; | |
`} |
css={css` | ||
display: inline-block; | ||
margin-top: 5px; | ||
`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
css={css` | |
display: inline-block; | |
margin-top: 5px; | |
`} | |
css={({ euiTheme }) => css` | |
display: inline-block; | |
margin-top: ${euiTheme.size.xs}; | |
`} |
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')} | ||
`} | ||
> |
There was a problem hiding this comment.
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:
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')} | |
`} | |
> |
Thanks @cee-chen for the review, I'll implement the suggestions |
@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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
|
There was a problem hiding this 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 !
Starting backport for target branches: 8.x |
…onents (elastic#200248) (cherry picked from commit 684a130)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…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]>
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