Skip to content

Commit

Permalink
feat(native/theme): Add stories for native theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Kashish Grover committed Feb 12, 2019
1 parent a181610 commit 13f0d40
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 59 deletions.
49 changes: 49 additions & 0 deletions src/theme/makeStories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';
import theme from '../theme/web';

export default (storiesOf, { Flex, View, Space, Size, Card, Text }) =>
storiesOf('Theme', module)
.add('colors', () => (
<Flex flexDirection="row" flexWrap="wrap">
<View>
{
Object.keys(theme.color).map((color) => (
<Flex
key={color}
flexBasis="25%"
alignItems="center"
justifyContent="center"
>
<Space margin={[0, 0, 2, 0]}>
<Size height={10}>
<Card backgroundColor={color} shape="sharpEdged">
<Card shape="sharpEdged" backgroundColor="greyLighter">
<Text size="xxs">
{`${color}\n${theme.color[color]}`}
</Text>
</Card>
</Card>
</Size>
</Space>
</Flex>
))
}
</View>
</Flex>
))
.add('spacing', () => (
<View>
{
[1, 2, 3, 4, 5, 6, 7, 8].map((space) => (
<View>
<Text size="xs">{space * 8}</Text>
<Space key={space} margin={[0, 0, 2, 0]}>
<Size height={space} width={space}>
<Card borderColor="red" borderStyle="dashed" />
</Size>
</Space>
</View>
))
}
</View>
));
17 changes: 17 additions & 0 deletions src/theme/native/theme.story.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { storiesOf } from '@storybook/react-native';
import Flex from '../../Flex/native';
import Space from '../../Space/native';
import Size from '../../Size/native';
import View from '../../View/native';
import Text from '../../Text/native';
import Card from '../../Card/native';
import makeStories from '../makeStories';

makeStories(storiesOf, {
Flex,
Space,
Size,
View,
Text,
Card,
});
69 changes: 10 additions & 59 deletions src/theme/web/theme.story.js
Original file line number Diff line number Diff line change
@@ -1,66 +1,17 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import theme from './theme';
import Flex from '../../Flex/web';
import Space from '../../Space/web';
import Size from '../../Size/web';
import View from '../../View/web';
import Text from '../../Text/web';
import Card from '../../Card/web';
import makeStories from '../makeStories';

storiesOf('Theme', module)
.add('colors', () => (
<Flex
flexDirection="row"
flexWrap="wrap"
>
<View>
{
Object.keys(theme.color).map((color) => (
<Flex
key={color}
flexBasis="25%"
alignItems="center"
justifyContent="center"
>
<Space margin={[0, 0, 2, 0]}>
<Size height={10}>
<Card
backgroundColor={color}
elevated
>
{color}
<br />
{theme.color[color]}
</Card>
</Size>
</Space>
</Flex>
))
}
</View>
</Flex>
))
.add('spacing', () => (
<View>
{
[1, 2, 3, 4, 5, 6, 7, 8].map((space) => (
<Space
key={space}
margin={[0, 0, 2, 0]}
>
<Size
height={space}
width={space}
>
<Card
borderColor="red"
borderStyle="dashed"
>
{space * 8}
</Card>
</Size>
</Space>
))
}
</View>
));
makeStories(storiesOf, {
Flex,
Space,
Size,
View,
Text,
Card,
});
1 change: 1 addition & 0 deletions storybook/native/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const loadStories = () => {
require('../../src/Button/native/Button.story');
require('../../src/Text/native/Text.story');
require('../../src/Tag/native/Tag.story');
require('../../src/theme/native/theme.story');
};

const StorybookUI = getStorybookUI();
Expand Down

0 comments on commit 13f0d40

Please sign in to comment.