kempo-css 2.0.0 → 2.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.
@@ -1,277 +1,277 @@
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 .bg-default': ({pass, fail}) => {
13
- const el = document.createElement('div');
14
- el.className = 'bg-default';
15
- document.body.appendChild(el);
16
- const bg = getStyle(el, 'backgroundColor');
17
- el.remove();
18
- if(bg && bg !== 'rgba(0, 0, 0, 0)'){
19
- pass(`.bg-default applies background: ${bg}`);
20
- } else {
21
- fail('bg-default should apply background');
22
- }
23
- },
24
-
25
- 'should apply .bg-alt': ({pass, fail}) => {
26
- const el = document.createElement('div');
27
- el.className = 'bg-alt';
28
- document.body.appendChild(el);
29
- const bg = getStyle(el, 'backgroundColor');
30
- el.remove();
31
- if(bg && bg !== 'rgba(0, 0, 0, 0)'){
32
- pass(`.bg-alt applies background: ${bg}`);
33
- } else {
34
- fail('bg-alt should apply background');
35
- }
36
- },
37
-
38
- 'should apply .bg-inv with inverted colors': ({pass, fail}) => {
39
- const el = document.createElement('div');
40
- el.className = 'bg-inv';
41
- document.body.appendChild(el);
42
- const bg = getStyle(el, 'backgroundColor');
43
- const color = getStyle(el, 'color');
44
- el.remove();
45
- if(bg && bg !== 'rgba(0, 0, 0, 0)'){
46
- pass(`.bg-inv applies inverted background: ${bg}`);
47
- } else {
48
- fail('bg-inv should apply background');
49
- }
50
- },
51
-
52
- 'should apply .bg-primary': ({pass, fail}) => {
53
- const el = document.createElement('div');
54
- el.className = 'bg-primary';
55
- document.body.appendChild(el);
56
- const bg = getStyle(el, 'backgroundColor');
57
- el.remove();
58
- if(bg && bg.includes('51') && bg.includes('102') && bg.includes('255')){
59
- pass(`.bg-primary applies primary color: ${bg}`);
60
- } else {
61
- fail(`Expected primary blue, got ${bg}`);
62
- }
63
- },
64
-
65
- 'should apply .bg-secondary': ({pass, fail}) => {
66
- const el = document.createElement('div');
67
- el.className = 'bg-secondary';
68
- document.body.appendChild(el);
69
- const bg = getStyle(el, 'backgroundColor');
70
- el.remove();
71
- if(bg && bg.includes('153') && bg.includes('51') && bg.includes('255')){
72
- pass(`.bg-secondary applies secondary color: ${bg}`);
73
- } else {
74
- fail(`Expected secondary purple, got ${bg}`);
75
- }
76
- },
77
-
78
- 'should apply .bg-success': ({pass, fail}) => {
79
- const el = document.createElement('div');
80
- el.className = 'bg-success';
81
- document.body.appendChild(el);
82
- const bg = getStyle(el, 'backgroundColor');
83
- el.remove();
84
- if(bg && bg.includes('136') && bg.includes('0')){
85
- pass(`.bg-success applies green: ${bg}`);
86
- } else {
87
- fail(`Expected green, got ${bg}`);
88
- }
89
- },
90
-
91
- 'should apply .bg-warning': ({pass, fail}) => {
92
- const el = document.createElement('div');
93
- el.className = 'bg-warning';
94
- document.body.appendChild(el);
95
- const bg = getStyle(el, 'backgroundColor');
96
- el.remove();
97
- if(bg && bg.includes('255') && bg.includes('102')){
98
- pass(`.bg-warning applies orange: ${bg}`);
99
- } else {
100
- fail(`Expected orange, got ${bg}`);
101
- }
102
- },
103
-
104
- 'should apply .bg-danger': ({pass, fail}) => {
105
- const el = document.createElement('div');
106
- el.className = 'bg-danger';
107
- document.body.appendChild(el);
108
- const bg = getStyle(el, 'backgroundColor');
109
- el.remove();
110
- if(bg && bg.includes('255') && bg.includes('51')){
111
- pass(`.bg-danger applies red: ${bg}`);
112
- } else {
113
- fail(`Expected red, got ${bg}`);
114
- }
115
- },
116
-
117
- 'should apply .tc-default': ({pass, fail}) => {
118
- const el = document.createElement('div');
119
- el.className = 'tc-default';
120
- document.body.appendChild(el);
121
- const color = getStyle(el, 'color');
122
- el.remove();
123
- if(color && color !== 'rgba(0, 0, 0, 0)'){
124
- pass(`.tc-default applies color: ${color}`);
125
- } else {
126
- fail('tc-default should apply color');
127
- }
128
- },
129
-
130
- 'should apply .tc-primary': ({pass, fail}) => {
131
- const el = document.createElement('div');
132
- el.className = 'tc-primary';
133
- document.body.appendChild(el);
134
- const color = getStyle(el, 'color');
135
- el.remove();
136
- if(color && color !== 'rgba(0, 0, 0, 0)'){
137
- pass(`.tc-primary applies color: ${color}`);
138
- } else {
139
- fail('tc-primary should apply color');
140
- }
141
- },
142
-
143
- 'should apply .tc-secondary': ({pass, fail}) => {
144
- const el = document.createElement('div');
145
- el.className = 'tc-secondary';
146
- document.body.appendChild(el);
147
- const color = getStyle(el, 'color');
148
- el.remove();
149
- if(color && color !== 'rgba(0, 0, 0, 0)'){
150
- pass(`.tc-secondary applies color: ${color}`);
151
- } else {
152
- fail('tc-secondary should apply color');
153
- }
154
- },
155
-
156
- 'should apply .tc-success': ({pass, fail}) => {
157
- const el = document.createElement('div');
158
- el.className = 'tc-success';
159
- document.body.appendChild(el);
160
- const color = getStyle(el, 'color');
161
- el.remove();
162
- if(color && color !== 'rgba(0, 0, 0, 0)'){
163
- pass(`.tc-success applies color: ${color}`);
164
- } else {
165
- fail('tc-success should apply color');
166
- }
167
- },
168
-
169
- 'should apply .tc-warning': ({pass, fail}) => {
170
- const el = document.createElement('div');
171
- el.className = 'tc-warning';
172
- document.body.appendChild(el);
173
- const color = getStyle(el, 'color');
174
- el.remove();
175
- if(color && color !== 'rgba(0, 0, 0, 0)'){
176
- pass(`.tc-warning applies color: ${color}`);
177
- } else {
178
- fail('tc-warning should apply color');
179
- }
180
- },
181
-
182
- 'should apply .tc-danger': ({pass, fail}) => {
183
- const el = document.createElement('div');
184
- el.className = 'tc-danger';
185
- document.body.appendChild(el);
186
- const color = getStyle(el, 'color');
187
- el.remove();
188
- if(color && color !== 'rgba(0, 0, 0, 0)'){
189
- pass(`.tc-danger applies color: ${color}`);
190
- } else {
191
- fail('tc-danger should apply color');
192
- }
193
- },
194
-
195
- 'should apply .tc-muted': ({pass, fail}) => {
196
- const el = document.createElement('div');
197
- el.className = 'tc-muted';
198
- document.body.appendChild(el);
199
- const color = getStyle(el, 'color');
200
- el.remove();
201
- if(color && color.includes('0.5')){
202
- pass(`.tc-muted applies muted color: ${color}`);
203
- } else {
204
- fail(`Expected muted (50% opacity), got ${color}`);
205
- }
206
- },
207
-
208
- 'should set text color on .bg-primary': ({pass, fail}) => {
209
- const el = document.createElement('div');
210
- el.className = 'bg-primary';
211
- el.textContent = 'Test';
212
- document.body.appendChild(el);
213
- const color = getStyle(el, 'color');
214
- el.remove();
215
- if(color && color.includes('255')){
216
- pass(`.bg-primary sets light text color: ${color}`);
217
- } else {
218
- fail(`Expected light text, got ${color}`);
219
- }
220
- },
221
-
222
- 'should prioritize .bg-primary over .bg-elevation background': ({pass, fail}) => {
223
- const combined = document.createElement('div');
224
- combined.className = 'elevation-3 bg-elevation bg-primary';
225
- document.body.appendChild(combined);
226
-
227
- const bgOnly = document.createElement('div');
228
- bgOnly.className = 'bg-primary';
229
- document.body.appendChild(bgOnly);
230
-
231
- const elevationOnly = document.createElement('div');
232
- elevationOnly.className = 'elevation-3 bg-elevation';
233
- document.body.appendChild(elevationOnly);
234
-
235
- const combinedBg = getStyle(combined, 'backgroundColor');
236
- const bgPrimaryOnly = getStyle(bgOnly, 'backgroundColor');
237
- const elevationOnlyBg = getStyle(elevationOnly, 'backgroundColor');
238
-
239
- combined.remove();
240
- bgOnly.remove();
241
- elevationOnly.remove();
242
-
243
- if(combinedBg === bgPrimaryOnly && combinedBg !== elevationOnlyBg){
244
- pass(`Combined classes use bg-primary color: ${combinedBg}`);
245
- } else {
246
- fail(`Expected bg-primary to win. combined=${combinedBg}, bg-primary=${bgPrimaryOnly}, elevation=${elevationOnlyBg}`);
247
- }
248
- },
249
-
250
- 'should prioritize .btn.primary over .bg-alt background': ({pass, fail}) => {
251
- const combined = document.createElement('button');
252
- combined.className = 'btn primary bg-alt';
253
- document.body.appendChild(combined);
254
-
255
- const primaryOnly = document.createElement('button');
256
- primaryOnly.className = 'btn primary';
257
- document.body.appendChild(primaryOnly);
258
-
259
- const bgAltOnly = document.createElement('button');
260
- bgAltOnly.className = 'btn bg-alt';
261
- document.body.appendChild(bgAltOnly);
262
-
263
- const combinedBg = getStyle(combined, 'backgroundColor');
264
- const primaryOnlyBg = getStyle(primaryOnly, 'backgroundColor');
265
- const bgAltOnlyBg = getStyle(bgAltOnly, 'backgroundColor');
266
-
267
- combined.remove();
268
- primaryOnly.remove();
269
- bgAltOnly.remove();
270
-
271
- if(combinedBg === primaryOnlyBg && combinedBg !== bgAltOnlyBg){
272
- pass(`Combined button classes keep primary color: ${combinedBg}`);
273
- } else {
274
- fail(`Expected btn.primary to win. combined=${combinedBg}, primary=${primaryOnlyBg}, bg-alt=${bgAltOnlyBg}`);
275
- }
276
- }
277
- };
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 .bg-default': ({pass, fail}) => {
13
+ const el = document.createElement('div');
14
+ el.className = 'bg-default';
15
+ document.body.appendChild(el);
16
+ const bg = getStyle(el, 'backgroundColor');
17
+ el.remove();
18
+ if(bg && bg !== 'rgba(0, 0, 0, 0)'){
19
+ pass(`.bg-default applies background: ${bg}`);
20
+ } else {
21
+ fail('bg-default should apply background');
22
+ }
23
+ },
24
+
25
+ 'should apply .bg-alt': ({pass, fail}) => {
26
+ const el = document.createElement('div');
27
+ el.className = 'bg-alt';
28
+ document.body.appendChild(el);
29
+ const bg = getStyle(el, 'backgroundColor');
30
+ el.remove();
31
+ if(bg && bg !== 'rgba(0, 0, 0, 0)'){
32
+ pass(`.bg-alt applies background: ${bg}`);
33
+ } else {
34
+ fail('bg-alt should apply background');
35
+ }
36
+ },
37
+
38
+ 'should apply .bg-inv with inverted colors': ({pass, fail}) => {
39
+ const el = document.createElement('div');
40
+ el.className = 'bg-inv';
41
+ document.body.appendChild(el);
42
+ const bg = getStyle(el, 'backgroundColor');
43
+ const color = getStyle(el, 'color');
44
+ el.remove();
45
+ if(bg && bg !== 'rgba(0, 0, 0, 0)'){
46
+ pass(`.bg-inv applies inverted background: ${bg}`);
47
+ } else {
48
+ fail('bg-inv should apply background');
49
+ }
50
+ },
51
+
52
+ 'should apply .bg-primary': ({pass, fail}) => {
53
+ const el = document.createElement('div');
54
+ el.className = 'bg-primary';
55
+ document.body.appendChild(el);
56
+ const bg = getStyle(el, 'backgroundColor');
57
+ el.remove();
58
+ if(bg && bg.includes('51') && bg.includes('102') && bg.includes('255')){
59
+ pass(`.bg-primary applies primary color: ${bg}`);
60
+ } else {
61
+ fail(`Expected primary blue, got ${bg}`);
62
+ }
63
+ },
64
+
65
+ 'should apply .bg-secondary': ({pass, fail}) => {
66
+ const el = document.createElement('div');
67
+ el.className = 'bg-secondary';
68
+ document.body.appendChild(el);
69
+ const bg = getStyle(el, 'backgroundColor');
70
+ el.remove();
71
+ if(bg && bg.includes('153') && bg.includes('51') && bg.includes('255')){
72
+ pass(`.bg-secondary applies secondary color: ${bg}`);
73
+ } else {
74
+ fail(`Expected secondary purple, got ${bg}`);
75
+ }
76
+ },
77
+
78
+ 'should apply .bg-success': ({pass, fail}) => {
79
+ const el = document.createElement('div');
80
+ el.className = 'bg-success';
81
+ document.body.appendChild(el);
82
+ const bg = getStyle(el, 'backgroundColor');
83
+ el.remove();
84
+ if(bg && bg.includes('136') && bg.includes('0')){
85
+ pass(`.bg-success applies green: ${bg}`);
86
+ } else {
87
+ fail(`Expected green, got ${bg}`);
88
+ }
89
+ },
90
+
91
+ 'should apply .bg-warning': ({pass, fail}) => {
92
+ const el = document.createElement('div');
93
+ el.className = 'bg-warning';
94
+ document.body.appendChild(el);
95
+ const bg = getStyle(el, 'backgroundColor');
96
+ el.remove();
97
+ if(bg && bg.includes('255') && bg.includes('102')){
98
+ pass(`.bg-warning applies orange: ${bg}`);
99
+ } else {
100
+ fail(`Expected orange, got ${bg}`);
101
+ }
102
+ },
103
+
104
+ 'should apply .bg-danger': ({pass, fail}) => {
105
+ const el = document.createElement('div');
106
+ el.className = 'bg-danger';
107
+ document.body.appendChild(el);
108
+ const bg = getStyle(el, 'backgroundColor');
109
+ el.remove();
110
+ if(bg && bg.includes('255') && bg.includes('51')){
111
+ pass(`.bg-danger applies red: ${bg}`);
112
+ } else {
113
+ fail(`Expected red, got ${bg}`);
114
+ }
115
+ },
116
+
117
+ 'should apply .tc-default': ({pass, fail}) => {
118
+ const el = document.createElement('div');
119
+ el.className = 'tc-default';
120
+ document.body.appendChild(el);
121
+ const color = getStyle(el, 'color');
122
+ el.remove();
123
+ if(color && color !== 'rgba(0, 0, 0, 0)'){
124
+ pass(`.tc-default applies color: ${color}`);
125
+ } else {
126
+ fail('tc-default should apply color');
127
+ }
128
+ },
129
+
130
+ 'should apply .tc-primary': ({pass, fail}) => {
131
+ const el = document.createElement('div');
132
+ el.className = 'tc-primary';
133
+ document.body.appendChild(el);
134
+ const color = getStyle(el, 'color');
135
+ el.remove();
136
+ if(color && color !== 'rgba(0, 0, 0, 0)'){
137
+ pass(`.tc-primary applies color: ${color}`);
138
+ } else {
139
+ fail('tc-primary should apply color');
140
+ }
141
+ },
142
+
143
+ 'should apply .tc-secondary': ({pass, fail}) => {
144
+ const el = document.createElement('div');
145
+ el.className = 'tc-secondary';
146
+ document.body.appendChild(el);
147
+ const color = getStyle(el, 'color');
148
+ el.remove();
149
+ if(color && color !== 'rgba(0, 0, 0, 0)'){
150
+ pass(`.tc-secondary applies color: ${color}`);
151
+ } else {
152
+ fail('tc-secondary should apply color');
153
+ }
154
+ },
155
+
156
+ 'should apply .tc-success': ({pass, fail}) => {
157
+ const el = document.createElement('div');
158
+ el.className = 'tc-success';
159
+ document.body.appendChild(el);
160
+ const color = getStyle(el, 'color');
161
+ el.remove();
162
+ if(color && color !== 'rgba(0, 0, 0, 0)'){
163
+ pass(`.tc-success applies color: ${color}`);
164
+ } else {
165
+ fail('tc-success should apply color');
166
+ }
167
+ },
168
+
169
+ 'should apply .tc-warning': ({pass, fail}) => {
170
+ const el = document.createElement('div');
171
+ el.className = 'tc-warning';
172
+ document.body.appendChild(el);
173
+ const color = getStyle(el, 'color');
174
+ el.remove();
175
+ if(color && color !== 'rgba(0, 0, 0, 0)'){
176
+ pass(`.tc-warning applies color: ${color}`);
177
+ } else {
178
+ fail('tc-warning should apply color');
179
+ }
180
+ },
181
+
182
+ 'should apply .tc-danger': ({pass, fail}) => {
183
+ const el = document.createElement('div');
184
+ el.className = 'tc-danger';
185
+ document.body.appendChild(el);
186
+ const color = getStyle(el, 'color');
187
+ el.remove();
188
+ if(color && color !== 'rgba(0, 0, 0, 0)'){
189
+ pass(`.tc-danger applies color: ${color}`);
190
+ } else {
191
+ fail('tc-danger should apply color');
192
+ }
193
+ },
194
+
195
+ 'should apply .tc-muted': ({pass, fail}) => {
196
+ const el = document.createElement('div');
197
+ el.className = 'tc-muted';
198
+ document.body.appendChild(el);
199
+ const color = getStyle(el, 'color');
200
+ el.remove();
201
+ if(color && color.includes('0.5')){
202
+ pass(`.tc-muted applies muted color: ${color}`);
203
+ } else {
204
+ fail(`Expected muted (50% opacity), got ${color}`);
205
+ }
206
+ },
207
+
208
+ 'should set text color on .bg-primary': ({pass, fail}) => {
209
+ const el = document.createElement('div');
210
+ el.className = 'bg-primary';
211
+ el.textContent = 'Test';
212
+ document.body.appendChild(el);
213
+ const color = getStyle(el, 'color');
214
+ el.remove();
215
+ if(color && color.includes('255')){
216
+ pass(`.bg-primary sets light text color: ${color}`);
217
+ } else {
218
+ fail(`Expected light text, got ${color}`);
219
+ }
220
+ },
221
+
222
+ 'should prioritize .bg-primary over .bg-elevation background': ({pass, fail}) => {
223
+ const combined = document.createElement('div');
224
+ combined.className = 'elevation-3 bg-elevation bg-primary';
225
+ document.body.appendChild(combined);
226
+
227
+ const bgOnly = document.createElement('div');
228
+ bgOnly.className = 'bg-primary';
229
+ document.body.appendChild(bgOnly);
230
+
231
+ const elevationOnly = document.createElement('div');
232
+ elevationOnly.className = 'elevation-3 bg-elevation';
233
+ document.body.appendChild(elevationOnly);
234
+
235
+ const combinedBg = getStyle(combined, 'backgroundColor');
236
+ const bgPrimaryOnly = getStyle(bgOnly, 'backgroundColor');
237
+ const elevationOnlyBg = getStyle(elevationOnly, 'backgroundColor');
238
+
239
+ combined.remove();
240
+ bgOnly.remove();
241
+ elevationOnly.remove();
242
+
243
+ if(combinedBg === bgPrimaryOnly && combinedBg !== elevationOnlyBg){
244
+ pass(`Combined classes use bg-primary color: ${combinedBg}`);
245
+ } else {
246
+ fail(`Expected bg-primary to win. combined=${combinedBg}, bg-primary=${bgPrimaryOnly}, elevation=${elevationOnlyBg}`);
247
+ }
248
+ },
249
+
250
+ 'should prioritize .btn.primary over .bg-alt background': ({pass, fail}) => {
251
+ const combined = document.createElement('button');
252
+ combined.className = 'btn primary bg-alt';
253
+ document.body.appendChild(combined);
254
+
255
+ const primaryOnly = document.createElement('button');
256
+ primaryOnly.className = 'btn primary';
257
+ document.body.appendChild(primaryOnly);
258
+
259
+ const bgAltOnly = document.createElement('button');
260
+ bgAltOnly.className = 'btn bg-alt';
261
+ document.body.appendChild(bgAltOnly);
262
+
263
+ const combinedBg = getStyle(combined, 'backgroundColor');
264
+ const primaryOnlyBg = getStyle(primaryOnly, 'backgroundColor');
265
+ const bgAltOnlyBg = getStyle(bgAltOnly, 'backgroundColor');
266
+
267
+ combined.remove();
268
+ primaryOnly.remove();
269
+ bgAltOnly.remove();
270
+
271
+ if(combinedBg === primaryOnlyBg && combinedBg !== bgAltOnlyBg){
272
+ pass(`Combined button classes keep primary color: ${combinedBg}`);
273
+ } else {
274
+ fail(`Expected btn.primary to win. combined=${combinedBg}, primary=${primaryOnlyBg}, bg-alt=${bgAltOnlyBg}`);
275
+ }
276
+ }
277
+ };