Skip to content

Commit 13f0d40

Browse files
author
Kashish Grover
committed
feat(native/theme): Add stories for native theme
1 parent a181610 commit 13f0d40

File tree

4 files changed

+77
-59
lines changed

4 files changed

+77
-59
lines changed

src/theme/makeStories.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import React from 'react';
2+
import theme from '../theme/web';
3+
4+
export default (storiesOf, { Flex, View, Space, Size, Card, Text }) =>
5+
storiesOf('Theme', module)
6+
.add('colors', () => (
7+
<Flex flexDirection="row" flexWrap="wrap">
8+
<View>
9+
{
10+
Object.keys(theme.color).map((color) => (
11+
<Flex
12+
key={color}
13+
flexBasis="25%"
14+
alignItems="center"
15+
justifyContent="center"
16+
>
17+
<Space margin={[0, 0, 2, 0]}>
18+
<Size height={10}>
19+
<Card backgroundColor={color} shape="sharpEdged">
20+
<Card shape="sharpEdged" backgroundColor="greyLighter">
21+
<Text size="xxs">
22+
{`${color}\n${theme.color[color]}`}
23+
</Text>
24+
</Card>
25+
</Card>
26+
</Size>
27+
</Space>
28+
</Flex>
29+
))
30+
}
31+
</View>
32+
</Flex>
33+
))
34+
.add('spacing', () => (
35+
<View>
36+
{
37+
[1, 2, 3, 4, 5, 6, 7, 8].map((space) => (
38+
<View>
39+
<Text size="xs">{space * 8}</Text>
40+
<Space key={space} margin={[0, 0, 2, 0]}>
41+
<Size height={space} width={space}>
42+
<Card borderColor="red" borderStyle="dashed" />
43+
</Size>
44+
</Space>
45+
</View>
46+
))
47+
}
48+
</View>
49+
));

src/theme/native/theme.story.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { storiesOf } from '@storybook/react-native';
2+
import Flex from '../../Flex/native';
3+
import Space from '../../Space/native';
4+
import Size from '../../Size/native';
5+
import View from '../../View/native';
6+
import Text from '../../Text/native';
7+
import Card from '../../Card/native';
8+
import makeStories from '../makeStories';
9+
10+
makeStories(storiesOf, {
11+
Flex,
12+
Space,
13+
Size,
14+
View,
15+
Text,
16+
Card,
17+
});

src/theme/web/theme.story.js

Lines changed: 10 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,17 @@
1-
import React from 'react';
21
import { storiesOf } from '@storybook/react';
3-
import theme from './theme';
42
import Flex from '../../Flex/web';
53
import Space from '../../Space/web';
64
import Size from '../../Size/web';
75
import View from '../../View/web';
6+
import Text from '../../Text/web';
87
import Card from '../../Card/web';
8+
import makeStories from '../makeStories';
99

10-
storiesOf('Theme', module)
11-
.add('colors', () => (
12-
<Flex
13-
flexDirection="row"
14-
flexWrap="wrap"
15-
>
16-
<View>
17-
{
18-
Object.keys(theme.color).map((color) => (
19-
<Flex
20-
key={color}
21-
flexBasis="25%"
22-
alignItems="center"
23-
justifyContent="center"
24-
>
25-
<Space margin={[0, 0, 2, 0]}>
26-
<Size height={10}>
27-
<Card
28-
backgroundColor={color}
29-
elevated
30-
>
31-
{color}
32-
<br />
33-
{theme.color[color]}
34-
</Card>
35-
</Size>
36-
</Space>
37-
</Flex>
38-
))
39-
}
40-
</View>
41-
</Flex>
42-
))
43-
.add('spacing', () => (
44-
<View>
45-
{
46-
[1, 2, 3, 4, 5, 6, 7, 8].map((space) => (
47-
<Space
48-
key={space}
49-
margin={[0, 0, 2, 0]}
50-
>
51-
<Size
52-
height={space}
53-
width={space}
54-
>
55-
<Card
56-
borderColor="red"
57-
borderStyle="dashed"
58-
>
59-
{space * 8}
60-
</Card>
61-
</Size>
62-
</Space>
63-
))
64-
}
65-
</View>
66-
));
10+
makeStories(storiesOf, {
11+
Flex,
12+
Space,
13+
Size,
14+
View,
15+
Text,
16+
Card,
17+
});

storybook/native/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const loadStories = () => {
1313
require('../../src/Button/native/Button.story');
1414
require('../../src/Text/native/Text.story');
1515
require('../../src/Tag/native/Tag.story');
16+
require('../../src/theme/native/theme.story');
1617
};
1718

1819
const StorybookUI = getStorybookUI();

0 commit comments

Comments
 (0)