Skip to content

Commit

Permalink
feat: add spacing showcase
Browse files Browse the repository at this point in the history
  • Loading branch information
bia committed Dec 17, 2018
1 parent d365890 commit 4a89be9
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions styleguide/Spacings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React from 'react';
import styled from 'styled-components';
import { map } from 'lodash';

import Text from '../src/components/Text';
import theme from '../src/theme';

const Row = styled.div`
margin-bottom: ${props => props.theme.spacing.large};
`;

const Block = styled.span`
display: block;
margin-right: ${props => props.theme.spacing.base};
margin-bottom: ${props => props.theme.spacing.medium};
`;

const SpacingElement = styled.div`
background-color: ${props => props.theme.colors.blue400};
`;

const SizeLabel = styled.div`
color: ${props => props.theme.colors.gray600};
font-size: ${props => props.theme.fontSizes.normal};
margin-top: ${props => props.theme.spacing.xs};
`;

const curly = start => (start ? '{' : '}');

class Spacings extends React.Component {
render() {
return (
<div>
<Row>
<Text extraLarge>Spacing</Text>
</Row>
<Row>
<pre>
const MyButton = styled.button`
<br />
&nbsp; padding: ${curly(true)}props =&gt; props.theme.spacing.small
{curly(false)};
<br />
`;
</pre>
</Row>
<Row>
{map(theme.spacing, (value, name) => (
<Block key={name}>
<SpacingElement style={{ width: value, height: value }} />
<SizeLabel>{value}</SizeLabel>
theme.spacing.<b>{name}</b>
</Block>
))}
</Row>
</div>
);
}
}

export default Spacings;

0 comments on commit 4a89be9

Please sign in to comment.