From 7060e9c49bdfd86000191db744bb03adb3b90251 Mon Sep 17 00:00:00 2001 From: sam-m-m Date: Tue, 1 Dec 2020 13:07:14 -0800 Subject: [PATCH 1/8] feat #159 - Add IngestionStatusDot comp & add to Table --- src/__mocks__/table_mock_data.ts | 20 ++++- src/components/IngestionStatusDot/index.tsx | 73 +++++++++++++++++++ src/components/Table/__tests__/Table.test.tsx | 2 + src/components/Table/types.ts | 6 ++ src/components/Table/utils.tsx | 24 +++++- src/components/index.ts | 1 + 6 files changed, 122 insertions(+), 4 deletions(-) create mode 100644 src/components/IngestionStatusDot/index.tsx diff --git a/src/__mocks__/table_mock_data.ts b/src/__mocks__/table_mock_data.ts index 01b477d3..d30dc660 100644 --- a/src/__mocks__/table_mock_data.ts +++ b/src/__mocks__/table_mock_data.ts @@ -1,3 +1,4 @@ +import { Status } from 'components' import { ColumnFormats, ColumnType, @@ -6,7 +7,16 @@ import { } from '../components/Table' const { component, number, string } = ColumnTypes -const { none, byte, date, icon, link, toggle, tag } = ColumnFormats +const { + none, + byte, + date, + icon, + ingestionStatusDot, + link, + toggle, + tag +} = ColumnFormats export interface Data { byte: number @@ -14,6 +24,7 @@ export interface Data { icon: string icon_key: string id: number + ingestion_status: Status link: string number: number string: string @@ -92,6 +103,12 @@ const columns: ColumnType[] = [ }, title: 'Component - Icon', type: component + }, + { + dataIndex: 'ingestion_status', + format: ingestionStatusDot, + title: 'Ingestion Status', + type: component } ] @@ -102,6 +119,7 @@ const data: Data[] = [ icon: 'test', icon_key: 'dassana', id: 0, + ingestion_status: Status.OK, link: 'test', number: 0, string: 'Dassana', diff --git a/src/components/IngestionStatusDot/index.tsx b/src/components/IngestionStatusDot/index.tsx new file mode 100644 index 00000000..05b615db --- /dev/null +++ b/src/components/IngestionStatusDot/index.tsx @@ -0,0 +1,73 @@ +import cn from 'classnames' +import { createUseStyles } from 'react-jss' +import React, { FC } from 'react' +import { styleguide, ThemeType } from 'components/assets/styles' + +const { + colors: { blacks, oranges } +} = styleguide + +const { light, dark } = ThemeType + +/* TODO: Use types generated from codegen */ +export enum Status { + DISABLED = 'DISABLED', + HASISSUES = 'HAS_ISSUES', + NEEDSCONFIG = 'NEEDS_CONFIG', + OK = 'OK' +} + +const colorPalette = { + [dark]: { + [Status.NEEDSCONFIG]: blacks['lighten-40'] + }, + [light]: { + [Status.NEEDSCONFIG]: blacks['lighten-70'] + } +} + +const useStyles = createUseStyles({ + hasIssues: { + background: oranges.base + }, + needsConfig: { + background: colorPalette[light][Status.NEEDSCONFIG] + }, + statusDot: { + borderRadius: '50%', + display: 'block', + height: 10, + width: 10 + }, + // eslint-disable-next-line sort-keys + '@global': { + [`.${dark}`]: { + '& $needsConfig': { + background: colorPalette[dark][Status.NEEDSCONFIG] + } + } + } +}) + +export interface Props { + classes?: string[] + status?: Status +} + +export const IngestionStatusDot: FC = ({ + classes = [], + status = Status.OK +}: Props) => { + const componentClasses = useStyles() + + const ingestionStatusDotClasses = cn( + { + [componentClasses.statusDot]: true, + [componentClasses.hasIssues]: status === Status.HASISSUES, + [componentClasses.needsConfig]: status === Status.NEEDSCONFIG + }, + classes + ) + + return +} diff --git a/src/components/Table/__tests__/Table.test.tsx b/src/components/Table/__tests__/Table.test.tsx index 996a33b4..2ccaf245 100644 --- a/src/components/Table/__tests__/Table.test.tsx +++ b/src/components/Table/__tests__/Table.test.tsx @@ -1,6 +1,7 @@ import { act } from 'react-dom/test-utils' import moment from 'moment' import React from 'react' +import { Status } from 'components/IngestionStatusDot' import { Input as AntDInput, Table as AntDTable } from 'antd' import mockData, { Data, dateFormat } from '__mocks__/table_mock_data' import mockData0, { Person } from '../fixtures/0_sample_data' @@ -97,6 +98,7 @@ describe('Table', () => { icon: 'test', icon_key: 'dassana', id: 0, + ingestion_status: Status.OK, key: 0, link: 'test', number: 0, diff --git a/src/components/Table/types.ts b/src/components/Table/types.ts index c5dfa417..432454c4 100644 --- a/src/components/Table/types.ts +++ b/src/components/Table/types.ts @@ -13,6 +13,7 @@ export enum ColumnFormats { date = 'date', byte = 'byte', icon = 'icon', + ingestionStatusDot = 'ingestionStatusDot', link = 'link', tag = 'tag', toggle = 'toggle' @@ -69,6 +70,10 @@ interface ComponentIconType extends PartialComponentType { renderProps: RenderPropsIcon | RenderPropsIconKey } +interface ComponentIngestionStatusDotType extends PartialComponentType { + format: ColumnFormats.ingestionStatusDot +} + interface RenderPropsLink extends Pick { buildHref: (record?: string) => string } @@ -88,6 +93,7 @@ interface ComponentToggleType extends PartialComponentType { type ComponentType = | ComponentIconType + | ComponentIngestionStatusDotType | ComponentLinkType | ComponentTagType | ComponentToggleType diff --git a/src/components/Table/utils.tsx b/src/components/Table/utils.tsx index acabcfce..cf9ba00a 100644 --- a/src/components/Table/utils.tsx +++ b/src/components/Table/utils.tsx @@ -15,6 +15,7 @@ import { Icon, IconName, IconProps } from '../Icon' import { Link, LinkProps } from '../Link' import { Tag, TagProps } from '../Tag' import { Toggle, ToggleProps } from '../Toggle' +import { IngestionStatusDot, Status } from 'components/IngestionStatusDot' /* ------- Exported Functions ------- */ @@ -81,7 +82,7 @@ More info --> https://fusejs.io/examples.html#nested-search */ export function mapFilterKeys(columns: ColumnType[]) { const { component, number, string } = ColumnTypes - const { icon, link, tag } = ColumnFormats + const { icon, ingestionStatusDot, link, tag } = ColumnFormats const keysArr: (string | string[])[] = ['_FORMATTED_DATA'] @@ -92,6 +93,7 @@ export function mapFilterKeys(columns: ColumnType[]) { case component: switch (column.format) { case icon: + case ingestionStatusDot: case link: keysArr.push(dataIndex) break @@ -171,12 +173,13 @@ function applySort( antDColumn: AntDColumnType ) { const { component, number, string } = ColumnTypes - const { icon, link, tag, toggle } = ColumnFormats + const { icon, ingestionStatusDot, link, tag, toggle } = ColumnFormats switch (column.type) { case component: switch (column.format) { case icon: + case ingestionStatusDot: case link: antDColumn.sorter = compareStrings(column) break @@ -212,7 +215,15 @@ function applyRender( antDColumn: AntDColumnType ) { const { component, number } = ColumnTypes - const { byte, date, icon, link, tag, toggle } = ColumnFormats + const { + byte, + date, + icon, + ingestionStatusDot, + link, + tag, + toggle + } = ColumnFormats switch (column.type) { case component: @@ -244,6 +255,13 @@ function applyRender( break } + case ingestionStatusDot: { + antDColumn.render = (record: Status) => ( + + ) + break + } + case link: { antDColumn.render = (record: string) => { if (record === undefined) return '' diff --git a/src/components/index.ts b/src/components/index.ts index 23b108ed..86376b2b 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -4,6 +4,7 @@ export * from './Button' export * from './Form' export * from './Input' export * from './Icon' +export * from './IngestionStatusDot' export * from './Link' export * from './Notification' export * from './NotificationV2' From a7be0479726186ffbc4cc8191d7e1fd48ea22270 Mon Sep 17 00:00:00 2001 From: sam-m-m Date: Tue, 1 Dec 2020 13:59:08 -0800 Subject: [PATCH 2/8] feat #159 - Add stories --- .../IngestionStatusDot.stories.tsx | 64 +++++++++++++++++++ src/components/IngestionStatusDot/index.tsx | 6 +- src/components/Table/Table.stories.mdx | 4 ++ src/components/Table/Table.stories.tsx | 10 +++ .../Table/fixtures/4_sample_data.ts | 53 +++++++++++++++ src/components/Table/utils.tsx | 2 +- 6 files changed, 135 insertions(+), 4 deletions(-) create mode 100644 src/components/IngestionStatusDot/IngestionStatusDot.stories.tsx create mode 100644 src/components/Table/fixtures/4_sample_data.ts diff --git a/src/components/IngestionStatusDot/IngestionStatusDot.stories.tsx b/src/components/IngestionStatusDot/IngestionStatusDot.stories.tsx new file mode 100644 index 00000000..132db9c9 --- /dev/null +++ b/src/components/IngestionStatusDot/IngestionStatusDot.stories.tsx @@ -0,0 +1,64 @@ +import { createUseStyles } from 'react-jss' +import { Meta } from '@storybook/react/types-6-0' +import { IngestionStatusDot, Status } from '.' +import React, { FC } from 'react' +import { styleguide, themedStyles, ThemeType } from 'components/assets/styles' + +export default { + component: IngestionStatusDot, + title: 'IngestionStatusDot' +} as Meta + +const { flexAlignCenter, font, spacing } = styleguide + +const { light, dark } = ThemeType + +const useStyles = createUseStyles({ + statusDot: { + marginRight: spacing.m + }, + wrapper: { + ...flexAlignCenter, + ...font.body, + color: themedStyles[light].base.color, + paddingBottom: spacing.m + }, + // eslint-disable-next-line sort-keys + '@global': { + [`.${dark}`]: { + '& $wrapper': { + color: themedStyles[dark].base.color + } + } + } +}) + +interface Props { + status: Status +} + +const DecoratedDot: FC = ({ status }: Props) => { + const classes = useStyles() + + return ( +
+ + {status} +
+ ) +} + +const statuses = [ + Status.HASISSUES, + Status.NEEDSCONFIG, + Status.OK, + Status.DISABLED +] + +export const All = () => ( + <> + {statuses.map((status: Status) => ( + + ))} + +) diff --git a/src/components/IngestionStatusDot/index.tsx b/src/components/IngestionStatusDot/index.tsx index 05b615db..b212c991 100644 --- a/src/components/IngestionStatusDot/index.tsx +++ b/src/components/IngestionStatusDot/index.tsx @@ -49,15 +49,15 @@ const useStyles = createUseStyles({ } }) -export interface Props { +export interface IngestionStatusDotProps { classes?: string[] status?: Status } -export const IngestionStatusDot: FC = ({ +export const IngestionStatusDot: FC = ({ classes = [], status = Status.OK -}: Props) => { +}: IngestionStatusDotProps) => { const componentClasses = useStyles() const ingestionStatusDotClasses = cn( diff --git a/src/components/Table/Table.stories.mdx b/src/components/Table/Table.stories.mdx index 0deb8032..4df599ca 100644 --- a/src/components/Table/Table.stories.mdx +++ b/src/components/Table/Table.stories.mdx @@ -718,3 +718,7 @@ export type type ColumnType = StringType | NumberType | ComponentType + + + + diff --git a/src/components/Table/Table.stories.tsx b/src/components/Table/Table.stories.tsx index 9e7425f8..dd3aa11b 100644 --- a/src/components/Table/Table.stories.tsx +++ b/src/components/Table/Table.stories.tsx @@ -7,6 +7,7 @@ import tableData0, { Person } from './fixtures/0_sample_data' import tableData1, { File } from './fixtures/1_sample_data' import tableData2, { Client } from './fixtures/2_sample_data' import tableData3, { Client1 } from './fixtures/3_sample_data' +import tableData4, { IngestionStatusType } from './fixtures/4_sample_data' const commonArgTypes = { activeRowKey: { @@ -250,3 +251,12 @@ Paginated.args = { }) } Paginated.argTypes = commonArgTypes + +const IngestionStatusTemplate: Story> = args => {...args} /> + +export const IngestionStatus = IngestionStatusTemplate.bind({}) +IngestionStatus.args = { + ...tableData4 +} diff --git a/src/components/Table/fixtures/4_sample_data.ts b/src/components/Table/fixtures/4_sample_data.ts new file mode 100644 index 00000000..dd0f6244 --- /dev/null +++ b/src/components/Table/fixtures/4_sample_data.ts @@ -0,0 +1,53 @@ +import { ColumnFormats } from '../types' +import { Status } from 'components/IngestionStatusDot' +import { ColumnType, ColumnTypes, TableProps } from '../.' + +export interface IngestionStatusType { + status_label: string + id: number | string + ingestion_status: Status +} + +const { ingestionStatusDot } = ColumnFormats +const { component, string } = ColumnTypes + +const columns: ColumnType[] = [ + { + dataIndex: 'status_label', + title: 'Status Label', + type: string + }, + { + dataIndex: 'ingestion_status', + format: ingestionStatusDot, + title: 'Ingestion Status Dot', + type: component + } +] + +const data: IngestionStatusType[] = [ + { + id: 0, + ingestion_status: Status.OK, + status_label: 'ok' + }, + { + id: 1, + ingestion_status: Status.NEEDSCONFIG, + status_label: 'needs config' + }, + { + id: 2, + ingestion_status: Status.DISABLED, + status_label: 'paused' + }, + { + id: 3, + ingestion_status: Status.HASISSUES, + status_label: 'issues' + } +] + +const tableData4: TableProps = { columns, data } + +export default tableData4 diff --git a/src/components/Table/utils.tsx b/src/components/Table/utils.tsx index cf9ba00a..c3c3d8e5 100644 --- a/src/components/Table/utils.tsx +++ b/src/components/Table/utils.tsx @@ -12,10 +12,10 @@ import { NumberDateType } from './types' import { Icon, IconName, IconProps } from '../Icon' +import { IngestionStatusDot, Status } from 'components/IngestionStatusDot' import { Link, LinkProps } from '../Link' import { Tag, TagProps } from '../Tag' import { Toggle, ToggleProps } from '../Toggle' -import { IngestionStatusDot, Status } from 'components/IngestionStatusDot' /* ------- Exported Functions ------- */ From 485bcc9829e779154f6684ddf719de3fd4eeb9be Mon Sep 17 00:00:00 2001 From: sam-m-m Date: Tue, 1 Dec 2020 14:37:32 -0800 Subject: [PATCH 3/8] feat #159 - Add Tooltip --- src/__snapshots__/storybook.test.ts.snap | 107 ++++++++++++------ .../IngestionStatusDot.stories.tsx | 2 +- .../IngestionStatusDot.test.tsx | 15 +++ src/components/IngestionStatusDot/index.tsx | 16 ++- 4 files changed, 106 insertions(+), 34 deletions(-) create mode 100644 src/components/IngestionStatusDot/IngestionStatusDot.test.tsx diff --git a/src/__snapshots__/storybook.test.ts.snap b/src/__snapshots__/storybook.test.ts.snap index 952fd8cc..d5d3e187 100644 --- a/src/__snapshots__/storybook.test.ts.snap +++ b/src/__snapshots__/storybook.test.ts.snap @@ -210,12 +210,55 @@ exports[`Storyshots Icon Predefined 1`] = ` `; +exports[`Storyshots IngestionStatusDot All 1`] = ` +
+
+ + HAS_ISSUES +
+
+ + NEEDS_CONFIG +
+
+ + OK +
+
+ + DISABLED +
+
+`; + exports[`Storyshots Input Default 1`] = `
  @@ -292,7 +335,7 @@ exports[`Storyshots Input Placeholder 1`] = ` className="light storyWrapper-0-2-2" >
 
 
  @@ -719,10 +762,10 @@ exports[`Storyshots Select Default 1`] = ` className="light storyWrapper-0-2-2" >
Lorem @@ -916,10 +959,10 @@ exports[`Storyshots Select Icon 1`] = ` className="light storyWrapper-0-2-2" >
  @@ -1137,27 +1180,27 @@ exports[`Storyshots Skeleton Count 1`] = ` className="light storyWrapper-0-2-2" >           @@ -1169,7 +1212,7 @@ exports[`Storyshots Skeleton Default 1`] = ` className="light storyWrapper-0-2-2" >   diff --git a/src/components/IngestionStatusDot/IngestionStatusDot.stories.tsx b/src/components/IngestionStatusDot/IngestionStatusDot.stories.tsx index 132db9c9..8d3a5d19 100644 --- a/src/components/IngestionStatusDot/IngestionStatusDot.stories.tsx +++ b/src/components/IngestionStatusDot/IngestionStatusDot.stories.tsx @@ -21,7 +21,7 @@ const useStyles = createUseStyles({ ...flexAlignCenter, ...font.body, color: themedStyles[light].base.color, - paddingBottom: spacing.m + padding: `${spacing.s}px ${spacing.xl}px` }, // eslint-disable-next-line sort-keys '@global': { diff --git a/src/components/IngestionStatusDot/IngestionStatusDot.test.tsx b/src/components/IngestionStatusDot/IngestionStatusDot.test.tsx new file mode 100644 index 00000000..581d7259 --- /dev/null +++ b/src/components/IngestionStatusDot/IngestionStatusDot.test.tsx @@ -0,0 +1,15 @@ +import React from 'react' +import { IngestionStatusDot, Status } from '.' +import { mount, ReactWrapper } from 'enzyme' + +let wrapper: ReactWrapper + +describe('IngestionStatusDot', () => { + beforeEach(() => { + wrapper = mount() + }) + + it('renders', () => { + expect(wrapper).toHaveLength(1) + }) +}) diff --git a/src/components/IngestionStatusDot/index.tsx b/src/components/IngestionStatusDot/index.tsx index b212c991..be74f315 100644 --- a/src/components/IngestionStatusDot/index.tsx +++ b/src/components/IngestionStatusDot/index.tsx @@ -1,5 +1,8 @@ import cn from 'classnames' import { createUseStyles } from 'react-jss' +import lowerCase from 'lodash/lowerCase' +import { Tooltip } from 'antd' +import upperFirst from 'lodash/upperFirst' import React, { FC } from 'react' import { styleguide, ThemeType } from 'components/assets/styles' @@ -69,5 +72,16 @@ export const IngestionStatusDot: FC = ({ classes ) - return + const showTooltip = + status === Status.HASISSUES || status === Status.NEEDSCONFIG + + const tooltipText = upperFirst(lowerCase(status)) + + return showTooltip ? ( + + + + ) : ( + + ) } From c300183ccc2e7b5b412d3b49d3d4e866b044a07b Mon Sep 17 00:00:00 2001 From: sam-m-m Date: Tue, 1 Dec 2020 18:26:06 -0800 Subject: [PATCH 4/8] feat #159 - Add tests --- package-lock.json | 2 +- package.json | 2 +- .../IngestionStatusDot.stories.tsx | 36 +++++++++++-------- .../IngestionStatusDot.test.tsx | 10 +++++- src/components/IngestionStatusDot/index.tsx | 4 +-- 5 files changed, 35 insertions(+), 19 deletions(-) diff --git a/package-lock.json b/package-lock.json index c8af1166..443148ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@dassana-io/web-components", - "version": "0.7.3", + "version": "0.7.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 68204686..b7c5cab2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dassana-io/web-components", - "version": "0.7.4", + "version": "0.7.5", "publishConfig": { "registry": "https://npm.pkg.github.com/dassana-io" }, diff --git a/src/components/IngestionStatusDot/IngestionStatusDot.stories.tsx b/src/components/IngestionStatusDot/IngestionStatusDot.stories.tsx index 8d3a5d19..8bd4fb02 100644 --- a/src/components/IngestionStatusDot/IngestionStatusDot.stories.tsx +++ b/src/components/IngestionStatusDot/IngestionStatusDot.stories.tsx @@ -14,19 +14,22 @@ const { flexAlignCenter, font, spacing } = styleguide const { light, dark } = ThemeType const useStyles = createUseStyles({ - statusDot: { - marginRight: spacing.m - }, - wrapper: { + container: { ...flexAlignCenter, + padding: `${spacing.s}px ${spacing.l}px` + }, + mainContainer: { ...font.body, color: themedStyles[light].base.color, - padding: `${spacing.s}px ${spacing.xl}px` + paddingLeft: spacing.l + }, + statusDot: { + marginRight: spacing.m }, // eslint-disable-next-line sort-keys '@global': { [`.${dark}`]: { - '& $wrapper': { + '& $mainContainer': { color: themedStyles[dark].base.color } } @@ -41,7 +44,7 @@ const DecoratedDot: FC = ({ status }: Props) => { const classes = useStyles() return ( -
+
{status}
@@ -55,10 +58,15 @@ const statuses = [ Status.DISABLED ] -export const All = () => ( - <> - {statuses.map((status: Status) => ( - - ))} - -) +export const All = () => { + const classes = useStyles() + + return ( +
+

Hover over colored dot to show tooltip.

+ {statuses.map((status: Status) => ( + + ))} +
+ ) +} diff --git a/src/components/IngestionStatusDot/IngestionStatusDot.test.tsx b/src/components/IngestionStatusDot/IngestionStatusDot.test.tsx index 581d7259..ac083e28 100644 --- a/src/components/IngestionStatusDot/IngestionStatusDot.test.tsx +++ b/src/components/IngestionStatusDot/IngestionStatusDot.test.tsx @@ -6,10 +6,18 @@ let wrapper: ReactWrapper describe('IngestionStatusDot', () => { beforeEach(() => { - wrapper = mount() + wrapper = mount() }) it('renders', () => { expect(wrapper).toHaveLength(1) }) + + it('has correct conditional classnames', () => { + expect(wrapper.find('span').hasClass(/hasIssues-*/)).toBeTruthy() + + wrapper = mount() + + expect(wrapper.find('span').hasClass(/needsConfig-*/)).toBeTruthy() + }) }) diff --git a/src/components/IngestionStatusDot/index.tsx b/src/components/IngestionStatusDot/index.tsx index be74f315..92829967 100644 --- a/src/components/IngestionStatusDot/index.tsx +++ b/src/components/IngestionStatusDot/index.tsx @@ -54,12 +54,12 @@ const useStyles = createUseStyles({ export interface IngestionStatusDotProps { classes?: string[] - status?: Status + status: Status } export const IngestionStatusDot: FC = ({ classes = [], - status = Status.OK + status }: IngestionStatusDotProps) => { const componentClasses = useStyles() From 409b8dd48dba38423edf81c08f7c9e9768f02d4d Mon Sep 17 00:00:00 2001 From: sam-m-m Date: Tue, 1 Dec 2020 18:27:48 -0800 Subject: [PATCH 5/8] feat #159 - Fix failing snapshots --- src/__snapshots__/storybook.test.ts.snap | 137 ++++++++++++----------- 1 file changed, 72 insertions(+), 65 deletions(-) diff --git a/src/__snapshots__/storybook.test.ts.snap b/src/__snapshots__/storybook.test.ts.snap index d5d3e187..4bf59b25 100644 --- a/src/__snapshots__/storybook.test.ts.snap +++ b/src/__snapshots__/storybook.test.ts.snap @@ -215,40 +215,47 @@ exports[`Storyshots IngestionStatusDot All 1`] = ` className="light storyWrapper-0-2-2" >
- - HAS_ISSUES -
-
- - NEEDS_CONFIG -
-
- - OK -
-
- - DISABLED +

+ Hover over colored dot to show tooltip. +

+
+ + HAS_ISSUES +
+
+ + NEEDS_CONFIG +
+
+ + OK +
+
+ + DISABLED +
`; @@ -258,7 +265,7 @@ exports[`Storyshots Input Default 1`] = ` className="light storyWrapper-0-2-2" >
  @@ -335,7 +342,7 @@ exports[`Storyshots Input Placeholder 1`] = ` className="light storyWrapper-0-2-2" >
 
 
  @@ -762,10 +769,10 @@ exports[`Storyshots Select Default 1`] = ` className="light storyWrapper-0-2-2" >
Lorem @@ -959,10 +966,10 @@ exports[`Storyshots Select Icon 1`] = ` className="light storyWrapper-0-2-2" >
  @@ -1180,27 +1187,27 @@ exports[`Storyshots Skeleton Count 1`] = ` className="light storyWrapper-0-2-2" >           @@ -1212,7 +1219,7 @@ exports[`Storyshots Skeleton Default 1`] = ` className="light storyWrapper-0-2-2" >   From 44feb41ca9175f574cf534d0043448894e6cab86 Mon Sep 17 00:00:00 2001 From: sam-m-m Date: Wed, 2 Dec 2020 17:56:04 -0800 Subject: [PATCH 6/8] feat #159 - Refactor IngestionStatusDot --> ColoredDot --- package-lock.json | 211 +++++++++++++++-- src/__mocks__/table_mock_data.ts | 40 ++-- src/__snapshots__/storybook.test.ts.snap | 221 ++++++++---------- .../ColoredDot/ColoredDot.stories.tsx | 56 +++++ src/components/ColoredDot/ColoredDot.test.tsx | 21 ++ src/components/ColoredDot/index.tsx | 58 +++++ .../IngestionStatusDot.stories.tsx | 72 ------ .../IngestionStatusDot.test.tsx | 23 -- src/components/IngestionStatusDot/index.tsx | 87 ------- src/components/Table/Table.stories.mdx | 2 +- src/components/Table/Table.stories.tsx | 12 +- src/components/Table/__tests__/Table.test.tsx | 5 +- .../Table/fixtures/4_sample_data.ts | 63 +++-- src/components/Table/types.ts | 13 +- src/components/Table/utils.tsx | 33 ++- src/components/index.ts | 2 +- 16 files changed, 524 insertions(+), 395 deletions(-) create mode 100644 src/components/ColoredDot/ColoredDot.stories.tsx create mode 100644 src/components/ColoredDot/ColoredDot.test.tsx create mode 100644 src/components/ColoredDot/index.tsx delete mode 100644 src/components/IngestionStatusDot/IngestionStatusDot.stories.tsx delete mode 100644 src/components/IngestionStatusDot/IngestionStatusDot.test.tsx delete mode 100644 src/components/IngestionStatusDot/index.tsx diff --git a/package-lock.json b/package-lock.json index 443148ae..866693e5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12486,6 +12486,19 @@ "@babel/runtime": "^7.3.1", "jss": "10.4.0", "jss-preset-default": "10.4.0" + }, + "dependencies": { + "jss": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/jss/-/jss-10.4.0.tgz", + "integrity": "sha512-l7EwdwhsDishXzqTc3lbsbyZ83tlUl5L/Hb16pHCvZliA9lRDdNBZmHzeJHP0sxqD0t1mrMmMR8XroR12JBYzw==", + "requires": { + "@babel/runtime": "^7.3.1", + "csstype": "^3.0.2", + "is-in-browser": "^1.1.3", + "tiny-warning": "^1.0.2" + } + } } }, "css-loader": { @@ -17912,24 +17925,6 @@ "verror": "1.10.0" } }, - "jss": { - "version": "10.4.0", - "resolved": "https://registry.npmjs.org/jss/-/jss-10.4.0.tgz", - "integrity": "sha512-l7EwdwhsDishXzqTc3lbsbyZ83tlUl5L/Hb16pHCvZliA9lRDdNBZmHzeJHP0sxqD0t1mrMmMR8XroR12JBYzw==", - "requires": { - "@babel/runtime": "^7.3.1", - "csstype": "^3.0.2", - "is-in-browser": "^1.1.3", - "tiny-warning": "^1.0.2" - }, - "dependencies": { - "csstype": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.2.tgz", - "integrity": "sha512-ofovWglpqoqbfLNOTBNZLSbMuGrblAf1efvvArGKOZMBrIoJeu5UsAipQolkijtyQx5MtAzT/J9IHj/CEY1mJw==" - } - } - }, "jss-plugin-camel-case": { "version": "10.4.0", "resolved": "https://registry.npmjs.org/jss-plugin-camel-case/-/jss-plugin-camel-case-10.4.0.tgz", @@ -17938,6 +17933,19 @@ "@babel/runtime": "^7.3.1", "hyphenate-style-name": "^1.0.3", "jss": "10.4.0" + }, + "dependencies": { + "jss": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/jss/-/jss-10.4.0.tgz", + "integrity": "sha512-l7EwdwhsDishXzqTc3lbsbyZ83tlUl5L/Hb16pHCvZliA9lRDdNBZmHzeJHP0sxqD0t1mrMmMR8XroR12JBYzw==", + "requires": { + "@babel/runtime": "^7.3.1", + "csstype": "^3.0.2", + "is-in-browser": "^1.1.3", + "tiny-warning": "^1.0.2" + } + } } }, "jss-plugin-compose": { @@ -17948,6 +17956,19 @@ "@babel/runtime": "^7.3.1", "jss": "10.4.0", "tiny-warning": "^1.0.2" + }, + "dependencies": { + "jss": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/jss/-/jss-10.4.0.tgz", + "integrity": "sha512-l7EwdwhsDishXzqTc3lbsbyZ83tlUl5L/Hb16pHCvZliA9lRDdNBZmHzeJHP0sxqD0t1mrMmMR8XroR12JBYzw==", + "requires": { + "@babel/runtime": "^7.3.1", + "csstype": "^3.0.2", + "is-in-browser": "^1.1.3", + "tiny-warning": "^1.0.2" + } + } } }, "jss-plugin-default-unit": { @@ -17957,6 +17978,19 @@ "requires": { "@babel/runtime": "^7.3.1", "jss": "10.4.0" + }, + "dependencies": { + "jss": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/jss/-/jss-10.4.0.tgz", + "integrity": "sha512-l7EwdwhsDishXzqTc3lbsbyZ83tlUl5L/Hb16pHCvZliA9lRDdNBZmHzeJHP0sxqD0t1mrMmMR8XroR12JBYzw==", + "requires": { + "@babel/runtime": "^7.3.1", + "csstype": "^3.0.2", + "is-in-browser": "^1.1.3", + "tiny-warning": "^1.0.2" + } + } } }, "jss-plugin-expand": { @@ -17966,6 +18000,19 @@ "requires": { "@babel/runtime": "^7.3.1", "jss": "10.4.0" + }, + "dependencies": { + "jss": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/jss/-/jss-10.4.0.tgz", + "integrity": "sha512-l7EwdwhsDishXzqTc3lbsbyZ83tlUl5L/Hb16pHCvZliA9lRDdNBZmHzeJHP0sxqD0t1mrMmMR8XroR12JBYzw==", + "requires": { + "@babel/runtime": "^7.3.1", + "csstype": "^3.0.2", + "is-in-browser": "^1.1.3", + "tiny-warning": "^1.0.2" + } + } } }, "jss-plugin-extend": { @@ -17976,6 +18023,19 @@ "@babel/runtime": "^7.3.1", "jss": "10.4.0", "tiny-warning": "^1.0.2" + }, + "dependencies": { + "jss": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/jss/-/jss-10.4.0.tgz", + "integrity": "sha512-l7EwdwhsDishXzqTc3lbsbyZ83tlUl5L/Hb16pHCvZliA9lRDdNBZmHzeJHP0sxqD0t1mrMmMR8XroR12JBYzw==", + "requires": { + "@babel/runtime": "^7.3.1", + "csstype": "^3.0.2", + "is-in-browser": "^1.1.3", + "tiny-warning": "^1.0.2" + } + } } }, "jss-plugin-global": { @@ -17985,6 +18045,19 @@ "requires": { "@babel/runtime": "^7.3.1", "jss": "10.4.0" + }, + "dependencies": { + "jss": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/jss/-/jss-10.4.0.tgz", + "integrity": "sha512-l7EwdwhsDishXzqTc3lbsbyZ83tlUl5L/Hb16pHCvZliA9lRDdNBZmHzeJHP0sxqD0t1mrMmMR8XroR12JBYzw==", + "requires": { + "@babel/runtime": "^7.3.1", + "csstype": "^3.0.2", + "is-in-browser": "^1.1.3", + "tiny-warning": "^1.0.2" + } + } } }, "jss-plugin-nested": { @@ -17995,6 +18068,19 @@ "@babel/runtime": "^7.3.1", "jss": "10.4.0", "tiny-warning": "^1.0.2" + }, + "dependencies": { + "jss": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/jss/-/jss-10.4.0.tgz", + "integrity": "sha512-l7EwdwhsDishXzqTc3lbsbyZ83tlUl5L/Hb16pHCvZliA9lRDdNBZmHzeJHP0sxqD0t1mrMmMR8XroR12JBYzw==", + "requires": { + "@babel/runtime": "^7.3.1", + "csstype": "^3.0.2", + "is-in-browser": "^1.1.3", + "tiny-warning": "^1.0.2" + } + } } }, "jss-plugin-props-sort": { @@ -18004,6 +18090,19 @@ "requires": { "@babel/runtime": "^7.3.1", "jss": "10.4.0" + }, + "dependencies": { + "jss": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/jss/-/jss-10.4.0.tgz", + "integrity": "sha512-l7EwdwhsDishXzqTc3lbsbyZ83tlUl5L/Hb16pHCvZliA9lRDdNBZmHzeJHP0sxqD0t1mrMmMR8XroR12JBYzw==", + "requires": { + "@babel/runtime": "^7.3.1", + "csstype": "^3.0.2", + "is-in-browser": "^1.1.3", + "tiny-warning": "^1.0.2" + } + } } }, "jss-plugin-rule-value-function": { @@ -18014,6 +18113,19 @@ "@babel/runtime": "^7.3.1", "jss": "10.4.0", "tiny-warning": "^1.0.2" + }, + "dependencies": { + "jss": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/jss/-/jss-10.4.0.tgz", + "integrity": "sha512-l7EwdwhsDishXzqTc3lbsbyZ83tlUl5L/Hb16pHCvZliA9lRDdNBZmHzeJHP0sxqD0t1mrMmMR8XroR12JBYzw==", + "requires": { + "@babel/runtime": "^7.3.1", + "csstype": "^3.0.2", + "is-in-browser": "^1.1.3", + "tiny-warning": "^1.0.2" + } + } } }, "jss-plugin-rule-value-observable": { @@ -18024,6 +18136,19 @@ "@babel/runtime": "^7.3.1", "jss": "10.4.0", "symbol-observable": "^1.2.0" + }, + "dependencies": { + "jss": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/jss/-/jss-10.4.0.tgz", + "integrity": "sha512-l7EwdwhsDishXzqTc3lbsbyZ83tlUl5L/Hb16pHCvZliA9lRDdNBZmHzeJHP0sxqD0t1mrMmMR8XroR12JBYzw==", + "requires": { + "@babel/runtime": "^7.3.1", + "csstype": "^3.0.2", + "is-in-browser": "^1.1.3", + "tiny-warning": "^1.0.2" + } + } } }, "jss-plugin-template": { @@ -18034,6 +18159,19 @@ "@babel/runtime": "^7.3.1", "jss": "10.4.0", "tiny-warning": "^1.0.2" + }, + "dependencies": { + "jss": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/jss/-/jss-10.4.0.tgz", + "integrity": "sha512-l7EwdwhsDishXzqTc3lbsbyZ83tlUl5L/Hb16pHCvZliA9lRDdNBZmHzeJHP0sxqD0t1mrMmMR8XroR12JBYzw==", + "requires": { + "@babel/runtime": "^7.3.1", + "csstype": "^3.0.2", + "is-in-browser": "^1.1.3", + "tiny-warning": "^1.0.2" + } + } } }, "jss-plugin-vendor-prefixer": { @@ -18044,6 +18182,19 @@ "@babel/runtime": "^7.3.1", "css-vendor": "^2.0.8", "jss": "10.4.0" + }, + "dependencies": { + "jss": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/jss/-/jss-10.4.0.tgz", + "integrity": "sha512-l7EwdwhsDishXzqTc3lbsbyZ83tlUl5L/Hb16pHCvZliA9lRDdNBZmHzeJHP0sxqD0t1mrMmMR8XroR12JBYzw==", + "requires": { + "@babel/runtime": "^7.3.1", + "csstype": "^3.0.2", + "is-in-browser": "^1.1.3", + "tiny-warning": "^1.0.2" + } + } } }, "jss-preset-default": { @@ -18065,6 +18216,19 @@ "jss-plugin-rule-value-observable": "10.4.0", "jss-plugin-template": "10.4.0", "jss-plugin-vendor-prefixer": "10.4.0" + }, + "dependencies": { + "jss": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/jss/-/jss-10.4.0.tgz", + "integrity": "sha512-l7EwdwhsDishXzqTc3lbsbyZ83tlUl5L/Hb16pHCvZliA9lRDdNBZmHzeJHP0sxqD0t1mrMmMR8XroR12JBYzw==", + "requires": { + "@babel/runtime": "^7.3.1", + "csstype": "^3.0.2", + "is-in-browser": "^1.1.3", + "tiny-warning": "^1.0.2" + } + } } }, "jsx-ast-utils": { @@ -25723,6 +25887,17 @@ "version": "0.7.1", "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.1.tgz", "integrity": "sha512-Qv4LTqO11jepd5Qmlp3M1YEjBumoTHcHFdgPTQ+sFlIL5myi/7xu/POwP7IRu6odBdmLXdtIs1D6TuW6kbwbbg==" + }, + "jss": { + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/jss/-/jss-10.4.0.tgz", + "integrity": "sha512-l7EwdwhsDishXzqTc3lbsbyZ83tlUl5L/Hb16pHCvZliA9lRDdNBZmHzeJHP0sxqD0t1mrMmMR8XroR12JBYzw==", + "requires": { + "@babel/runtime": "^7.3.1", + "csstype": "^3.0.2", + "is-in-browser": "^1.1.3", + "tiny-warning": "^1.0.2" + } } } }, diff --git a/src/__mocks__/table_mock_data.ts b/src/__mocks__/table_mock_data.ts index d30dc660..5128eac0 100644 --- a/src/__mocks__/table_mock_data.ts +++ b/src/__mocks__/table_mock_data.ts @@ -1,4 +1,4 @@ -import { Status } from 'components' +import { ThemeType } from 'components' import { ColumnFormats, ColumnType, @@ -7,24 +7,15 @@ import { } from '../components/Table' const { component, number, string } = ColumnTypes -const { - none, - byte, - date, - icon, - ingestionStatusDot, - link, - toggle, - tag -} = ColumnFormats +const { none, byte, date, icon, coloredDot, link, toggle, tag } = ColumnFormats export interface Data { byte: number date: number + dot: string icon: string - icon_key: string + iconKey: string id: number - ingestion_status: Status link: string number: number string: string @@ -84,7 +75,7 @@ const columns: ColumnType[] = [ type: component }, { - dataIndex: 'icon_key', + dataIndex: 'iconKey', format: icon, renderProps: { type: 'iconKey' @@ -105,9 +96,20 @@ const columns: ColumnType[] = [ type: component }, { - dataIndex: 'ingestion_status', - format: ingestionStatusDot, - title: 'Ingestion Status', + dataIndex: 'dot', + format: coloredDot, + renderProps: { + colorMap: { + test: { + colors: { + [ThemeType.light]: 'red', + [ThemeType.dark]: 'red' + }, + tooltipText: 'Hi I am colored' + } + } + }, + title: 'Colored Dot', type: component } ] @@ -116,10 +118,10 @@ const data: Data[] = [ { byte: 1024, date: 1599193037581, + dot: 'test', icon: 'test', - icon_key: 'dassana', + iconKey: 'dassana', id: 0, - ingestion_status: Status.OK, link: 'test', number: 0, string: 'Dassana', diff --git a/src/__snapshots__/storybook.test.ts.snap b/src/__snapshots__/storybook.test.ts.snap index 4bf59b25..d4234fba 100644 --- a/src/__snapshots__/storybook.test.ts.snap +++ b/src/__snapshots__/storybook.test.ts.snap @@ -2,7 +2,7 @@ exports[`Storyshots Avatar Default 1`] = `