Skip to content

Commit 4a89be9

Browse files
committed
feat: add spacing showcase
1 parent d365890 commit 4a89be9

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

styleguide/Spacings.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import React from 'react';
2+
import styled from 'styled-components';
3+
import { map } from 'lodash';
4+
5+
import Text from '../src/components/Text';
6+
import theme from '../src/theme';
7+
8+
const Row = styled.div`
9+
margin-bottom: ${props => props.theme.spacing.large};
10+
`;
11+
12+
const Block = styled.span`
13+
display: block;
14+
margin-right: ${props => props.theme.spacing.base};
15+
margin-bottom: ${props => props.theme.spacing.medium};
16+
`;
17+
18+
const SpacingElement = styled.div`
19+
background-color: ${props => props.theme.colors.blue400};
20+
`;
21+
22+
const SizeLabel = styled.div`
23+
color: ${props => props.theme.colors.gray600};
24+
font-size: ${props => props.theme.fontSizes.normal};
25+
margin-top: ${props => props.theme.spacing.xs};
26+
`;
27+
28+
const curly = start => (start ? '{' : '}');
29+
30+
class Spacings extends React.Component {
31+
render() {
32+
return (
33+
<div>
34+
<Row>
35+
<Text extraLarge>Spacing</Text>
36+
</Row>
37+
<Row>
38+
<pre>
39+
const MyButton = styled.button`
40+
<br />
41+
&nbsp; padding: ${curly(true)}props =&gt; props.theme.spacing.small
42+
{curly(false)};
43+
<br />
44+
`;
45+
</pre>
46+
</Row>
47+
<Row>
48+
{map(theme.spacing, (value, name) => (
49+
<Block key={name}>
50+
<SpacingElement style={{ width: value, height: value }} />
51+
<SizeLabel>{value}</SizeLabel>
52+
theme.spacing.<b>{name}</b>
53+
</Block>
54+
))}
55+
</Row>
56+
</div>
57+
);
58+
}
59+
}
60+
61+
export default Spacings;

0 commit comments

Comments
 (0)