blob: b337a6e58c1df726208becf99405bf8102c27561 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
import * as React from 'react';
import styled from 'styled-components';
interface WrapWidths {
default: string;
full: string;
medium: string;
narrow: string;
[key: string]: string;
}
interface ColumnWidths {
[key: string]: string;
}
interface SectionProps {
noPadding?: any;
bgColor?: string;
}
interface WrapProps {
width?: 'default' | 'full' | 'medium' | 'narrow';
bgColor?: string;
}
interface ColumnProps {
colWidth?: '1/4' | '1/3' | '1/2' | '2/3';
}
const GUTTER = 30 as number;
const WRAPPER_WIDTHS: WrapWidths = {
default: '1500px', // dunno
full: '100%',
medium: '1136px',
narrow: '930px',
};
const COLUMN_WIDTHS: ColumnWidths = {
'1/4': `calc(${(1 / 4) * 100}% - ${(GUTTER * 3) / 4}px)`,
'1/3': `calc(${(1 / 3) * 100}% - ${(GUTTER * 2) / 3}px)`,
'1/2': `calc(${(1 / 2) * 100}% - ${GUTTER / 2}px)`,
'2/3': `calc(${(2 / 3) * 100}% - ${GUTTER / 2}px)`,
};
export const Section = styled.section<SectionProps>`
width: 100%;
padding: ${props => !props.noPadding && '30px'};
margin-bottom: 30px;
background-color: ${props => props.bgColor};
border: 1px solid blue;
`;
export const Wrap = styled.div<WrapProps>`
max-width: ${props => WRAPPER_WIDTHS[props.width || 'default']};
background-color: ${props => props.bgColor};
margin: 0 auto;
border: 1px solid green;
display: flex;
justify-content: space-between;
`;
export const Column = styled.div<ColumnProps>`
width: ${props => props.colWidth ? COLUMN_WIDTHS[props.colWidth] : '100%'};
padding: 30px;
border: 1px solid yellow;
`;
|