@jsb188/css 1.0.4 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/_colors.generated.css +530 -0
- package/css/_global.css +2669 -560
- package/css/_responsive.css +8085 -0
- package/css/_responsive.generated.css +13983 -0
- package/css/_sizing.css +1680 -393
- package/css/alert.css +88 -37
- package/css/animate.css +734 -0
- package/css/form.css +517 -236
- package/css/layout.css +375 -78
- package/css/loading.css +127 -118
- package/css/misc.css +3 -75
- package/css/modal.css +41 -176
- package/css/popover.css +74 -247
- package/package.json +23 -20
- package/scripts/generateResponsiveCss.js +274 -0
- package/css/list.css +0 -292
package/css/popover.css
CHANGED
|
@@ -1,302 +1,129 @@
|
|
|
1
|
-
|
|
2
1
|
/* Pop overs */
|
|
3
2
|
|
|
4
3
|
.popover {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
position: fixed;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
align-items: flex-start;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
.popover .tooltip {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
box-shadow: var(--shadow);
|
|
17
|
-
/* box-shadow: var(--shadow-float-light); */
|
|
11
|
+
display: inline-block;
|
|
12
|
+
padding: 0.58rem 0.64rem;
|
|
13
|
+
/* box-shadow: var(--shadow-light); */
|
|
14
|
+
box-shadow: var(--shadow);
|
|
18
15
|
}
|
|
19
16
|
|
|
20
|
-
.popover.small .tooltip {
|
|
21
|
-
|
|
17
|
+
.popover.small .tooltip:not(.w_override) {
|
|
18
|
+
max-width: 150px;
|
|
22
19
|
}
|
|
23
20
|
|
|
24
|
-
.popover.default .tooltip {
|
|
25
|
-
|
|
21
|
+
.popover.default .tooltip:not(.w_override) {
|
|
22
|
+
max-width: 200px;
|
|
26
23
|
}
|
|
27
24
|
|
|
28
|
-
/* Pop over;
|
|
25
|
+
/* Pop over; list */
|
|
29
26
|
|
|
30
|
-
.
|
|
31
|
-
|
|
32
|
-
justify-content: flex-start;
|
|
33
|
-
align-items: stretch;
|
|
34
|
-
padding: .25rem .25rem;
|
|
35
|
-
max-width: 225px;
|
|
27
|
+
.po_list {
|
|
28
|
+
border-radius: 6px;
|
|
36
29
|
}
|
|
37
30
|
|
|
38
|
-
.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
.po_list .inside {
|
|
32
|
+
/* padding: 5px; */
|
|
33
|
+
padding: 5px;
|
|
34
|
+
display: flex;
|
|
35
|
+
flex-direction: column;
|
|
36
|
+
justify-content: flex-start;
|
|
37
|
+
align-items: stretch;
|
|
42
38
|
}
|
|
43
39
|
|
|
44
|
-
.
|
|
45
|
-
|
|
46
|
-
transform: translateX(-7px);
|
|
40
|
+
.po_list.bg a:hover {
|
|
41
|
+
background-color: var(--color-darker-light);
|
|
47
42
|
}
|
|
48
43
|
|
|
49
|
-
.
|
|
50
|
-
|
|
51
|
-
padding: .25rem 0 .25rem .64rem;
|
|
52
|
-
white-space: nowrap;
|
|
44
|
+
.po_list .av_item .av.main {
|
|
45
|
+
box-shadow: 0 0 10px rgb(var(--color-bg));
|
|
53
46
|
}
|
|
54
47
|
|
|
55
|
-
|
|
56
|
-
border-radius: 4px;
|
|
57
|
-
}
|
|
48
|
+
/* Pop over; subtitle */
|
|
58
49
|
|
|
59
|
-
.
|
|
60
|
-
|
|
50
|
+
.po_subtitle {
|
|
51
|
+
position: sticky;
|
|
52
|
+
top: 0;
|
|
53
|
+
left: 0;
|
|
54
|
+
right: 0;
|
|
55
|
+
padding: 5px 0.4rem 8px;
|
|
56
|
+
margin-bottom: 0.3rem;
|
|
57
|
+
box-shadow:
|
|
58
|
+
0 -5px 0 rgb(var(--color-bg)),
|
|
59
|
+
0 0 7px rgb(var(--color-bg));
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
content: ' ';
|
|
65
|
-
position: absolute;
|
|
66
|
-
left: 0; right: 0;
|
|
67
|
-
height: 1px;
|
|
68
|
-
}
|
|
62
|
+
/* Pop over; list item */
|
|
69
63
|
|
|
70
|
-
.
|
|
71
|
-
|
|
64
|
+
.po_opt .saving_area {
|
|
65
|
+
width: 24px;
|
|
66
|
+
transform: translateX(-4px);
|
|
72
67
|
}
|
|
73
68
|
|
|
74
|
-
.
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
.po_opt {
|
|
70
|
+
padding: 5px 0 5px 0.4375rem;
|
|
71
|
+
border-radius: 5px;
|
|
77
72
|
}
|
|
78
73
|
|
|
79
|
-
.
|
|
80
|
-
|
|
81
|
-
background-color: var(--color-text-light);
|
|
74
|
+
.po_opt.default:first-child {
|
|
75
|
+
margin-top: 5px;
|
|
82
76
|
}
|
|
83
77
|
|
|
84
|
-
.
|
|
85
|
-
|
|
78
|
+
.po_opt.default:last-child {
|
|
79
|
+
margin-bottom: 5px;
|
|
86
80
|
}
|
|
87
81
|
|
|
88
|
-
|
|
89
|
-
color: var(--color-text);
|
|
90
|
-
}
|
|
82
|
+
/* Pop over; text item */
|
|
91
83
|
|
|
92
|
-
.
|
|
93
|
-
|
|
84
|
+
.po_opt.text_item {
|
|
85
|
+
padding: 5px 0.4375rem;
|
|
86
|
+
margin-bottom: 0;
|
|
94
87
|
}
|
|
95
88
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
89
|
+
/* Pop over; different presets for list item */
|
|
90
|
+
|
|
91
|
+
.po_opt.av_item {
|
|
92
|
+
padding-top: 0.5rem;
|
|
93
|
+
padding-bottom: 0.5rem;
|
|
100
94
|
}
|
|
101
95
|
|
|
102
|
-
.po_opt.
|
|
103
|
-
|
|
104
|
-
padding-bottom: .4rem;
|
|
105
|
-
margin-bottom: .25rem;
|
|
96
|
+
.po_opt.preset_small {
|
|
97
|
+
padding: 0.5rem 0 0.5rem 0.4375rem;
|
|
106
98
|
}
|
|
107
99
|
|
|
108
|
-
|
|
109
|
-
|
|
100
|
+
/* Pop over; list break */
|
|
101
|
+
|
|
102
|
+
.po_list_break {
|
|
103
|
+
margin: 4px 0;
|
|
104
|
+
border-top: solid 1px var(--color-darker-light);
|
|
110
105
|
}
|
|
111
106
|
|
|
112
107
|
/* Pop over container */
|
|
113
108
|
|
|
114
109
|
.po_container {
|
|
115
|
-
|
|
116
|
-
|
|
110
|
+
/* padding: 4px; */
|
|
111
|
+
box-shadow: var(--shadow-light);
|
|
117
112
|
}
|
|
118
113
|
|
|
119
114
|
.po_container .inside {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
width: 300px;
|
|
124
|
-
min-height: 200px;
|
|
125
|
-
/* max-height: calc(100vh - 20px); */
|
|
126
|
-
max-height: 70vh;
|
|
127
|
-
/* background: var(--color-highlight) linear-gradient(180deg, var(--color-highlight-alt), var(--color-highlight)) fixed; */
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/* Profile; header */
|
|
131
|
-
|
|
132
|
-
.pf_header_area {
|
|
133
|
-
width: 100%;
|
|
134
|
-
padding: 30% 0 0;
|
|
135
|
-
object-fit: cover;
|
|
136
|
-
background-color: var(--color-darker-light);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.pf_header_area.with_img {
|
|
140
|
-
padding: 40% 0 0;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.pf_header_content.medium {
|
|
144
|
-
margin-top: -40px;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
.pf_header_content.large {
|
|
148
|
-
margin-top: -70px;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.pf_header_content .mpf_shadow {
|
|
152
|
-
box-shadow: 0 0 0 5px var(--color-primary);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.pf_header_content .ib_label {
|
|
156
|
-
transform: translateY(3px);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
.pf_header_content .ib_label .icon {
|
|
160
|
-
display: inline-block;
|
|
161
|
-
font-size: 1.6rem;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
.pf_friend_status_dropdown {
|
|
165
|
-
position: absolute;
|
|
166
|
-
top: 94px;
|
|
167
|
-
left: 100%;
|
|
168
|
-
transform: translateX(-7px);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
.pf_friend_status_dropdown.has_bg {
|
|
172
|
-
top: 123px;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
.pf_content_area {
|
|
176
|
-
padding: 1rem 0;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/* .pf_header_content .mpf_shadow:before {
|
|
180
|
-
content: ' ';
|
|
181
|
-
position: absolute;
|
|
182
|
-
left: -5px; top: 0; right: -5px; bottom: -10px;
|
|
183
|
-
border-radius: 50%;
|
|
184
|
-
background: radial-gradient(rgba(0,0,0,1), rgba(0,0,0,0));
|
|
185
|
-
box-shadow: 0 0 10px rgba(0,0,0,.5);
|
|
186
|
-
} */
|
|
187
|
-
|
|
188
|
-
/* Mini profile buttons */
|
|
189
|
-
|
|
190
|
-
.mpf_btns_cnt {
|
|
191
|
-
display: grid;
|
|
192
|
-
column-gap: .5rem;
|
|
193
|
-
border-top: .1875em dashed var(--color-darker-light);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
.pf_header_content {
|
|
197
|
-
border-bottom: .1875em dashed var(--color-darker-light);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
.mpf_btns_cnt.size-1 {
|
|
201
|
-
grid-template-columns: repeat(1, 1fr);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
.mpf_btns_cnt.size-2 {
|
|
205
|
-
grid-template-columns: repeat(2, 1fr);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
.mpf_btn {
|
|
209
|
-
align-self: stretch;
|
|
210
|
-
padding: 6px 4px 7px 6px;
|
|
211
|
-
background-color: var(--color-darker-light);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
.mpf_btn:not(:first-child) {
|
|
215
|
-
margin-left: 5px;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
.mpf_btn.icon_only {
|
|
219
|
-
align-items: center;
|
|
220
|
-
padding-left: 4px;
|
|
221
|
-
padding-right: 4px;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
.mpf_btn svg:first-child {
|
|
225
|
-
margin-right: 3px;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
.mpf_btn svg:last-child {
|
|
229
|
-
margin-left: 3px;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
button.mpf_btn:hover, a.mpf_btn:hover {
|
|
233
|
-
background-color: var(--color-darker-default);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/* Card item */
|
|
237
|
-
|
|
238
|
-
.crd_item {
|
|
239
|
-
margin-top: 4px;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/* Card header */
|
|
243
|
-
|
|
244
|
-
.crd_header {
|
|
245
|
-
/* padding: 0; */
|
|
246
|
-
background-color: var(--color-darker-light);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
.crd_header[role="button"] {
|
|
250
|
-
cursor: pointer;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
.crd_header .av.main {
|
|
254
|
-
transform: scale(.8);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
.crd_header .text {
|
|
258
|
-
padding: 6px 0 7px;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
.crd_side {
|
|
262
|
-
width: 32px;
|
|
263
|
-
height: var(--av-xsmall);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
.crd_side.expanded {
|
|
267
|
-
transform: rotate(45deg);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/* Card links */
|
|
271
|
-
|
|
272
|
-
.crd_links_cnt {
|
|
273
|
-
display: grid;
|
|
274
|
-
grid-template-columns: repeat(3, 1fr);
|
|
275
|
-
row-gap: 4px;
|
|
276
|
-
column-gap: 4px;
|
|
277
|
-
padding: 14px 0 10px;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
.crd_link {
|
|
281
|
-
padding: 10px 4px 8px;
|
|
282
|
-
background-color: var(--color-darker-light);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
.crd_link .av.no_img {
|
|
286
|
-
background-color: var(--color-darker-light);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
button.crd_link:hover {
|
|
290
|
-
background-color: var(--color-darker-default);
|
|
291
|
-
}
|
|
115
|
+
display: flex;
|
|
116
|
+
flex-direction: column;
|
|
292
117
|
|
|
293
|
-
|
|
294
|
-
|
|
118
|
+
width: 300px;
|
|
119
|
+
min-height: 150px;
|
|
120
|
+
/* max-height: calc(100vh - 20px); */
|
|
121
|
+
max-height: 70vh;
|
|
295
122
|
}
|
|
296
123
|
|
|
297
124
|
/* Pop over image */
|
|
298
125
|
|
|
299
126
|
.pu_img {
|
|
300
|
-
|
|
301
|
-
|
|
127
|
+
max-width: 400px;
|
|
128
|
+
margin: 10px; /* 10px is also hard coded into the React Component */
|
|
302
129
|
}
|
package/package.json
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
"name": "@jsb188/css",
|
|
3
|
+
"version": "1.1.2",
|
|
4
|
+
"description": "Re-usable, base CSS styles for any app (NOTE: Bring your own variables).",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "jsb188",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./_global.css": "./css/_global.css",
|
|
10
|
+
"./_colors.generated.css": "./css/_colors.generated.css",
|
|
11
|
+
"./alert.css": "./css/alert.css",
|
|
12
|
+
"./animate.css": "./css/animate.css",
|
|
13
|
+
"./form.css": "./css/form.css",
|
|
14
|
+
"./layout.css": "./css/layout.css",
|
|
15
|
+
"./loading.css": "./css/loading.css",
|
|
16
|
+
"./misc.css": "./css/misc.css",
|
|
17
|
+
"./modal.css": "./css/modal.css",
|
|
18
|
+
"./popover.css": "./css/popover.css"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"gen:responsive-css": "node ./scripts/generateResponsiveCss.js",
|
|
22
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {}
|
|
22
25
|
}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = path.dirname(__filename);
|
|
7
|
+
const cssDir = path.resolve(__dirname, '../css');
|
|
8
|
+
const responsiveSourcePath = path.join(cssDir, '_responsive.css');
|
|
9
|
+
const responsiveOutputPath = path.join(cssDir, '_responsive.generated.css');
|
|
10
|
+
const colorsOutputPath = path.join(cssDir, '_colors.generated.css');
|
|
11
|
+
|
|
12
|
+
const responsiveBreakpoints = [
|
|
13
|
+
['landscape', '--responsive-mobile-landscape'],
|
|
14
|
+
['portrait', '--responsive-mobile-portrait'],
|
|
15
|
+
['phone', '--responsive-phone-wide'],
|
|
16
|
+
['narrow', '--responsive-phone-narrow'],
|
|
17
|
+
['tiny', '--responsive-phone-tiny'],
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const colorPalettes = [
|
|
21
|
+
'red',
|
|
22
|
+
'orange',
|
|
23
|
+
'brown',
|
|
24
|
+
'amber',
|
|
25
|
+
'yellow',
|
|
26
|
+
'lime',
|
|
27
|
+
'green',
|
|
28
|
+
'emerald',
|
|
29
|
+
'teal',
|
|
30
|
+
'cyan',
|
|
31
|
+
'sky',
|
|
32
|
+
'blue',
|
|
33
|
+
'indigo',
|
|
34
|
+
'violet',
|
|
35
|
+
'purple',
|
|
36
|
+
'fuchsia',
|
|
37
|
+
'pink',
|
|
38
|
+
'rose',
|
|
39
|
+
'slate',
|
|
40
|
+
'zinc',
|
|
41
|
+
'stone',
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
const colorShades = [
|
|
45
|
+
['fd', 'fade'],
|
|
46
|
+
['lt', 'light'],
|
|
47
|
+
['md', 'medium'],
|
|
48
|
+
['bd', 'bold'],
|
|
49
|
+
['', 'default'],
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const colorAltShades = [
|
|
53
|
+
['fd', 'fade'],
|
|
54
|
+
['lt', 'light'],
|
|
55
|
+
['md', 'medium'],
|
|
56
|
+
['df', 'default'],
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
const colorRuleGroups = [
|
|
60
|
+
['cl', 'color'],
|
|
61
|
+
['bg', 'background-color'],
|
|
62
|
+
['bd', 'border-color'],
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
/*
|
|
66
|
+
Reads the source responsive utility CSS file that will be expanded into
|
|
67
|
+
breakpoint-scoped utility classes.
|
|
68
|
+
*/
|
|
69
|
+
async function readSourceCSS() {
|
|
70
|
+
return readFile(responsiveSourcePath, 'utf8');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/*
|
|
74
|
+
Extracts simple single-selector utility rules from the source CSS file so each
|
|
75
|
+
selector can be cloned with responsive prefixes.
|
|
76
|
+
*/
|
|
77
|
+
function parseUtilityRules(sourceCSS) {
|
|
78
|
+
const utilityRulePattern =
|
|
79
|
+
/(^|\n)\s*(\.[A-Za-z0-9_-][A-Za-z0-9_-]*)\s*\{([^}]*)\}/g;
|
|
80
|
+
|
|
81
|
+
return Array.from(
|
|
82
|
+
sourceCSS.matchAll(utilityRulePattern),
|
|
83
|
+
([, , selector, declarations]) => ({
|
|
84
|
+
selector,
|
|
85
|
+
declarations: declarations.trim(),
|
|
86
|
+
}),
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/*
|
|
91
|
+
Builds the generated CSS file contents by wrapping cloned utility selectors in
|
|
92
|
+
their corresponding custom-media breakpoints.
|
|
93
|
+
*/
|
|
94
|
+
function buildGeneratedResponsiveCSS(rules) {
|
|
95
|
+
const sections = responsiveBreakpoints.map(([prefix, mediaName]) => {
|
|
96
|
+
const clonedRules = rules.map(({ selector, declarations }) => {
|
|
97
|
+
const className = selector.slice(1);
|
|
98
|
+
|
|
99
|
+
return ` .${prefix}\\:${className} { ${declarations} }`;
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
return `@media (${mediaName}) {\n${clonedRules.join('\n')}\n}`;
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
return [
|
|
106
|
+
'/* This file is auto-generated by scripts/generateResponsiveCss.js. */',
|
|
107
|
+
'/* Do not edit this file directly. Edit _responsive.css and regenerate. */',
|
|
108
|
+
'',
|
|
109
|
+
...sections,
|
|
110
|
+
'',
|
|
111
|
+
].join('\n');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/*
|
|
115
|
+
Builds one palette utility rule for a color, shade, and CSS property group.
|
|
116
|
+
Default background rules also set a readable foreground color.
|
|
117
|
+
*/
|
|
118
|
+
function buildColorRule(
|
|
119
|
+
rulePrefix,
|
|
120
|
+
propertyName,
|
|
121
|
+
palette,
|
|
122
|
+
classSuffix,
|
|
123
|
+
tokenSuffix,
|
|
124
|
+
) {
|
|
125
|
+
const shadeClassSuffix = classSuffix ? `_${classSuffix}` : '';
|
|
126
|
+
const className = `${rulePrefix}_${palette}${shadeClassSuffix}`;
|
|
127
|
+
const selectors = [`.${className}`, `.${className}_hv:hover`];
|
|
128
|
+
const declarations = [
|
|
129
|
+
`${propertyName}: var(--color-${palette}-${tokenSuffix}) !important;`,
|
|
130
|
+
];
|
|
131
|
+
|
|
132
|
+
if (rulePrefix === 'bg' && tokenSuffix === 'default') {
|
|
133
|
+
declarations.push('color: var(--color-solid) !important;');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return `${selectors.join(', ')} { ${declarations.join(' ')} }`;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/*
|
|
140
|
+
Builds one alt background utility rule for a color and shade.
|
|
141
|
+
*/
|
|
142
|
+
function buildAltBackgroundColorRule(palette, classSuffix, tokenSuffix) {
|
|
143
|
+
const className = `bg_${palette}_alt_${classSuffix}`;
|
|
144
|
+
const selectors = [`.${className}`, `.${className}_hv:hover`];
|
|
145
|
+
|
|
146
|
+
return `${selectors.join(', ')} { background-color: var(--color-${palette}-alt-${tokenSuffix}) !important; }`;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/*
|
|
150
|
+
Builds one alt foreground/border utility rule for a color, mapping the bare
|
|
151
|
+
"_alt" suffix to the muted-vivid alt-default token.
|
|
152
|
+
*/
|
|
153
|
+
function buildAltColorRule(rulePrefix, propertyName, palette) {
|
|
154
|
+
const className = `${rulePrefix}_${palette}_alt`;
|
|
155
|
+
const selectors = [`.${className}`, `.${className}_hv:hover`];
|
|
156
|
+
|
|
157
|
+
return `${selectors.join(', ')} { ${propertyName}: var(--color-${palette}-alt-default) !important; }`;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/*
|
|
161
|
+
Builds one outline utility rule for a palette's default or light token,
|
|
162
|
+
including the equivalent alt token when requested.
|
|
163
|
+
*/
|
|
164
|
+
function buildOutlineColorRule(
|
|
165
|
+
palette,
|
|
166
|
+
classSuffix,
|
|
167
|
+
tokenSuffix,
|
|
168
|
+
isAlt = false,
|
|
169
|
+
) {
|
|
170
|
+
const altClassSuffix = isAlt ? '_alt' : '';
|
|
171
|
+
const shadeClassSuffix = classSuffix ? `_${classSuffix}` : '';
|
|
172
|
+
const altTokenSuffix = isAlt ? '-alt' : '';
|
|
173
|
+
const className = `ol_${palette}${altClassSuffix}${shadeClassSuffix}`;
|
|
174
|
+
const selectors = [
|
|
175
|
+
`.${className}`,
|
|
176
|
+
`.${className}_hv:hover`,
|
|
177
|
+
`.${className}_focus:focus`,
|
|
178
|
+
];
|
|
179
|
+
|
|
180
|
+
return `${selectors.join(', ')} { outline: 3px solid rgb(var(--color-${palette}${altTokenSuffix}-${tokenSuffix})); outline-offset: -1px; }`;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/*
|
|
184
|
+
Builds the generated color utility CSS file contents from palette, shade, and
|
|
185
|
+
property rule definitions.
|
|
186
|
+
*/
|
|
187
|
+
function buildGeneratedColorsCSS() {
|
|
188
|
+
const sections = colorRuleGroups.map(([rulePrefix, propertyName]) => {
|
|
189
|
+
const rules = colorPalettes.flatMap((palette) => {
|
|
190
|
+
const paletteRules = colorShades.map(([classSuffix, tokenSuffix]) => {
|
|
191
|
+
return buildColorRule(
|
|
192
|
+
rulePrefix,
|
|
193
|
+
propertyName,
|
|
194
|
+
palette,
|
|
195
|
+
classSuffix,
|
|
196
|
+
tokenSuffix,
|
|
197
|
+
);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
if (rulePrefix === 'bg') {
|
|
201
|
+
return [
|
|
202
|
+
...paletteRules,
|
|
203
|
+
...colorAltShades.map(([classSuffix, tokenSuffix]) => {
|
|
204
|
+
return buildAltBackgroundColorRule(
|
|
205
|
+
palette,
|
|
206
|
+
classSuffix,
|
|
207
|
+
tokenSuffix,
|
|
208
|
+
);
|
|
209
|
+
}),
|
|
210
|
+
];
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return [
|
|
214
|
+
...paletteRules,
|
|
215
|
+
buildAltColorRule(rulePrefix, propertyName, palette),
|
|
216
|
+
];
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
return rules.join('\n');
|
|
220
|
+
});
|
|
221
|
+
const outlineRules = colorPalettes.flatMap((palette) => {
|
|
222
|
+
return [
|
|
223
|
+
buildOutlineColorRule(palette, '', 'default'),
|
|
224
|
+
buildOutlineColorRule(palette, 'lt', 'light'),
|
|
225
|
+
buildOutlineColorRule(palette, '', 'default', true),
|
|
226
|
+
buildOutlineColorRule(palette, 'lt', 'light', true),
|
|
227
|
+
];
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
return [
|
|
231
|
+
'/* This file is auto-generated by scripts/generateResponsiveCss.js. */',
|
|
232
|
+
'/* Do not edit this file directly. Update the color generator definitions and regenerate. */',
|
|
233
|
+
'',
|
|
234
|
+
'/* Colors - Palette */',
|
|
235
|
+
'',
|
|
236
|
+
...sections,
|
|
237
|
+
outlineRules.join('\n'),
|
|
238
|
+
'',
|
|
239
|
+
].join('\n');
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/*
|
|
243
|
+
Writes a generated CSS file to the shared CSS package so apps can import it
|
|
244
|
+
through the existing global stylesheet.
|
|
245
|
+
*/
|
|
246
|
+
async function writeGeneratedCSS(outputPath, outputCSS) {
|
|
247
|
+
await mkdir(cssDir, { recursive: true });
|
|
248
|
+
await writeFile(outputPath, outputCSS, 'utf8');
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/*
|
|
252
|
+
Generates the shared CSS files that can be derived from compact utility
|
|
253
|
+
definitions.
|
|
254
|
+
*/
|
|
255
|
+
async function main() {
|
|
256
|
+
const sourceCSS = await readSourceCSS();
|
|
257
|
+
const rules = parseUtilityRules(sourceCSS);
|
|
258
|
+
const responsiveOutputCSS = buildGeneratedResponsiveCSS(rules);
|
|
259
|
+
const colorsOutputCSS = buildGeneratedColorsCSS();
|
|
260
|
+
|
|
261
|
+
await Promise.all([
|
|
262
|
+
writeGeneratedCSS(responsiveOutputPath, responsiveOutputCSS),
|
|
263
|
+
writeGeneratedCSS(colorsOutputPath, colorsOutputCSS),
|
|
264
|
+
]);
|
|
265
|
+
|
|
266
|
+
console.log(
|
|
267
|
+
`Generated ${path.relative(process.cwd(), responsiveOutputPath)} from ${path.relative(process.cwd(), responsiveSourcePath)}.`,
|
|
268
|
+
);
|
|
269
|
+
console.log(
|
|
270
|
+
`Generated ${path.relative(process.cwd(), colorsOutputPath)} from color generator definitions.`,
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
await main();
|