diff --git a/contribute/style-guides/styling.md b/contribute/style-guides/styling.md index 7b224e85db2..37c1bc1b1d1 100644 --- a/contribute/style-guides/styling.md +++ b/contribute/style-guides/styling.md @@ -10,7 +10,7 @@ For styling components, use [Emotion's `css` function](https://emotion.sh/docs/e ```tsx import React from 'react'; -import { css } from 'emotion'; +import { css } from '@emotion/css'; const ComponentA = () => (
= () => { const styles = useStyles(getStyles); // Use styles with classNames - return
...
- + return
...
; }; const getStyles = (theme: GrafanaTheme) => css` @@ -56,15 +55,15 @@ Let's say you need to style a component that has a different background dependin ```tsx import React from 'react'; -import { css } from 'emotion'; +import { css } from '@emotion/css'; import { GrafanaTheme } from '@grafana/data'; import { selectThemeVariant, stylesFactory, useTheme } from '@grafana/ui'; interface ComponentAProps { - isActive: boolean + isActive: boolean; } -const ComponentA: React.FC = ({isActive}) => { +const ComponentA: React.FC = ({ isActive }) => { const theme = useTheme(); const styles = getStyles(theme, isActive); @@ -76,7 +75,6 @@ const ComponentA: React.FC = ({isActive}) => { ); }; - // Mind, that you can pass multiple arguments, theme included const getStyles = stylesFactory((theme: GrafanaTheme, isActive: boolean) => { const backgroundColor = isActive ? theme.colors.red : theme.colors.blue; @@ -100,7 +98,7 @@ For class composition, use [Emotion's `cx` function](https://emotion.sh/docs/emo ```tsx import React from 'react'; -import { css, cx } from 'emotion'; +import { css, cx } from '@emotion/css'; interface Props { className?: string; diff --git a/contribute/style-guides/themes.md b/contribute/style-guides/themes.md index 39a9a064d7f..7e0d4fee62c 100644 --- a/contribute/style-guides/themes.md +++ b/contribute/style-guides/themes.md @@ -26,7 +26,7 @@ Here's how to use Grafana themes in React components. import React, { FC } from 'react'; import { GrafanaTheme } from '@grafana/data'; import { useStyles } from '@grafana/ui'; -import { css } from 'emotion'; +import { css } from '@emotion/css'; const getComponentStyles = (theme: GrafanaTheme) => css` padding: ${theme.spacing.md}; @@ -57,7 +57,7 @@ const Foo: FC = () => { ```tsx import { ThemeContext } from '@grafana/ui'; -{theme => }; +{(theme) => }; ``` #### Using `withTheme` higher-order component (HOC) @@ -97,9 +97,8 @@ describe('MyComponent', () => { restoreThemeContext(); }); - it('renders correctly', () => { - const wrapper = mount() + const wrapper = mount(); expect(wrapper).toMatchSnapshot(); }); }); diff --git a/packages/grafana-ui/src/components/ColorPicker/SeriesColorPickerPopover.tsx b/packages/grafana-ui/src/components/ColorPicker/SeriesColorPickerPopover.tsx index 364a31a541f..227ce6382f5 100644 --- a/packages/grafana-ui/src/components/ColorPicker/SeriesColorPickerPopover.tsx +++ b/packages/grafana-ui/src/components/ColorPicker/SeriesColorPickerPopover.tsx @@ -5,6 +5,7 @@ import { PopoverContentProps } from '../Tooltip/Tooltip'; import { Switch } from '../Forms/Legacy/Switch/Switch'; import { css } from '@emotion/css'; import { withTheme, useStyles } from '../../themes'; +import { Button } from '../Button'; export interface SeriesColorPickerPopoverProps extends ColorPickerProps, PopoverContentProps { yaxis?: number; @@ -70,18 +71,18 @@ export class AxisSelector extends React.PureComponent - - + +
); } diff --git a/packages/grafana-ui/src/components/DataSourceSettings/CertificationKey.tsx b/packages/grafana-ui/src/components/DataSourceSettings/CertificationKey.tsx index 5ed9a27cb76..1b8406ca8ff 100644 --- a/packages/grafana-ui/src/components/DataSourceSettings/CertificationKey.tsx +++ b/packages/grafana-ui/src/components/DataSourceSettings/CertificationKey.tsx @@ -1,4 +1,8 @@ import React, { ChangeEvent, MouseEvent, FC } from 'react'; +import { Input } from '../Input/Input'; +import { Button } from '../Button'; +import { TextArea } from '../TextArea/TextArea'; +import { InlineField } from '../Forms/InlineField'; interface Props { label: string; @@ -6,35 +10,22 @@ interface Props { placeholder: string; onChange: (event: ChangeEvent) => void; - onClick: (event: MouseEvent) => void; + onClick: (event: MouseEvent) => void; } export const CertificationKey: FC = ({ hasCert, label, onChange, onClick, placeholder }) => { return ( -
-
- -
- {!hasCert && ( -
-