-
Notifications
You must be signed in to change notification settings - Fork 11
/
Box.styles.js
83 lines (79 loc) · 2.82 KB
/
Box.styles.js
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import styled, { css } from 'react-emotion';
import creacteDynamicTag from '@lskjs/utils/createDynamicTag';
import removeProps from '@lskjs/utils/removeProps';
import getTheme from '@lskjs/theme/getTheme';
const dynamicTag = creacteDynamicTag('div');
const filteredTag = removeProps(dynamicTag, ['padded', 'paint']);
const paintColors = (p) => {
switch (p.paint) {
case 'light':
return css`
background-color: ${getTheme(p.theme, 'colors.lightGray')};
color: ${getTheme(p.theme, 'colors.main')};`;
case 'dark':
return css`
background-color: ${getTheme(p.theme, 'colors.black')};
color: ${getTheme(p.theme, 'colors.white')};`;
case 'primary':
return css`
background-color: ${getTheme(p.theme, 'colors.primary')};
color: ${getTheme(p.theme, 'colors.white')};`;
case 'info':
return css`
background-color: ${getTheme(p.theme, 'colors.info')};
color: ${getTheme(p.theme, 'colors.white')};`;
case 'success':
return css`
background-color: ${getTheme(p.theme, 'colors.success')};
color: ${getTheme(p.theme, 'colors.white')};`;
case 'warning':
return css`
background-color: ${getTheme(p.theme, 'colors.warning')};
color: ${getTheme(p.theme, 'colors.main')};`;
case 'danger':
return css`
background-color: ${getTheme(p.theme, 'colors.danger')};
color: ${getTheme(p.theme, 'colors.white')};`;
case 'nobackground':
return css`
background-color: transparent;
color: ${getTheme(p.theme, 'colors.main')}; `;
case 'transparent':
return css`
background-color: transparent;
color: ${getTheme(p.theme, 'colors.main')};
border: 1px solid transparent; `;
default:
return css`
background-color: ${getTheme(p.theme, 'colors.white')};
color: ${getTheme(p.theme, 'colors.main')}; `;
}
};
export default styled(filteredTag)`
overflow: hidden;
position: relative;
display: flex;
flex-direction: column;
font-family: ${p => getTheme(p.theme, 'fontFamily')};
border-radius: ${p => getTheme(p.theme, 'borderRadius')};
border: 1px solid ${p => getTheme(p.theme, 'colors.border')};
${p => (p.padded && css`
padding: 1.625rem;
line-height: 1.85em;
background-color: ${getTheme(p.theme, 'colors.white')};
`)}
${paintColors}
> div:first-child {
border-radius: ${p => getTheme(p.theme, 'borderRadius')} ${p => getTheme(p.theme, 'borderRadius')} 0 0;
}
> div:last-child {
border-radius: 0 0 ${p => getTheme(p.theme, 'borderRadius')} ${p => getTheme(p.theme, 'borderRadius')};
}
${p => (p.image && css`
background-image: ${`url(${p.image})`};
background-position: center;
background-repeat: no-repeat;
background-size: cover;
border-radius: ${getTheme(p.theme, 'borderRadius')}
`)}
`;