Skip to content

Commit

Permalink
feat(Indicator): adds Indicator component
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Firsov committed Apr 3, 2019
1 parent 4a859ad commit 63f73e0
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions e2e/__tests__/indicator.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { baisy } from '../setup/TestSuiter';

const SUITES = [
baisy.suite('Components/Indicator', 'common'),
];

SUITES.map(suite => {
it(suite.getTestName(), suite.testStory, 20000);
});

28 changes: 28 additions & 0 deletions src/components/Indicator/Indicator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// @flow

import React from 'react';

import { IndicatorContainerTag, IndicatorTag } from './Indicator.theme';
import { Text } from '../Text';

type IndicatorProps = {
status: 'enabled' | 'disabled',
children: React$Node,
};

const Indicator = ({ children, status }: IndicatorProps) => (
<IndicatorContainerTag tagName="span">
<IndicatorTag tagName="span" status={ status } />
<Text>
{ children }
</Text>
</IndicatorContainerTag>
);

Indicator.defaultProps = {
status: 'disabled',
};

export { Indicator };


20 changes: 20 additions & 0 deletions src/components/Indicator/Indicator.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// @flow

import React from 'react';

export default (asStory: *) => {
asStory(
'Components/Indicator',
module,
(story, { Indicator, Column }) => {
story
.add('common', () => (
<Column>
<Indicator>Disabled</Indicator>
<Indicator status="enabled">Enabled</Indicator>
</Column>
));
},
);
};

46 changes: 46 additions & 0 deletions src/components/Indicator/Indicator.theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// @flow

import { createThemeTag } from '../../theme/createThemeTag';

const name = 'indicator';

const [IndicatorContainerTag, themeContainer] = createThemeTag(
`${name}Container`,
() => ({
root: {
display: 'flex',
alignItems: 'center',
},
}),
);

const [IndicatorTag, themeIndicator] = createThemeTag(
name,
({ COLORS }) => ({
root: {
width: '12px',
height: '12px',
borderRadius: '50%',
marginRight: '8px',
},

modifiers: {
status: {
enabled: { backgroundColor: COLORS.GREEN },
disabled: { backgroundColor: COLORS.LIGHT_GRAY1 },
},
},
}),
);

const theme = {
...themeContainer,
...themeIndicator,
};

export {
IndicatorContainerTag,
IndicatorTag,
theme,
};

5 changes: 5 additions & 0 deletions src/components/Indicator/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @flow

export { Indicator } from './Indicator';
export { theme } from './Indicator.theme';

1 change: 1 addition & 0 deletions src/components/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ export { TreeSelectField } from './TreeSelectField';
export { Tooltip } from './Tooltip';
export { NoData } from './NoData';
export { Pagination } from './Pagination';
export { Indicator } from './Indicator';

2 changes: 2 additions & 0 deletions src/components/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { theme as menuTheme } from './Menu';
import { theme as dateInputTheme } from './DateInput';
import { theme as noDataTheme } from './NoData';
import { theme as paginationTheme } from './Pagination';
import { theme as indicatorTheme } from './Indicator';


export const theme = {
Expand Down Expand Up @@ -79,4 +80,5 @@ export const theme = {
...dateInputTheme,
...noDataTheme,
...paginationTheme,
...indicatorTheme,
};

0 comments on commit 63f73e0

Please sign in to comment.