kempo-css 1.3.13 → 2.0.0

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.
@@ -1,159 +1,159 @@
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
- 'should apply display block with .d-b': ({pass, fail}) => {
13
- const el = document.createElement('span');
14
- el.className = 'd-b';
15
- document.body.appendChild(el);
16
- const display = getStyle(el, 'display');
17
- el.remove();
18
- if(display === 'block'){
19
- pass('.d-b sets display: block');
20
- } else {
21
- fail(`Expected block, got ${display}`);
22
- }
23
- },
24
-
25
- 'should apply display inline-block with .d-ib': ({pass, fail}) => {
26
- const el = document.createElement('div');
27
- el.className = 'd-ib';
28
- document.body.appendChild(el);
29
- const display = getStyle(el, 'display');
30
- el.remove();
31
- if(display === 'inline-block'){
32
- pass('.d-ib sets display: inline-block');
33
- } else {
34
- fail(`Expected inline-block, got ${display}`);
35
- }
36
- },
37
-
38
- 'should apply display grid with .d-g': ({pass, fail}) => {
39
- const el = document.createElement('div');
40
- el.className = 'd-g';
41
- document.body.appendChild(el);
42
- const display = getStyle(el, 'display');
43
- el.remove();
44
- if(display === 'grid'){
45
- pass('.d-g sets display: grid');
46
- } else {
47
- fail(`Expected grid, got ${display}`);
48
- }
49
- },
50
-
51
- 'should apply display inline with .d-i': ({pass, fail}) => {
52
- const el = document.createElement('div');
53
- el.className = 'd-i';
54
- document.body.appendChild(el);
55
- const display = getStyle(el, 'display');
56
- el.remove();
57
- if(display === 'inline'){
58
- pass('.d-i sets display: inline');
59
- } else {
60
- fail(`Expected inline, got ${display}`);
61
- }
62
- },
63
-
64
- 'should apply display none with .d-n': ({pass, fail}) => {
65
- const el = document.createElement('div');
66
- el.className = 'd-n';
67
- document.body.appendChild(el);
68
- const display = getStyle(el, 'display');
69
- el.remove();
70
- if(display === 'none'){
71
- pass('.d-n sets display: none');
72
- } else {
73
- fail(`Expected none, got ${display}`);
74
- }
75
- },
76
-
77
- 'should apply display flex with .d-f': ({pass, fail}) => {
78
- const el = document.createElement('div');
79
- el.className = 'd-f';
80
- document.body.appendChild(el);
81
- const display = getStyle(el, 'display');
82
- const flexWrap = getStyle(el, 'flexWrap');
83
- el.remove();
84
- if(display === 'flex' && flexWrap === 'wrap'){
85
- pass('.d-f sets display: flex with wrap');
86
- } else {
87
- fail(`Expected flex with wrap, got display: ${display}, flex-wrap: ${flexWrap}`);
88
- }
89
- },
90
-
91
- 'should apply display inline-flex with .d-if': ({pass, fail}) => {
92
- const el = document.createElement('div');
93
- el.className = 'd-if';
94
- document.body.appendChild(el);
95
- const display = getStyle(el, 'display');
96
- const flexWrap = getStyle(el, 'flexWrap');
97
- el.remove();
98
- if(display === 'inline-flex' && flexWrap === 'wrap'){
99
- pass('.d-if sets display: inline-flex with wrap');
100
- } else {
101
- fail(`Expected inline-flex with wrap, got display: ${display}, flex-wrap: ${flexWrap}`);
102
- }
103
- },
104
-
105
- 'should apply flex grow with .flex classes': ({pass, fail}) => {
106
- const el = document.createElement('div');
107
- el.className = 'flex';
108
- document.body.appendChild(el);
109
- const flexGrow = getStyle(el, 'flexGrow');
110
- el.remove();
111
- if(flexGrow === '1'){
112
- pass('.flex sets flex-grow: 1');
113
- } else {
114
- fail(`Expected flex-grow: 1, got ${flexGrow}`);
115
- }
116
- },
117
-
118
- 'should apply flex-0 correctly': ({pass, fail}) => {
119
- const el = document.createElement('div');
120
- el.className = 'flex-0';
121
- document.body.appendChild(el);
122
- const flexGrow = getStyle(el, 'flexGrow');
123
- el.remove();
124
- if(flexGrow === '0'){
125
- pass('.flex-0 sets flex-grow: 0');
126
- } else {
127
- fail(`Expected flex-grow: 0, got ${flexGrow}`);
128
- }
129
- },
130
-
131
- 'should apply higher flex values': ({pass, fail}) => {
132
- const el = document.createElement('div');
133
- el.className = 'flex-5';
134
- document.body.appendChild(el);
135
- const flexGrow = getStyle(el, 'flexGrow');
136
- el.remove();
137
- if(flexGrow === '5'){
138
- pass('.flex-5 sets flex-grow: 5');
139
- } else {
140
- fail(`Expected flex-grow: 5, got ${flexGrow}`);
141
- }
142
- },
143
-
144
- 'should apply fixed positioning with .fixed': ({pass, fail}) => {
145
- const el = document.createElement('div');
146
- el.className = 'fixed';
147
- document.body.appendChild(el);
148
- const position = getStyle(el, 'position');
149
- const top = getStyle(el, 'top');
150
- const width = getStyle(el, 'width');
151
- const zIndex = getStyle(el, 'zIndex');
152
- el.remove();
153
- if(position === 'fixed' && top === '0px' && zIndex !== 'auto'){
154
- pass('.fixed applies fixed positioning at top with z-index');
155
- } else {
156
- fail(`Expected fixed position at top, got position: ${position}, top: ${top}, z-index: ${zIndex}`);
157
- }
158
- }
159
- };
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
+ 'should apply display block with .d-b': ({pass, fail}) => {
13
+ const el = document.createElement('span');
14
+ el.className = 'd-b';
15
+ document.body.appendChild(el);
16
+ const display = getStyle(el, 'display');
17
+ el.remove();
18
+ if(display === 'block'){
19
+ pass('.d-b sets display: block');
20
+ } else {
21
+ fail(`Expected block, got ${display}`);
22
+ }
23
+ },
24
+
25
+ 'should apply display inline-block with .d-ib': ({pass, fail}) => {
26
+ const el = document.createElement('div');
27
+ el.className = 'd-ib';
28
+ document.body.appendChild(el);
29
+ const display = getStyle(el, 'display');
30
+ el.remove();
31
+ if(display === 'inline-block'){
32
+ pass('.d-ib sets display: inline-block');
33
+ } else {
34
+ fail(`Expected inline-block, got ${display}`);
35
+ }
36
+ },
37
+
38
+ 'should apply display grid with .d-g': ({pass, fail}) => {
39
+ const el = document.createElement('div');
40
+ el.className = 'd-g';
41
+ document.body.appendChild(el);
42
+ const display = getStyle(el, 'display');
43
+ el.remove();
44
+ if(display === 'grid'){
45
+ pass('.d-g sets display: grid');
46
+ } else {
47
+ fail(`Expected grid, got ${display}`);
48
+ }
49
+ },
50
+
51
+ 'should apply display inline with .d-i': ({pass, fail}) => {
52
+ const el = document.createElement('div');
53
+ el.className = 'd-i';
54
+ document.body.appendChild(el);
55
+ const display = getStyle(el, 'display');
56
+ el.remove();
57
+ if(display === 'inline'){
58
+ pass('.d-i sets display: inline');
59
+ } else {
60
+ fail(`Expected inline, got ${display}`);
61
+ }
62
+ },
63
+
64
+ 'should apply display none with .d-n': ({pass, fail}) => {
65
+ const el = document.createElement('div');
66
+ el.className = 'd-n';
67
+ document.body.appendChild(el);
68
+ const display = getStyle(el, 'display');
69
+ el.remove();
70
+ if(display === 'none'){
71
+ pass('.d-n sets display: none');
72
+ } else {
73
+ fail(`Expected none, got ${display}`);
74
+ }
75
+ },
76
+
77
+ 'should apply display flex with .d-f': ({pass, fail}) => {
78
+ const el = document.createElement('div');
79
+ el.className = 'd-f';
80
+ document.body.appendChild(el);
81
+ const display = getStyle(el, 'display');
82
+ const flexWrap = getStyle(el, 'flexWrap');
83
+ el.remove();
84
+ if(display === 'flex' && flexWrap === 'wrap'){
85
+ pass('.d-f sets display: flex with wrap');
86
+ } else {
87
+ fail(`Expected flex with wrap, got display: ${display}, flex-wrap: ${flexWrap}`);
88
+ }
89
+ },
90
+
91
+ 'should apply display inline-flex with .d-if': ({pass, fail}) => {
92
+ const el = document.createElement('div');
93
+ el.className = 'd-if';
94
+ document.body.appendChild(el);
95
+ const display = getStyle(el, 'display');
96
+ const flexWrap = getStyle(el, 'flexWrap');
97
+ el.remove();
98
+ if(display === 'inline-flex' && flexWrap === 'wrap'){
99
+ pass('.d-if sets display: inline-flex with wrap');
100
+ } else {
101
+ fail(`Expected inline-flex with wrap, got display: ${display}, flex-wrap: ${flexWrap}`);
102
+ }
103
+ },
104
+
105
+ 'should apply flex grow with .flex classes': ({pass, fail}) => {
106
+ const el = document.createElement('div');
107
+ el.className = 'flex';
108
+ document.body.appendChild(el);
109
+ const flexGrow = getStyle(el, 'flexGrow');
110
+ el.remove();
111
+ if(flexGrow === '1'){
112
+ pass('.flex sets flex-grow: 1');
113
+ } else {
114
+ fail(`Expected flex-grow: 1, got ${flexGrow}`);
115
+ }
116
+ },
117
+
118
+ 'should apply flex-0 correctly': ({pass, fail}) => {
119
+ const el = document.createElement('div');
120
+ el.className = 'flex-0';
121
+ document.body.appendChild(el);
122
+ const flexGrow = getStyle(el, 'flexGrow');
123
+ el.remove();
124
+ if(flexGrow === '0'){
125
+ pass('.flex-0 sets flex-grow: 0');
126
+ } else {
127
+ fail(`Expected flex-grow: 0, got ${flexGrow}`);
128
+ }
129
+ },
130
+
131
+ 'should apply higher flex values': ({pass, fail}) => {
132
+ const el = document.createElement('div');
133
+ el.className = 'flex-5';
134
+ document.body.appendChild(el);
135
+ const flexGrow = getStyle(el, 'flexGrow');
136
+ el.remove();
137
+ if(flexGrow === '5'){
138
+ pass('.flex-5 sets flex-grow: 5');
139
+ } else {
140
+ fail(`Expected flex-grow: 5, got ${flexGrow}`);
141
+ }
142
+ },
143
+
144
+ 'should apply fixed positioning with .fixed': ({pass, fail}) => {
145
+ const el = document.createElement('div');
146
+ el.className = 'fixed';
147
+ document.body.appendChild(el);
148
+ const position = getStyle(el, 'position');
149
+ const top = getStyle(el, 'top');
150
+ const width = getStyle(el, 'width');
151
+ const zIndex = getStyle(el, 'zIndex');
152
+ el.remove();
153
+ if(position === 'fixed' && top === '0px' && zIndex !== 'auto'){
154
+ pass('.fixed applies fixed positioning at top with z-index');
155
+ } else {
156
+ fail(`Expected fixed position at top, got position: ${position}, top: ${top}, z-index: ${zIndex}`);
157
+ }
158
+ }
159
+ };
@@ -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
+ };