kempo-css 1.3.13 → 2.1.1
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/CHANGELOG.md +21 -1
- package/CONTRIBUTING.md +17 -0
- package/README.md +2 -48
- package/dist/kempo.min.css +1 -1
- package/docs/components/ThemePropertyInput.js +2 -2
- package/docs/examples/responsive-grid.html +1 -1
- package/docs/index.html +1401 -25
- package/docs/init.js +1 -1
- package/docs/kempo.css +105 -94
- package/docs/kempo.min.css +1 -1
- package/docs/theme-editor.html +29 -74
- package/llms.txt +205 -0
- package/package.json +1 -1
- package/src/kempo.css +105 -94
- package/tests/colors.browser-test.js +3 -3
- package/tests/components.browser-test.js +0 -13
- package/tests/css_variables.browser-test.js +1 -1
- package/tests/elevation.browser-test.js +239 -0
- package/docs/docs.inc.html +0 -955
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
const getStyle = (el, prop) => getComputedStyle(el)[prop];
|
|
2
|
+
|
|
3
|
+
export const beforeAll = async () => {
|
|
4
|
+
const link = document.createElement('link');
|
|
5
|
+
link.rel = 'stylesheet';
|
|
6
|
+
link.href = '/src/kempo.css';
|
|
7
|
+
document.head.appendChild(link);
|
|
8
|
+
await new Promise(resolve => link.onload = resolve);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
'elevation-0 should set z-index 0': ({pass, fail}) => {
|
|
13
|
+
const el = document.createElement('div');
|
|
14
|
+
el.className = 'elevation-0';
|
|
15
|
+
el.style.position = 'relative';
|
|
16
|
+
document.body.appendChild(el);
|
|
17
|
+
const zIndex = getStyle(el, 'zIndex');
|
|
18
|
+
el.remove();
|
|
19
|
+
if(zIndex === '0'){
|
|
20
|
+
pass(`elevation-0 has z-index: ${zIndex}`);
|
|
21
|
+
} else {
|
|
22
|
+
fail(`Expected z-index 0, got ${zIndex}`);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
'elevation-2 should set z-index 20': ({pass, fail}) => {
|
|
27
|
+
const el = document.createElement('div');
|
|
28
|
+
el.className = 'elevation-2';
|
|
29
|
+
el.style.position = 'relative';
|
|
30
|
+
document.body.appendChild(el);
|
|
31
|
+
const zIndex = getStyle(el, 'zIndex');
|
|
32
|
+
el.remove();
|
|
33
|
+
if(zIndex === '20'){
|
|
34
|
+
pass(`elevation-2 has z-index: ${zIndex}`);
|
|
35
|
+
} else {
|
|
36
|
+
fail(`Expected z-index 20, got ${zIndex}`);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
'elevation-5 should set z-index 50': ({pass, fail}) => {
|
|
41
|
+
const el = document.createElement('div');
|
|
42
|
+
el.className = 'elevation-5';
|
|
43
|
+
el.style.position = 'relative';
|
|
44
|
+
document.body.appendChild(el);
|
|
45
|
+
const zIndex = getStyle(el, 'zIndex');
|
|
46
|
+
el.remove();
|
|
47
|
+
if(zIndex === '50'){
|
|
48
|
+
pass(`elevation-5 has z-index: ${zIndex}`);
|
|
49
|
+
} else {
|
|
50
|
+
fail(`Expected z-index 50, got ${zIndex}`);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
'elevation-10 should set z-index 100': ({pass, fail}) => {
|
|
55
|
+
const el = document.createElement('div');
|
|
56
|
+
el.className = 'elevation-10';
|
|
57
|
+
el.style.position = 'relative';
|
|
58
|
+
document.body.appendChild(el);
|
|
59
|
+
const zIndex = getStyle(el, 'zIndex');
|
|
60
|
+
el.remove();
|
|
61
|
+
if(zIndex === '100'){
|
|
62
|
+
pass(`elevation-10 has z-index: ${zIndex}`);
|
|
63
|
+
} else {
|
|
64
|
+
fail(`Expected z-index 100, got ${zIndex}`);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
'elevation-* should not set background-color': ({pass, fail}) => {
|
|
69
|
+
const el = document.createElement('div');
|
|
70
|
+
el.className = 'elevation-5';
|
|
71
|
+
document.body.appendChild(el);
|
|
72
|
+
const bg = getStyle(el, 'backgroundColor');
|
|
73
|
+
const bodyBg = getStyle(document.body, 'backgroundColor');
|
|
74
|
+
el.remove();
|
|
75
|
+
if(bg === bodyBg || bg === 'rgba(0, 0, 0, 0)' || bg === 'transparent'){
|
|
76
|
+
pass(`elevation-5 does not set background-color (got: ${bg})`);
|
|
77
|
+
} else {
|
|
78
|
+
fail(`elevation-5 should not set background-color, got ${bg}`);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
'elevation-* should not set box-shadow': ({pass, fail}) => {
|
|
83
|
+
const el = document.createElement('div');
|
|
84
|
+
el.className = 'elevation-5';
|
|
85
|
+
document.body.appendChild(el);
|
|
86
|
+
const shadow = getStyle(el, 'boxShadow');
|
|
87
|
+
el.remove();
|
|
88
|
+
if(shadow === 'none'){
|
|
89
|
+
pass('elevation-5 does not set box-shadow');
|
|
90
|
+
} else {
|
|
91
|
+
fail(`elevation-5 should not set box-shadow, got ${shadow}`);
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
'.shadow.elevation-0 should have inset box-shadow': ({pass, fail}) => {
|
|
96
|
+
const el = document.createElement('div');
|
|
97
|
+
el.className = 'elevation-0 shadow';
|
|
98
|
+
document.body.appendChild(el);
|
|
99
|
+
const shadow = getStyle(el, 'boxShadow');
|
|
100
|
+
el.remove();
|
|
101
|
+
if(shadow && shadow !== 'none' && shadow.includes('inset')){
|
|
102
|
+
pass(`.shadow.elevation-0 has inset shadow: ${shadow}`);
|
|
103
|
+
} else {
|
|
104
|
+
fail(`Expected inset shadow for elevation-0 shadow, got ${shadow}`);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
'.shadow.elevation-1 should have inset box-shadow': ({pass, fail}) => {
|
|
109
|
+
const el = document.createElement('div');
|
|
110
|
+
el.className = 'elevation-1 shadow';
|
|
111
|
+
document.body.appendChild(el);
|
|
112
|
+
const shadow = getStyle(el, 'boxShadow');
|
|
113
|
+
el.remove();
|
|
114
|
+
if(shadow && shadow !== 'none' && shadow.includes('inset')){
|
|
115
|
+
pass(`.shadow.elevation-1 has inset shadow: ${shadow}`);
|
|
116
|
+
} else {
|
|
117
|
+
fail(`Expected inset shadow for elevation-1 shadow, got ${shadow}`);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
'.shadow.elevation-2 should have no box-shadow': ({pass, fail}) => {
|
|
122
|
+
const el = document.createElement('div');
|
|
123
|
+
el.className = 'elevation-2 shadow';
|
|
124
|
+
document.body.appendChild(el);
|
|
125
|
+
const shadow = getStyle(el, 'boxShadow');
|
|
126
|
+
el.remove();
|
|
127
|
+
if(shadow === 'none'){
|
|
128
|
+
pass('.shadow.elevation-2 has no shadow (page level)');
|
|
129
|
+
} else {
|
|
130
|
+
fail(`Expected no shadow for elevation-2 shadow, got ${shadow}`);
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
'.shadow.elevation-3 should have outset box-shadow': ({pass, fail}) => {
|
|
135
|
+
const el = document.createElement('div');
|
|
136
|
+
el.className = 'elevation-3 shadow';
|
|
137
|
+
document.body.appendChild(el);
|
|
138
|
+
const shadow = getStyle(el, 'boxShadow');
|
|
139
|
+
el.remove();
|
|
140
|
+
if(shadow && shadow !== 'none' && !shadow.includes('inset')){
|
|
141
|
+
pass(`.shadow.elevation-3 has outset shadow: ${shadow}`);
|
|
142
|
+
} else {
|
|
143
|
+
fail(`Expected outset shadow for elevation-3 shadow, got ${shadow}`);
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
'.shadow.elevation-10 should have large outset box-shadow': ({pass, fail}) => {
|
|
148
|
+
const el3 = document.createElement('div');
|
|
149
|
+
el3.className = 'elevation-3 shadow';
|
|
150
|
+
document.body.appendChild(el3);
|
|
151
|
+
const shadow3 = getStyle(el3, 'boxShadow');
|
|
152
|
+
el3.remove();
|
|
153
|
+
|
|
154
|
+
const el10 = document.createElement('div');
|
|
155
|
+
el10.className = 'elevation-10 shadow';
|
|
156
|
+
document.body.appendChild(el10);
|
|
157
|
+
const shadow10 = getStyle(el10, 'boxShadow');
|
|
158
|
+
el10.remove();
|
|
159
|
+
|
|
160
|
+
if(shadow10 && shadow10 !== 'none' && !shadow10.includes('inset') && shadow10 !== shadow3){
|
|
161
|
+
pass(`.shadow.elevation-10 has larger shadow than elevation-3`);
|
|
162
|
+
} else {
|
|
163
|
+
fail(`Expected elevation-10 shadow to be larger than elevation-3. elevation-3=${shadow3}, elevation-10=${shadow10}`);
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
'.bg-elevation.elevation-0 should apply background color': ({pass, fail}) => {
|
|
168
|
+
const el = document.createElement('div');
|
|
169
|
+
el.className = 'elevation-0 bg-elevation';
|
|
170
|
+
document.body.appendChild(el);
|
|
171
|
+
const bg = getStyle(el, 'backgroundColor');
|
|
172
|
+
el.remove();
|
|
173
|
+
if(bg && bg !== 'rgba(0, 0, 0, 0)'){
|
|
174
|
+
pass(`.bg-elevation.elevation-0 has background: ${bg}`);
|
|
175
|
+
} else {
|
|
176
|
+
fail(`Expected background color for bg-elevation elevation-0, got ${bg}`);
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
'.bg-elevation.elevation-2 should match --c_bg': ({pass, fail}) => {
|
|
181
|
+
const el = document.createElement('div');
|
|
182
|
+
el.className = 'elevation-2 bg-elevation';
|
|
183
|
+
document.body.appendChild(el);
|
|
184
|
+
const bg = getStyle(el, 'backgroundColor');
|
|
185
|
+
const bodyBg = getStyle(document.body, 'backgroundColor');
|
|
186
|
+
el.remove();
|
|
187
|
+
if(bg === bodyBg){
|
|
188
|
+
pass(`.bg-elevation.elevation-2 matches body background: ${bg}`);
|
|
189
|
+
} else {
|
|
190
|
+
fail(`Expected elevation-2 bg-elevation to match body bg. got ${bg}, body=${bodyBg}`);
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
'.bg-elevation.elevation-0 should be darker than elevation-2 in light mode': ({pass, fail}) => {
|
|
195
|
+
const el0 = document.createElement('div');
|
|
196
|
+
el0.className = 'elevation-0 bg-elevation';
|
|
197
|
+
document.body.appendChild(el0);
|
|
198
|
+
const bg0 = getStyle(el0, 'backgroundColor');
|
|
199
|
+
el0.remove();
|
|
200
|
+
|
|
201
|
+
const el2 = document.createElement('div');
|
|
202
|
+
el2.className = 'elevation-2 bg-elevation';
|
|
203
|
+
document.body.appendChild(el2);
|
|
204
|
+
const bg2 = getStyle(el2, 'backgroundColor');
|
|
205
|
+
el2.remove();
|
|
206
|
+
|
|
207
|
+
const parseRgb = (s) => {
|
|
208
|
+
const m = s.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);
|
|
209
|
+
return m ? parseInt(m[1]) + parseInt(m[2]) + parseInt(m[3]) : 0;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
const brightness0 = parseRgb(bg0);
|
|
213
|
+
const brightness2 = parseRgb(bg2);
|
|
214
|
+
|
|
215
|
+
if(brightness0 < brightness2){
|
|
216
|
+
pass(`elevation-0 bg (${bg0}) is darker than elevation-2 bg (${bg2})`);
|
|
217
|
+
} else {
|
|
218
|
+
fail(`Expected elevation-0 to be darker than elevation-2. bg0=${bg0}, bg2=${bg2}`);
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
'.bg-elevation lower levels should have distinct backgrounds': ({pass, fail}) => {
|
|
223
|
+
const levels = [0, 1, 2, 3, 4];
|
|
224
|
+
const bgs = levels.map(n => {
|
|
225
|
+
const el = document.createElement('div');
|
|
226
|
+
el.className = `elevation-${n} bg-elevation`;
|
|
227
|
+
document.body.appendChild(el);
|
|
228
|
+
const bg = getStyle(el, 'backgroundColor');
|
|
229
|
+
el.remove();
|
|
230
|
+
return bg;
|
|
231
|
+
});
|
|
232
|
+
const unique = new Set(bgs);
|
|
233
|
+
if(unique.size === bgs.length){
|
|
234
|
+
pass(`bg-elevation levels 0–4 all have distinct background colors`);
|
|
235
|
+
} else {
|
|
236
|
+
fail(`Expected distinct backgrounds for levels ${levels.join(', ')}, got: ${bgs.join(', ')}`);
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
};
|