-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.ts
61 lines (50 loc) · 1.24 KB
/
index.ts
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
import styled from '@emotion/styled'
const justifyMap = {
start: 'flex-start',
end: 'flex-end',
'space-between': 'space-between',
'space-around': 'space-around',
center: 'center',
'space-evenly': 'space-evenly',
}
const alignMap = {
start: 'flex-start',
end: 'flex-end',
center: 'center',
baseline: 'baseline',
stretch: 'stretch',
}
const justifyContent = ({ justify = 'center' }: { justify: Justify }) =>
justifyMap[justify]
const alignItems = ({ align = 'center' }: { align: Align }) => alignMap[align]
type Justify =
| 'start'
| 'end'
| 'center'
| 'space-between'
| 'space-around'
| 'space-evenly'
type Align = 'start' | 'end' | 'center' | 'baseline' | 'stretch'
export interface Props {
wrap: boolean
grow: boolean
inline: boolean
justify: Justify
align: Align
}
const Box = styled('div')<Props>`
display: flex;
justify-content: ${justifyContent};
align-items: ${alignItems};
flex-wrap: ${props => (props.wrap ? 'wrap' : 'no-wrap')};
flex-grow: ${props => (props.grow ? 1 : 0)};
width: ${props => (props.inline ? 'auto' : '100%')};
position: relative;
`
export const Row = styled(Box)`
flex-direction: row;
`
export const Column = styled(Box)`
flex-direction: column;
`
export default Box