|
| 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 | + padding: ${curly(true)}props => 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