From 2552fdb7303acf16c8a6753bac9dd827b1fe55b5 Mon Sep 17 00:00:00 2001 From: Uchechukwu Obasi Date: Mon, 1 Feb 2021 11:46:47 +0100 Subject: [PATCH] TableInputCSV: migrated styles from sass to emotion (#30554) * TableInputCSV: migrated styles from sass to emotion * placed the getSyles function at the end of the file * made some changes * fixes small nit * fixes small nit * replaced classNames with emotions cx function * Replaced textarea with TextArea component * updated some changes * removed return type annotation * fixed small import nit --- .../TableInputCSV.story.internal.tsx | 5 ++- .../TableInputCSV/TableInputCSV.test.tsx | 2 +- .../TableInputCSV/TableInputCSV.tsx | 44 +++++++++++++++---- .../TableInputCSV/_TableInputCSV.scss | 18 -------- packages/grafana-ui/src/components/index.scss | 1 - 5 files changed, 40 insertions(+), 30 deletions(-) delete mode 100644 packages/grafana-ui/src/components/TableInputCSV/_TableInputCSV.scss diff --git a/packages/grafana-ui/src/components/TableInputCSV/TableInputCSV.story.internal.tsx b/packages/grafana-ui/src/components/TableInputCSV/TableInputCSV.story.internal.tsx index a702a4688a0..b3ad26c955a 100644 --- a/packages/grafana-ui/src/components/TableInputCSV/TableInputCSV.story.internal.tsx +++ b/packages/grafana-ui/src/components/TableInputCSV/TableInputCSV.story.internal.tsx @@ -1,6 +1,7 @@ import React from 'react'; -import TableInputCSV from './TableInputCSV'; +import { TableInputCSV } from './TableInputCSV'; +import { Meta } from '@storybook/react'; import { action } from '@storybook/addon-actions'; import { DataFrame } from '@grafana/data'; import { withCenteredStory } from '../../utils/storybook/withCenteredStory'; @@ -9,7 +10,7 @@ export default { title: 'Forms/TableInputCSV', component: TableInputCSV, decorators: [withCenteredStory], -}; +} as Meta; export const basic = () => { return ( diff --git a/packages/grafana-ui/src/components/TableInputCSV/TableInputCSV.test.tsx b/packages/grafana-ui/src/components/TableInputCSV/TableInputCSV.test.tsx index 4e08b103027..e2953fc1c43 100644 --- a/packages/grafana-ui/src/components/TableInputCSV/TableInputCSV.test.tsx +++ b/packages/grafana-ui/src/components/TableInputCSV/TableInputCSV.test.tsx @@ -1,7 +1,7 @@ import React from 'react'; import renderer from 'react-test-renderer'; -import TableInputCSV from './TableInputCSV'; +import { TableInputCSV } from './TableInputCSV'; import { DataFrame } from '@grafana/data'; describe('TableInputCSV', () => { diff --git a/packages/grafana-ui/src/components/TableInputCSV/TableInputCSV.tsx b/packages/grafana-ui/src/components/TableInputCSV/TableInputCSV.tsx index 5b92ef0d6cf..e0633e398ca 100644 --- a/packages/grafana-ui/src/components/TableInputCSV/TableInputCSV.tsx +++ b/packages/grafana-ui/src/components/TableInputCSV/TableInputCSV.tsx @@ -1,9 +1,14 @@ import React from 'react'; import debounce from 'lodash/debounce'; +import { css } from 'emotion'; import { DataFrame, CSVConfig, readCSV } from '@grafana/data'; import { Icon } from '../Icon/Icon'; +import { GrafanaTheme } from '@grafana/data'; +import { Themeable } from '../../types/theme'; +import { TextArea } from '../TextArea/TextArea'; +import { stylesFactory, withTheme } from '../../themes'; -interface Props { +interface Props extends Themeable { config?: CSVConfig; text: string; width: string | number; @@ -19,7 +24,7 @@ interface State { /** * Expects the container div to have size set and will fill it 100% */ -export class TableInputCSV extends React.PureComponent { +export class UnThemedTableInputCSV extends React.PureComponent { constructor(props: Props) { super(props); @@ -59,19 +64,20 @@ export class TableInputCSV extends React.PureComponent { }; render() { - const { width, height } = this.props; + const { width, height, theme } = this.props; const { data } = this.state; + const styles = getStyles(theme); return ( -
-