This repository was archived by the owner on Aug 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathIcon.css.js
More file actions
137 lines (116 loc) · 2.38 KB
/
Icon.css.js
File metadata and controls
137 lines (116 loc) · 2.38 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import { BEM } from '../../utilities/classNames'
import { STATES, TEXT_SHADES } from '../../styles/configs/constants'
import { getColor } from '../../styles/utilities/color'
import forEach from '../../styles/utilities/forEach'
import styled from 'styled-components'
const bem = BEM('.c-Icon')
const ICON_SIZES = [8, 10, 12, 13, 14, 15, 16, 18, 20, 24, 32, 48, 52, 72]
export const config = {
caretSize: 13,
marginOffset: 4,
offsetRight: '6px',
offsetTop: '1px',
size: 20,
}
export const IconUI = styled.span`
color: currentColor;
display: block;
height: ${config.size}px;
position: relative;
width: ${config.size}px;
&.is-center {
margin-left: auto;
margin-right: auto;
}
&.is-clickable {
cursor: pointer;
}
&.is-inline {
display: inline-block;
}
&.is-noInteract {
pointer-events: none;
}
&.is-offsetLeft {
margin-right: ${config.marginOffset}px;
}
&.is-offsetRight {
margin-left: ${config.marginOffset}px;
}
${makeShadeStyles()};
${makeSizeStyles()};
${makeStateColorStyles()};
&.withCaret {
${bem.element('icon')} {
width: calc(100% - (${config.caretSize}px - ${config.offsetRight}));
}
}
${bem.element('icon')} {
color: currentColor;
display: block;
height: 100%;
pointer-events: none;
svg {
display: block;
height: 100%;
max-width: 100%;
width: 100%;
}
circle[fill],
path,
rect[fill] {
fill: currentColor;
}
path[stroke] {
fill: none;
}
circle[stroke],
path[stroke],
rect[stroke] {
stroke: currentColor;
}
&.is-caret {
height: ${config.caretSize}px;
position: absolute;
right: 0;
top: calc(
50% - ${Math.round(config.caretSize / 2)}px + ${config.offsetTop}
);
width: ${config.caretSize}px;
}
}
`
function makeShadeStyles() {
return forEach(
TEXT_SHADES,
shade => `
&.is-${shade} {
color: ${getColor('text', shade)};
}
`
)
}
function makeSizeStyles() {
return forEach(
ICON_SIZES,
size => `
&.is-${size} {
height: ${size}px;
width: ${size}px;
&.withCaret {
width: ${size + config.caretSize}px;
}
}
`
)
}
function makeStateColorStyles() {
return forEach(
STATES,
state => `
&.is-${state} {
color: ${getColor('state', state, 'default')};
}
`
)
}