-
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
Changes from all commits
6e8e779
3287d9d
c3111fc
aa362a4
dd8092c
2c309e4
8a4add9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import '@emotion/react'; | ||
import type { UseEuiTheme } from '@elastic/eui'; | ||
|
||
declare module '@emotion/react' { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface Theme extends UseEuiTheme {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,15 @@ | |
* 2.0. | ||
*/ | ||
|
||
import { EuiBadge, EuiFlexGroup, EuiFlexItem, EuiLink, EuiLoadingChart } from '@elastic/eui'; | ||
import { css } from '@emotion/css'; | ||
import { | ||
EuiBadge, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiLink, | ||
EuiLoadingChart, | ||
UseEuiTheme, | ||
} from '@elastic/eui'; | ||
import { css } from '@emotion/react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
import { SLOWithSummaryResponse } from '@kbn/slo-schema'; | ||
|
@@ -41,12 +48,7 @@ export function BurnRate({ sloId, sloInstanceId, duration, reloadSubject }: Embe | |
|
||
if (isLoading || !slo) { | ||
return ( | ||
<EuiFlexGroup | ||
direction="column" | ||
alignItems="center" | ||
justifyContent="center" | ||
className={container} | ||
> | ||
<EuiFlexGroup direction="column" alignItems="center" justifyContent="center" css={container}> | ||
<EuiFlexItem grow={false}> | ||
<EuiLoadingChart /> | ||
</EuiFlexItem> | ||
|
@@ -56,12 +58,7 @@ export function BurnRate({ sloId, sloInstanceId, duration, reloadSubject }: Embe | |
|
||
if (isSloNotFound) { | ||
return ( | ||
<EuiFlexGroup | ||
direction="column" | ||
alignItems="center" | ||
justifyContent="center" | ||
className={container} | ||
> | ||
<EuiFlexGroup direction="column" alignItems="center" justifyContent="center" css={container}> | ||
<EuiFlexItem grow={false}> | ||
{i18n.translate('xpack.slo.sloEmbeddable.overview.sloNotFoundText', { | ||
defaultMessage: | ||
|
@@ -84,7 +81,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 commentThe 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};
`; |
||
color="text" | ||
onClick={() => { | ||
setSelectedSlo(slo); | ||
|
@@ -146,7 +143,7 @@ const container = css` | |
height: 100%; | ||
`; | ||
|
||
const link = css` | ||
font-size: 16px; | ||
font-weight: 700; | ||
const link = ({ euiTheme }: UseEuiTheme) => css` | ||
font-size: ${euiTheme.size.base}; | ||
font-weight: ${euiTheme.font.weight.bold}; | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,8 @@ | |
* 2.0. | ||
*/ | ||
|
||
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; | ||
import { EuiFlexGroup, EuiFlexItem, UseEuiTheme } from '@elastic/eui'; | ||
import { css } from '@emotion/react'; | ||
import type { CoreStart } from '@kbn/core-lifecycle-browser'; | ||
import { ReactEmbeddableFactory } from '@kbn/embeddable-plugin/public'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
@@ -21,7 +22,6 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | |
import { createBrowserHistory } from 'history'; | ||
import React, { useEffect } from 'react'; | ||
import { BehaviorSubject, Subject } from 'rxjs'; | ||
import styled from 'styled-components'; | ||
import { PluginContext } from '../../../context/plugin_context'; | ||
import type { SLOPublicPluginsStart, SLORepositoryClient } from '../../../types'; | ||
import { SLO_OVERVIEW_EMBEDDABLE_ID } from './constants'; | ||
|
@@ -165,11 +165,21 @@ export const getOverviewEmbeddableFactory = ({ | |
const kqlQuery = groupFilters?.kqlQuery ?? ''; | ||
const groups = groupFilters?.groups ?? []; | ||
return ( | ||
<Wrapper> | ||
<div | ||
css={({ euiTheme }: UseEuiTheme) => css` | ||
width: 100%; | ||
padding: ${euiTheme.size.xs} ${euiTheme.size.base}; | ||
overflow: scroll; | ||
|
||
.euiAccordion__buttonContent { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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. |
||
min-width: ${euiTheme.base * 6}px; | ||
} | ||
`} | ||
> | ||
<EuiFlexGroup data-test-subj="sloGroupOverviewPanel" data-shared-item=""> | ||
<EuiFlexItem | ||
css={` | ||
margin-top: 20px; | ||
css={({ euiTheme }: UseEuiTheme) => css` | ||
margin-top: ${euiTheme.base * 1.25}px; | ||
`} | ||
> | ||
<GroupSloView | ||
|
@@ -182,7 +192,7 @@ export const getOverviewEmbeddableFactory = ({ | |
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</Wrapper> | ||
</div> | ||
); | ||
} else { | ||
return ( | ||
|
@@ -230,13 +240,3 @@ export const getOverviewEmbeddableFactory = ({ | |
}; | ||
return factory; | ||
}; | ||
|
||
const Wrapper = styled.div` | ||
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.
removing this deprecated theme provider, kept
<KibanaThemeProvider {...{ theme: { theme$ } }}>
from above