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.
- package/.github/workflows/test.yml +25 -25
- package/AGENTS.md +43 -43
- package/CHANGELOG.md +117 -107
- package/CONTRIBUTING.md +17 -0
- package/LICENSE.md +21 -21
- package/README.md +2 -48
- package/dist/kempo.min.css +1 -1
- package/docs/demo.inc.html +213 -213
- package/docs/index.html +171 -160
- package/docs/kempo-hljs.css +124 -124
- package/docs/kempo.css +1194 -1210
- package/docs/kempo.min.css +1 -1
- package/docs/manifest.json +87 -87
- package/docs/nav.js +32 -32
- package/docs/theme-editor.html +19 -64
- package/llms.txt +205 -0
- package/package.json +1 -1
- package/scripts/build.js +173 -173
- package/src/kempo-hljs.css +124 -124
- package/src/kempo.css +1194 -1210
- package/tests/base_reset.browser-test.js +201 -201
- package/tests/buttons.browser-test.js +223 -223
- package/tests/colors.browser-test.js +277 -277
- package/tests/components.browser-test.js +131 -131
- package/tests/css_variables.browser-test.js +170 -170
- package/tests/display_flex.browser-test.js +159 -159
- package/tests/elevation.browser-test.js +239 -239
- package/tests/forms.browser-test.js +224 -224
- package/tests/rows_columns.browser-test.js +171 -171
- package/tests/spacing.browser-test.js +310 -310
- package/tests/tables.browser-test.js +192 -192
- package/tests/typography.browser-test.js +255 -255
|
@@ -1,192 +1,192 @@
|
|
|
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 make table full width': ({pass, fail}) => {
|
|
13
|
-
const table = document.createElement('table');
|
|
14
|
-
document.body.appendChild(table);
|
|
15
|
-
const width = getStyle(table, 'width');
|
|
16
|
-
table.remove();
|
|
17
|
-
if(width.endsWith('%') || parseFloat(width) > 500){
|
|
18
|
-
pass(`Table has full width: ${width}`);
|
|
19
|
-
} else {
|
|
20
|
-
fail(`Expected full width, got ${width}`);
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
'should collapse table borders': ({pass, fail}) => {
|
|
25
|
-
const table = document.createElement('table');
|
|
26
|
-
document.body.appendChild(table);
|
|
27
|
-
const borderSpacing = getStyle(table, 'borderSpacing');
|
|
28
|
-
table.remove();
|
|
29
|
-
if(borderSpacing === '0px' || borderSpacing === '0px 0px'){
|
|
30
|
-
pass('Table has collapsed borders (border-spacing: 0)');
|
|
31
|
-
} else {
|
|
32
|
-
fail(`Expected 0 border-spacing, got ${borderSpacing}`);
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
'should style th with bold font': ({pass, fail}) => {
|
|
37
|
-
const table = document.createElement('table');
|
|
38
|
-
const tr = document.createElement('tr');
|
|
39
|
-
const th = document.createElement('th');
|
|
40
|
-
th.textContent = 'Header';
|
|
41
|
-
tr.appendChild(th);
|
|
42
|
-
table.appendChild(tr);
|
|
43
|
-
document.body.appendChild(table);
|
|
44
|
-
const fontWeight = getStyle(th, 'fontWeight');
|
|
45
|
-
table.remove();
|
|
46
|
-
if(parseInt(fontWeight) >= 700){
|
|
47
|
-
pass(`th has bold font weight: ${fontWeight}`);
|
|
48
|
-
} else {
|
|
49
|
-
fail(`Expected bold, got ${fontWeight}`);
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
'should style th with background': ({pass, fail}) => {
|
|
54
|
-
const table = document.createElement('table');
|
|
55
|
-
const tr = document.createElement('tr');
|
|
56
|
-
const th = document.createElement('th');
|
|
57
|
-
tr.appendChild(th);
|
|
58
|
-
table.appendChild(tr);
|
|
59
|
-
document.body.appendChild(table);
|
|
60
|
-
const bg = getStyle(th, 'backgroundColor');
|
|
61
|
-
table.remove();
|
|
62
|
-
if(bg && bg !== 'rgba(0, 0, 0, 0)' && bg !== 'transparent'){
|
|
63
|
-
pass(`th has background: ${bg}`);
|
|
64
|
-
} else {
|
|
65
|
-
fail('th should have background color');
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
'should apply left text-align to th': ({pass, fail}) => {
|
|
70
|
-
const table = document.createElement('table');
|
|
71
|
-
const tr = document.createElement('tr');
|
|
72
|
-
const th = document.createElement('th');
|
|
73
|
-
tr.appendChild(th);
|
|
74
|
-
table.appendChild(tr);
|
|
75
|
-
document.body.appendChild(table);
|
|
76
|
-
const textAlign = getStyle(th, 'textAlign');
|
|
77
|
-
table.remove();
|
|
78
|
-
if(textAlign === 'left' || textAlign === 'start'){
|
|
79
|
-
pass(`th has left alignment: ${textAlign}`);
|
|
80
|
-
} else {
|
|
81
|
-
fail(`Expected left alignment, got ${textAlign}`);
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
'should apply padding to th and td': ({pass, fail}) => {
|
|
86
|
-
const table = document.createElement('table');
|
|
87
|
-
const tr = document.createElement('tr');
|
|
88
|
-
const th = document.createElement('th');
|
|
89
|
-
const td = document.createElement('td');
|
|
90
|
-
tr.appendChild(th);
|
|
91
|
-
tr.appendChild(td);
|
|
92
|
-
table.appendChild(tr);
|
|
93
|
-
document.body.appendChild(table);
|
|
94
|
-
const thPadding = parseFloat(getStyle(th, 'padding'));
|
|
95
|
-
const tdPadding = parseFloat(getStyle(td, 'padding'));
|
|
96
|
-
table.remove();
|
|
97
|
-
if(thPadding > 0 && tdPadding > 0){
|
|
98
|
-
pass(`th and td have padding: th=${thPadding}px, td=${tdPadding}px`);
|
|
99
|
-
} else {
|
|
100
|
-
fail(`Expected padding, got th: ${thPadding}, td: ${tdPadding}`);
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
'should apply borders to th and td': ({pass, fail}) => {
|
|
105
|
-
const table = document.createElement('table');
|
|
106
|
-
const tr = document.createElement('tr');
|
|
107
|
-
const th = document.createElement('th');
|
|
108
|
-
const td = document.createElement('td');
|
|
109
|
-
tr.appendChild(th);
|
|
110
|
-
tr.appendChild(td);
|
|
111
|
-
table.appendChild(tr);
|
|
112
|
-
document.body.appendChild(table);
|
|
113
|
-
const thBorder = parseFloat(getStyle(th, 'borderBottomWidth'));
|
|
114
|
-
const tdBorder = parseFloat(getStyle(td, 'borderBottomWidth'));
|
|
115
|
-
table.remove();
|
|
116
|
-
if(thBorder > 0 && tdBorder > 0){
|
|
117
|
-
pass('th and td have borders');
|
|
118
|
-
} else {
|
|
119
|
-
fail(`Expected borders, got th: ${thBorder}, td: ${tdBorder}`);
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
'should apply border radius to first th': ({pass, fail}) => {
|
|
124
|
-
const table = document.createElement('table');
|
|
125
|
-
const tr = document.createElement('tr');
|
|
126
|
-
const th = document.createElement('th');
|
|
127
|
-
tr.appendChild(th);
|
|
128
|
-
table.appendChild(tr);
|
|
129
|
-
document.body.appendChild(table);
|
|
130
|
-
const radius = parseFloat(getStyle(th, 'borderTopLeftRadius'));
|
|
131
|
-
table.remove();
|
|
132
|
-
if(radius > 0){
|
|
133
|
-
pass(`First th has border-top-left-radius: ${radius}px`);
|
|
134
|
-
} else {
|
|
135
|
-
fail('First th should have border radius');
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
|
|
139
|
-
'should apply border radius to last th': ({pass, fail}) => {
|
|
140
|
-
const table = document.createElement('table');
|
|
141
|
-
const tr = document.createElement('tr');
|
|
142
|
-
const th1 = document.createElement('th');
|
|
143
|
-
const th2 = document.createElement('th');
|
|
144
|
-
tr.appendChild(th1);
|
|
145
|
-
tr.appendChild(th2);
|
|
146
|
-
table.appendChild(tr);
|
|
147
|
-
document.body.appendChild(table);
|
|
148
|
-
const radius = parseFloat(getStyle(th2, 'borderTopRightRadius'));
|
|
149
|
-
table.remove();
|
|
150
|
-
if(radius > 0){
|
|
151
|
-
pass(`Last th has border-top-right-radius: ${radius}px`);
|
|
152
|
-
} else {
|
|
153
|
-
fail('Last th should have border radius');
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
'should apply border radius to last row cells': ({pass, fail}) => {
|
|
158
|
-
const table = document.createElement('table');
|
|
159
|
-
const tr1 = document.createElement('tr');
|
|
160
|
-
const th = document.createElement('th');
|
|
161
|
-
tr1.appendChild(th);
|
|
162
|
-
const tr2 = document.createElement('tr');
|
|
163
|
-
const td1 = document.createElement('td');
|
|
164
|
-
const td2 = document.createElement('td');
|
|
165
|
-
tr2.appendChild(td1);
|
|
166
|
-
tr2.appendChild(td2);
|
|
167
|
-
table.appendChild(tr1);
|
|
168
|
-
table.appendChild(tr2);
|
|
169
|
-
document.body.appendChild(table);
|
|
170
|
-
const td1Radius = parseFloat(getStyle(td1, 'borderBottomLeftRadius'));
|
|
171
|
-
const td2Radius = parseFloat(getStyle(td2, 'borderBottomRightRadius'));
|
|
172
|
-
table.remove();
|
|
173
|
-
if(td1Radius > 0 && td2Radius > 0){
|
|
174
|
-
pass('Last row has corner border radius');
|
|
175
|
-
} else {
|
|
176
|
-
fail(`Expected radius, got td1: ${td1Radius}, td2: ${td2Radius}`);
|
|
177
|
-
}
|
|
178
|
-
},
|
|
179
|
-
|
|
180
|
-
'should style .table-wrapper with overflow-x auto': ({pass, fail}) => {
|
|
181
|
-
const wrapper = document.createElement('div');
|
|
182
|
-
wrapper.className = 'table-wrapper';
|
|
183
|
-
document.body.appendChild(wrapper);
|
|
184
|
-
const overflow = getStyle(wrapper, 'overflowX');
|
|
185
|
-
wrapper.remove();
|
|
186
|
-
if(overflow === 'auto'){
|
|
187
|
-
pass('.table-wrapper has overflow-x: auto');
|
|
188
|
-
} else {
|
|
189
|
-
fail(`Expected auto, got ${overflow}`);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
};
|
|
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 make table full width': ({pass, fail}) => {
|
|
13
|
+
const table = document.createElement('table');
|
|
14
|
+
document.body.appendChild(table);
|
|
15
|
+
const width = getStyle(table, 'width');
|
|
16
|
+
table.remove();
|
|
17
|
+
if(width.endsWith('%') || parseFloat(width) > 500){
|
|
18
|
+
pass(`Table has full width: ${width}`);
|
|
19
|
+
} else {
|
|
20
|
+
fail(`Expected full width, got ${width}`);
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
'should collapse table borders': ({pass, fail}) => {
|
|
25
|
+
const table = document.createElement('table');
|
|
26
|
+
document.body.appendChild(table);
|
|
27
|
+
const borderSpacing = getStyle(table, 'borderSpacing');
|
|
28
|
+
table.remove();
|
|
29
|
+
if(borderSpacing === '0px' || borderSpacing === '0px 0px'){
|
|
30
|
+
pass('Table has collapsed borders (border-spacing: 0)');
|
|
31
|
+
} else {
|
|
32
|
+
fail(`Expected 0 border-spacing, got ${borderSpacing}`);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
'should style th with bold font': ({pass, fail}) => {
|
|
37
|
+
const table = document.createElement('table');
|
|
38
|
+
const tr = document.createElement('tr');
|
|
39
|
+
const th = document.createElement('th');
|
|
40
|
+
th.textContent = 'Header';
|
|
41
|
+
tr.appendChild(th);
|
|
42
|
+
table.appendChild(tr);
|
|
43
|
+
document.body.appendChild(table);
|
|
44
|
+
const fontWeight = getStyle(th, 'fontWeight');
|
|
45
|
+
table.remove();
|
|
46
|
+
if(parseInt(fontWeight) >= 700){
|
|
47
|
+
pass(`th has bold font weight: ${fontWeight}`);
|
|
48
|
+
} else {
|
|
49
|
+
fail(`Expected bold, got ${fontWeight}`);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
'should style th with background': ({pass, fail}) => {
|
|
54
|
+
const table = document.createElement('table');
|
|
55
|
+
const tr = document.createElement('tr');
|
|
56
|
+
const th = document.createElement('th');
|
|
57
|
+
tr.appendChild(th);
|
|
58
|
+
table.appendChild(tr);
|
|
59
|
+
document.body.appendChild(table);
|
|
60
|
+
const bg = getStyle(th, 'backgroundColor');
|
|
61
|
+
table.remove();
|
|
62
|
+
if(bg && bg !== 'rgba(0, 0, 0, 0)' && bg !== 'transparent'){
|
|
63
|
+
pass(`th has background: ${bg}`);
|
|
64
|
+
} else {
|
|
65
|
+
fail('th should have background color');
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
'should apply left text-align to th': ({pass, fail}) => {
|
|
70
|
+
const table = document.createElement('table');
|
|
71
|
+
const tr = document.createElement('tr');
|
|
72
|
+
const th = document.createElement('th');
|
|
73
|
+
tr.appendChild(th);
|
|
74
|
+
table.appendChild(tr);
|
|
75
|
+
document.body.appendChild(table);
|
|
76
|
+
const textAlign = getStyle(th, 'textAlign');
|
|
77
|
+
table.remove();
|
|
78
|
+
if(textAlign === 'left' || textAlign === 'start'){
|
|
79
|
+
pass(`th has left alignment: ${textAlign}`);
|
|
80
|
+
} else {
|
|
81
|
+
fail(`Expected left alignment, got ${textAlign}`);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
'should apply padding to th and td': ({pass, fail}) => {
|
|
86
|
+
const table = document.createElement('table');
|
|
87
|
+
const tr = document.createElement('tr');
|
|
88
|
+
const th = document.createElement('th');
|
|
89
|
+
const td = document.createElement('td');
|
|
90
|
+
tr.appendChild(th);
|
|
91
|
+
tr.appendChild(td);
|
|
92
|
+
table.appendChild(tr);
|
|
93
|
+
document.body.appendChild(table);
|
|
94
|
+
const thPadding = parseFloat(getStyle(th, 'padding'));
|
|
95
|
+
const tdPadding = parseFloat(getStyle(td, 'padding'));
|
|
96
|
+
table.remove();
|
|
97
|
+
if(thPadding > 0 && tdPadding > 0){
|
|
98
|
+
pass(`th and td have padding: th=${thPadding}px, td=${tdPadding}px`);
|
|
99
|
+
} else {
|
|
100
|
+
fail(`Expected padding, got th: ${thPadding}, td: ${tdPadding}`);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
'should apply borders to th and td': ({pass, fail}) => {
|
|
105
|
+
const table = document.createElement('table');
|
|
106
|
+
const tr = document.createElement('tr');
|
|
107
|
+
const th = document.createElement('th');
|
|
108
|
+
const td = document.createElement('td');
|
|
109
|
+
tr.appendChild(th);
|
|
110
|
+
tr.appendChild(td);
|
|
111
|
+
table.appendChild(tr);
|
|
112
|
+
document.body.appendChild(table);
|
|
113
|
+
const thBorder = parseFloat(getStyle(th, 'borderBottomWidth'));
|
|
114
|
+
const tdBorder = parseFloat(getStyle(td, 'borderBottomWidth'));
|
|
115
|
+
table.remove();
|
|
116
|
+
if(thBorder > 0 && tdBorder > 0){
|
|
117
|
+
pass('th and td have borders');
|
|
118
|
+
} else {
|
|
119
|
+
fail(`Expected borders, got th: ${thBorder}, td: ${tdBorder}`);
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
'should apply border radius to first th': ({pass, fail}) => {
|
|
124
|
+
const table = document.createElement('table');
|
|
125
|
+
const tr = document.createElement('tr');
|
|
126
|
+
const th = document.createElement('th');
|
|
127
|
+
tr.appendChild(th);
|
|
128
|
+
table.appendChild(tr);
|
|
129
|
+
document.body.appendChild(table);
|
|
130
|
+
const radius = parseFloat(getStyle(th, 'borderTopLeftRadius'));
|
|
131
|
+
table.remove();
|
|
132
|
+
if(radius > 0){
|
|
133
|
+
pass(`First th has border-top-left-radius: ${radius}px`);
|
|
134
|
+
} else {
|
|
135
|
+
fail('First th should have border radius');
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
'should apply border radius to last th': ({pass, fail}) => {
|
|
140
|
+
const table = document.createElement('table');
|
|
141
|
+
const tr = document.createElement('tr');
|
|
142
|
+
const th1 = document.createElement('th');
|
|
143
|
+
const th2 = document.createElement('th');
|
|
144
|
+
tr.appendChild(th1);
|
|
145
|
+
tr.appendChild(th2);
|
|
146
|
+
table.appendChild(tr);
|
|
147
|
+
document.body.appendChild(table);
|
|
148
|
+
const radius = parseFloat(getStyle(th2, 'borderTopRightRadius'));
|
|
149
|
+
table.remove();
|
|
150
|
+
if(radius > 0){
|
|
151
|
+
pass(`Last th has border-top-right-radius: ${radius}px`);
|
|
152
|
+
} else {
|
|
153
|
+
fail('Last th should have border radius');
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
'should apply border radius to last row cells': ({pass, fail}) => {
|
|
158
|
+
const table = document.createElement('table');
|
|
159
|
+
const tr1 = document.createElement('tr');
|
|
160
|
+
const th = document.createElement('th');
|
|
161
|
+
tr1.appendChild(th);
|
|
162
|
+
const tr2 = document.createElement('tr');
|
|
163
|
+
const td1 = document.createElement('td');
|
|
164
|
+
const td2 = document.createElement('td');
|
|
165
|
+
tr2.appendChild(td1);
|
|
166
|
+
tr2.appendChild(td2);
|
|
167
|
+
table.appendChild(tr1);
|
|
168
|
+
table.appendChild(tr2);
|
|
169
|
+
document.body.appendChild(table);
|
|
170
|
+
const td1Radius = parseFloat(getStyle(td1, 'borderBottomLeftRadius'));
|
|
171
|
+
const td2Radius = parseFloat(getStyle(td2, 'borderBottomRightRadius'));
|
|
172
|
+
table.remove();
|
|
173
|
+
if(td1Radius > 0 && td2Radius > 0){
|
|
174
|
+
pass('Last row has corner border radius');
|
|
175
|
+
} else {
|
|
176
|
+
fail(`Expected radius, got td1: ${td1Radius}, td2: ${td2Radius}`);
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
'should style .table-wrapper with overflow-x auto': ({pass, fail}) => {
|
|
181
|
+
const wrapper = document.createElement('div');
|
|
182
|
+
wrapper.className = 'table-wrapper';
|
|
183
|
+
document.body.appendChild(wrapper);
|
|
184
|
+
const overflow = getStyle(wrapper, 'overflowX');
|
|
185
|
+
wrapper.remove();
|
|
186
|
+
if(overflow === 'auto'){
|
|
187
|
+
pass('.table-wrapper has overflow-x: auto');
|
|
188
|
+
} else {
|
|
189
|
+
fail(`Expected auto, got ${overflow}`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
};
|