@toheeb/base 1.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.
Files changed (3) hide show
  1. package/base-settings.js +436 -0
  2. package/base.css +737 -0
  3. package/package.json +12 -0
@@ -0,0 +1,436 @@
1
+ class BaseSettings extends HTMLElement {
2
+ constructor() {
3
+ super();
4
+ }
5
+
6
+ connectedCallback() {
7
+ this.innerHTML = `
8
+ <dialog class="_bs">
9
+ <main>
10
+ <form id="base-form" method="dialog" novalidate>
11
+ <p>
12
+ <button type="submit">
13
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"><polygon points="7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2"></polygon><line x1="15" y1="9" x2="9" y2="15"></line><line x1="9" y1="9" x2="15" y2="15"></line></svg>
14
+ </button>
15
+ </p>
16
+ <p class="modes">
17
+ <label>
18
+ <input type="checkbox" id="base-mode-doc">
19
+ <span>Doc Mode</span>
20
+ </label>
21
+ <label>
22
+ <input type="checkbox" id="base-mode-indent">
23
+ <span>Indent Mode</span>
24
+ </label>
25
+ </p>
26
+ <p class="fields">
27
+ <label>
28
+ <span>Font Family</span>
29
+ <input type="text" id="base-font-family" list="typefaces">
30
+ <datalist id="typefaces">
31
+ <option value="serif">Serif</option>
32
+ <option value="cursive">Cursive</option>
33
+ <option value="sans-serif">Sans Serif</option>
34
+ <option value="system-ui">System UI</option>
35
+ <option value="monospace">Monospace</option>
36
+ </datalist>
37
+
38
+ </label>
39
+ <label>
40
+ <span>Font Size</span>
41
+ <input type="number" id="base-font-size" step=".0625">
42
+ </label>
43
+ <label>
44
+ <span>Font Scale</span>
45
+ <select id="base-font-scale">
46
+ <option value="1.067">Minor Second</option>
47
+ <option value="1.125">Major Second</option>
48
+ <option value="1.2">Minor Third</option>
49
+ <option value="1.25">Major Third</option>
50
+ <option value="1.333">Perfect Fourth</option>
51
+ <option value="1.414">Augmented Fourth</option>
52
+ <option value="1.5">Perfect Fifth</option>
53
+ <option value="1.618">Golden Ratio</option>
54
+ </select>
55
+ </label>
56
+ </p>
57
+ <p class="fields">
58
+ <label>
59
+ <span>Line Height</span>
60
+ <input type="number" id="base-line-height" step=".0625">
61
+ </label>
62
+ <label>
63
+ <span>Line Length</span>
64
+ <input type="number" id="base-line-length">
65
+ </label>
66
+ <label>
67
+ <span>Block Gap</span>
68
+ <input type="number" id="base-block-gap" step=".0625">
69
+ </label>
70
+ </p>
71
+ <p class="fields">
72
+ <label>
73
+ <span>Color Scheme</span>
74
+ <select id="base-color-scheme">
75
+ <option value="">Browser</option>
76
+ <option value="light">Light</option>
77
+ <option value="dark">Dark</option>
78
+ </select>
79
+ </label>
80
+ <label>
81
+ <span>Color Hue</span>
82
+ <input type="number" id="base-color-hue" min="0" max="360" step="1">
83
+ </label>
84
+ </p>
85
+ </form>
86
+ </main>
87
+ </dialog>
88
+ <style>
89
+ ._bs {
90
+ box-shadow:
91
+ -0px -0px 1px oklch(from currentColor l c h / .01),
92
+ -2px -2px 3px oklch(from currentColor l c h / .03),
93
+ -4px -4px 7px oklch(from currentColor l c h / .05)
94
+ ;
95
+ margin: auto 0 0 auto;
96
+ max-width: 20em;
97
+ border: 1px solid;
98
+ border-color: oklch(from currentColor l c h / .5);
99
+ inset-block-end: 16px;
100
+ inset-inline-end: 16px;
101
+ border-radius: 1em;
102
+ }
103
+
104
+ @supports
105
+ (color: oklch(0 0 0)) and
106
+ (color: light-dark(#000, #fff))
107
+ {
108
+ ._bs {
109
+ background-color: light-dark(
110
+ oklch(1 0.003 var(--base-color-hue)),
111
+ oklch(0.22 .03 var(--base-color-hue))
112
+ );
113
+ }
114
+ }
115
+
116
+ dialog::backdrop {
117
+ background: transparent;
118
+ }
119
+
120
+ ._bs button[type=submit] {
121
+ display: flex;
122
+ border: 0;
123
+ margin: auto;
124
+ padding: .25em;
125
+ }
126
+
127
+ ._bs form {
128
+ display: grid;
129
+ width: 100%;
130
+ gap: var(--bbg);
131
+ }
132
+
133
+ ._bs p {
134
+ width: 100%;
135
+ display: flex;
136
+ flex-flow: row wrap;
137
+ justify-content: space-between;
138
+ gap: calc(.75 * var(--bbg));
139
+ }
140
+
141
+ ._bs .fields label:not([hidden]) {
142
+ display: grid;
143
+ gap: .25em;
144
+ flex: 1 1 calc(50% - calc(.75 * var(--bbg)));
145
+ }
146
+
147
+ ._bs .fields span {
148
+ font-size: calc(var(--bfs-075) * 1rem);
149
+ }
150
+
151
+ ._bs .fields input {
152
+ width: 100%;
153
+ }
154
+ </style>
155
+
156
+ `;
157
+
158
+ document.addEventListener("click", e => {
159
+ if (e.target.classList.contains("base-settings")) {
160
+ this.querySelector("dialog").showModal();
161
+ }
162
+ })
163
+
164
+ const doc_sheets = Array.from(document.styleSheets).filter(sheet => {
165
+ if (sheet.ownerNode.closest(this.nodeName)) {
166
+ return false;
167
+ } else {
168
+ return true;
169
+ }
170
+ })
171
+
172
+
173
+ // onLoad
174
+ {
175
+
176
+ // Doc Mode
177
+ {
178
+ const has_base_sheet = doc_sheets.some(sheet => sheet.title?.toLowerCase()?.trim() == "base");
179
+ const label_mode_doc = this.querySelector("#base-mode-doc").closest("label");
180
+
181
+ if (has_base_sheet) {
182
+ label_mode_doc.hidden = false;
183
+ const has_other_sheet = doc_sheets.some(sheet => sheet.title?.toLowerCase()?.trim() != "base");
184
+ const mode_doc = this.querySelector("#base-mode-doc");
185
+
186
+ if (has_other_sheet) {
187
+ mode_doc.checked = false;
188
+ mode_doc.disabled = false;
189
+ } else {
190
+ mode_doc.checked = true;
191
+ mode_doc.disabled = true;
192
+ }
193
+ } else {
194
+ label_mode_doc.hidden = true;
195
+ }
196
+ }
197
+
198
+
199
+ const root_styles = getComputedStyle(document.documentElement);
200
+
201
+ // Indent Mode
202
+ {
203
+ const mode_indent = root_styles.getPropertyValue("--base-mode-indent").trim();
204
+ const label_mode_indent = this.querySelector("#base-mode-indent").closest("label");
205
+
206
+ if (mode_indent) {
207
+ label_mode_indent.hidden = false;
208
+ this.querySelector("#base-mode-indent").checked = parseInt(mode_indent) === 1;
209
+ } else {
210
+ label_mode_indent.hidden = true;
211
+ }
212
+ }
213
+
214
+ // Font Family
215
+ {
216
+ const font_family = root_styles.getPropertyValue("--base-font-family").trim();
217
+ const label_font_family = this.querySelector("#base-font-family").closest("label");
218
+
219
+ if (font_family) {
220
+ label_font_family.hidden = false;
221
+
222
+ const def_typefaces = ["serif", "sans-serif", "cursive", "system-ui", "monospace"];
223
+
224
+ if (def_typefaces.includes(font_family.toLowerCase())) {
225
+ } else {
226
+ const option = document.createElement("option");
227
+
228
+ option.value = font_family;
229
+ option.textContent = font_family;
230
+ this.querySelector("#base-font-family").append(option);
231
+ }
232
+
233
+ this.querySelector("#base-font-family").value = font_family;
234
+ } else {
235
+ label_font_family.hidden = true;
236
+ }
237
+
238
+ }
239
+
240
+ // Font Size
241
+ {
242
+ const font_size = root_styles.getPropertyValue("--base-font-size").trim();
243
+ const label_font_size = this.querySelector("#base-font-size").closest("label");
244
+ const positive_numbers = /^\d+\.?\d*$/;
245
+
246
+ if (positive_numbers.test(font_size)) {
247
+ label_font_size.hidden = false;
248
+ this.querySelector("#base-font-size").value = font_size;
249
+ } else {
250
+ label_font_size.hidden = true;
251
+ }
252
+ }
253
+
254
+ // Font Scale
255
+ {
256
+ const font_scale = root_styles.getPropertyValue("--base-font-scale").trim();
257
+ const label_font_scale = this.querySelector("#base-font-scale").closest("label");
258
+
259
+ if (font_scale) {
260
+ label_font_scale.hidden = false;
261
+
262
+ const scale_set = [1.067, 1.125, 1.2, 1.25, 1.333, 1.414, 1.5, 1.618];
263
+
264
+ if (scale_set.includes(parseFloat(font_scale))) {
265
+ } else {
266
+ const option = document.createElement("option");
267
+
268
+ option.value = font_scale;
269
+ option.textContent = font_scale;
270
+ this.querySelector("#base-font-scale").append(option);
271
+ }
272
+
273
+ this.querySelector("#base-font-scale").value = font_scale;
274
+ } else {
275
+ label_font_scale.hidden = true;
276
+ }
277
+
278
+ }
279
+
280
+ // Line Height
281
+ {
282
+ const line_height = root_styles.getPropertyValue("--base-line-height").trim();
283
+ const label_line_height = this.querySelector("#base-line-height").closest("label");
284
+ const positive_numbers = /^\d*\.?\d*$/;
285
+
286
+ if (positive_numbers.test(line_height)) {
287
+ label_line_height.hidden = false;
288
+ this.querySelector("#base-line-height").value = line_height;
289
+ } else {
290
+ label_line_height.hidden = true;
291
+ }
292
+ }
293
+
294
+ // Line Length
295
+ {
296
+ const line_length = root_styles.getPropertyValue("--base-line-length").trim();
297
+ const label_line_length = this.querySelector("#base-line-length").closest("label");
298
+
299
+ if (parseFloat(line_length)) {
300
+ label_line_length.hidden = false;
301
+ this.querySelector("#base-line-length").value = parseFloat(line_length);
302
+ } else {
303
+ label_line_length.hidden = true;
304
+ }
305
+ }
306
+
307
+ // Block Gap
308
+ {
309
+ const block_gap = root_styles.getPropertyValue("--base-block-gap").trim();
310
+ const label_block_gap = this.querySelector("#base-block-gap").closest("label");
311
+ const positive_numbers = /^\d*\.?\d*$/;
312
+
313
+ if (positive_numbers.test(block_gap)) {
314
+ label_block_gap.hidden = false;
315
+ this.querySelector("#base-block-gap").value = block_gap;
316
+ } else {
317
+ label_block_gap.hidden = true;
318
+ }
319
+ }
320
+
321
+ // Color Hue
322
+ {
323
+ const supports = CSS.supports('color', 'oklch(0 0 0)');
324
+ const color_hue = root_styles.getPropertyValue("--base-color-hue").trim();
325
+ const label_color_hue = this.querySelector("#base-color-hue").closest("label");
326
+ const positive_numbers = /^\d+\.?\d*$/;
327
+
328
+ if (supports && positive_numbers.test(color_hue)) {
329
+ label_color_hue.hidden = false;
330
+ this.querySelector("#base-color-hue").value = color_hue;
331
+ } else {
332
+ label_color_hue.hidden = true;
333
+ }
334
+ }
335
+
336
+ // Color Scheme
337
+ {
338
+ const color_scheme = document.querySelector("meta[name=color-scheme]")?.content.split(" ");
339
+ const node_color_scheme = this.querySelector("#base-color-scheme");
340
+ const has_light = color_scheme.includes("light");
341
+ const has_dark = color_scheme.includes("dark");
342
+
343
+ if (has_light && has_dark) {
344
+ node_color_scheme.value = "";
345
+ } else if (has_light) {
346
+ node_color_scheme.value = "light";
347
+ } else if (has_dark) {
348
+ node_color_scheme.value = "dark";
349
+ } else {
350
+ node_color_scheme.value = "";
351
+ }
352
+ }
353
+ }
354
+
355
+ // onChange
356
+ {
357
+ this.addEventListener("change", e => {
358
+ const form = e.target;
359
+ const root_style = document.documentElement.style;
360
+
361
+ switch (form.id) {
362
+
363
+ case "base-mode-doc":
364
+
365
+ if (form.checked) {
366
+
367
+ doc_sheets.forEach(sheet => {
368
+ if (sheet.title?.toLowerCase().trim() == "base") {
369
+ sheet.disabled = false;
370
+ } else {
371
+
372
+ // Store disabled to remember later
373
+ if (sheet.disabled === true) {
374
+ sheet.dataset.disabled = true;
375
+ }
376
+
377
+ sheet.disabled = true;
378
+ }
379
+ })
380
+
381
+ } else {
382
+ doc_sheets.forEach(sheet => {
383
+ if (sheet.ownerNode.dataset.disabled) {
384
+ sheet.removeAttribute("data-disabled");
385
+ sheet.disabled = true;
386
+ } else {
387
+ sheet.disabled = false;
388
+ }
389
+ })
390
+ }
391
+
392
+ break;
393
+
394
+ case "base-mode-indent":
395
+ root_style.setProperty("--base-mode-indent", form.checked * 1);
396
+ break;
397
+
398
+ case "base-font-family":
399
+ root_style.setProperty("--base-font-family", form.value);
400
+ break;
401
+
402
+ case "base-font-size":
403
+ root_style.setProperty("--base-font-size", form.value);
404
+ break;
405
+
406
+ case "base-font-scale":
407
+ root_style.setProperty("--base-font-scale", form.value);
408
+ break;
409
+
410
+ case "base-line-height":
411
+ root_style.setProperty("--base-line-height", form.value);
412
+ break;
413
+
414
+ case "base-line-length":
415
+ root_style.setProperty("--base-line-length", form.value + "rem");
416
+ break;
417
+
418
+ case "base-block-gap":
419
+ root_style.setProperty("--base-block-gap", form.value);
420
+ break;
421
+
422
+ case "base-color-scheme":
423
+ document.querySelector("meta[name=color-scheme]").content = form.value;
424
+ break;
425
+
426
+ case "base-color-hue":
427
+ root_style.setProperty("--base-color-hue", form.value);
428
+ break;
429
+
430
+ }
431
+ })
432
+ }
433
+ }
434
+ }
435
+
436
+ customElements.define("base-settings", BaseSettings);
package/base.css ADDED
@@ -0,0 +1,737 @@
1
+
2
+ /* UNIVERSAL
3
+ ========================================================= */
4
+
5
+ /* 1 */
6
+ :root {
7
+ --base-corner-radius: .2em;
8
+ }
9
+
10
+ *, ::before, ::after
11
+ {
12
+ /* 1 */
13
+ border-radius: var(--base-corner-radius);
14
+
15
+ /* 2 */
16
+ box-sizing: border-box;
17
+ }
18
+
19
+
20
+
21
+
22
+ /* TYPOGRAPHY
23
+ ========================================================= */
24
+
25
+ :root {
26
+
27
+ /* 1 */
28
+ --base-font-size: 1;
29
+ --base-font-scale: 1.2;
30
+ --base-line-height: .7;
31
+ --base-font-family: system-ui;
32
+
33
+ /* 2 */
34
+ --bfs-050: (var(--bfs-100) / (var(--base-font-scale) * var(--base-font-scale)));
35
+ --bfs-075: (var(--bfs-100) / (var(--base-font-scale)));
36
+ --bfs-100: (var(--base-font-size));
37
+ --bfs-200: (var(--bfs-100) * var(--base-font-scale));
38
+ --bfs-300: (var(--bfs-100) * var(--base-font-scale) * var(--base-font-scale));
39
+ --bfs-400: (var(--bfs-100) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale));
40
+ --bfs-500: (var(--bfs-100) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale));
41
+ --bfs-600: (var(--bfs-100) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale));
42
+ --bfs-700: (var(--bfs-100) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale));
43
+ --bfs-800: (var(--bfs-100) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale));
44
+ --bfs-900: (var(--bfs-100) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale) * var(--base-font-scale));
45
+ }
46
+
47
+ /* 3a */
48
+ p:has(~ :is(h1, h2, h3, h4, h5, h6)),
49
+ small, ::marker
50
+ {
51
+ --bfs: var(--bfs-075);
52
+ }
53
+
54
+ /* 3b */
55
+ body,
56
+ p, pre,
57
+ summary, legend, dt, th
58
+ {
59
+ --bfs: var(--bfs-100);
60
+ }
61
+
62
+ /* 3c */
63
+ :is(h1, h2, h3, h4, h5, h6) ~ p
64
+ {
65
+ --bfs: var(--bfs-200);
66
+ }
67
+
68
+
69
+ /* 3d */
70
+
71
+ h6 {
72
+ --bfs: var(--bfs-300);
73
+ }
74
+
75
+ h5 {
76
+ --bfs: var(--bfs-400);
77
+ }
78
+
79
+ h4 {
80
+ --bfs: var(--bfs-500);
81
+ }
82
+
83
+ h3 {
84
+ --bfs: var(--bfs-600);
85
+ }
86
+
87
+ h2 {
88
+ --bfs: var(--bfs-700);
89
+ }
90
+
91
+ h1 {
92
+ --bfs: var(--bfs-800);
93
+ }
94
+
95
+ /* 4 */
96
+ body,
97
+ h1, h2, h3, h4, h5, h6,
98
+ summary, legend, dt, th,
99
+ p, pre,
100
+ small, ::marker
101
+ {
102
+
103
+ /* 4a */
104
+ font-family: var(--base-font-family);
105
+
106
+ /* 4b */
107
+ font-size: calc(var(--bfs) * 1rem);
108
+
109
+ /* 4c */
110
+ line-height: calc(
111
+ 1 + (
112
+ var(--base-line-height) / var(--bfs)
113
+ )
114
+ );
115
+ }
116
+
117
+ /* 5 */
118
+ p {
119
+ text-wrap: pretty;
120
+ }
121
+
122
+ /* 6 */
123
+ h1, h2, h3, h4, h5, h6,
124
+ :is(h1, h2, h3, h4, h5, h6) ~ p,
125
+ summary, legend, dt, th
126
+ {
127
+ text-wrap: balance;
128
+ }
129
+
130
+
131
+
132
+
133
+ /* SPACING
134
+ ========================================================= */
135
+
136
+ /* 1 - 3 */
137
+ :root {
138
+
139
+ /* 1 */
140
+ --base-mode-indent: 0;
141
+ --base-block-gap: .9;
142
+ --base-line-length: 36rem;
143
+
144
+ /* 2 */
145
+ --bbg: calc(1rem * var(--base-block-gap) * var(--base-line-height) * var(--base-font-size));
146
+
147
+ /* 3 */
148
+ --bbg-100: calc( (1 - var(--base-mode-indent)) * var(--bbg));
149
+ --bbg-200: calc( (2 - var(--base-mode-indent)) * var(--bbg));
150
+ --bbg-300: calc( (3 - var(--base-mode-indent)) * var(--bbg));
151
+ --bbg-400: calc( (4 - var(--base-mode-indent)) * var(--bbg));
152
+ --bbg-500: calc( (5 - var(--base-mode-indent)) * var(--bbg));
153
+ --bbg-600: calc( (6 - var(--base-mode-indent)) * var(--bbg));
154
+ --bbg-700: calc( (7 - var(--base-mode-indent)) * var(--bbg));
155
+ --bbg-800: calc( (8 - var(--base-mode-indent)) * var(--bbg));
156
+ --bbg-900: calc( (9 - var(--base-mode-indent)) * var(--bbg));
157
+ }
158
+
159
+ /* 4 */
160
+ h1, h2, h3, h4, h5, h6
161
+ {
162
+ /* where .15em is synonymous to line height offset */
163
+ padding-block: 0 .15em;
164
+ }
165
+
166
+ /* 5a */
167
+ p:has(~ :is(h1, h2, h3, h4, h5, h6)) {
168
+ margin-block: 0 calc(.25 * var(--bbg));
169
+ }
170
+
171
+ /* 5b */
172
+ dt,
173
+ :is(h1, h2, h3, h4, h5, h6) ~ p {
174
+ margin-block: calc(.50 * var(--bbg));
175
+ }
176
+
177
+ /* 5c */
178
+ p, pre {
179
+ margin-block: var(--bbg-100);
180
+ }
181
+
182
+
183
+ /* on mixes, enforce space irrespective of indent mode */
184
+
185
+ ol, ul, dl
186
+ {
187
+ margin-block: var(--bbg);
188
+ }
189
+
190
+ dd {
191
+ margin: 0;
192
+ }
193
+
194
+ table,
195
+ iframe, object, embed, video, audio, img,
196
+ blockquote, fieldset, address, figure, del, ins, a
197
+ {
198
+ /*
199
+ * add .5 to 1 to compensate for
200
+ * loss of ascender and descender space
201
+ * prior to border
202
+ */
203
+ margin-block: calc(1.5 * var(--bbg));
204
+ }
205
+
206
+ :is(table,
207
+ iframe, object, embed, video, audio, img,
208
+ blockquote, fieldset, address, figure, del, ins, a) +
209
+ :is(table,
210
+ iframe, object, embed, video, audio, img,
211
+ blockquote, fieldset, address, figure, del, ins, a)
212
+ {
213
+ /*
214
+ * add .5 again to start to compensate for
215
+ * loss of descender space at end of previous element
216
+ * due to border to border
217
+ */
218
+ margin-block-start: calc(2 * var(--bbg));
219
+ }
220
+
221
+ /* 5d */
222
+ summary, legend, th
223
+ {
224
+ margin-block: calc(1.5* var(--bbg-100)) var(--bbg-100);
225
+ }
226
+
227
+
228
+ /* 5e */
229
+
230
+ header,
231
+ figcaption:first-child
232
+ {
233
+ padding: 0 0 var(--bbg-100);
234
+ }
235
+
236
+ header + *,
237
+ figcaption:first-child + *
238
+ {
239
+ margin-block-start: var(--bbg-200);
240
+ }
241
+
242
+ footer,
243
+ figcaption:last-child
244
+ {
245
+ padding: var(--bbg-100) 0 0;
246
+ margin-block-start: var(--bbg-200);
247
+ }
248
+
249
+ hgroup + * {
250
+ margin-block-start: var(--bbg-200);
251
+ }
252
+
253
+ hr {
254
+ margin-block: var(--bbg-200);
255
+ }
256
+
257
+
258
+ /* 5f */
259
+
260
+ /* redirect margin to sections */
261
+ h1, h2, h3, h4, h5, h6 {
262
+ margin-block: 0;
263
+ }
264
+
265
+ :is(section, aside, nav, article)
266
+ :is(section, aside, nav, article)
267
+ :is(section, aside, nav, article)
268
+ :is(section, aside, nav, article)
269
+ :is(section, aside, nav, article)
270
+ :is(section, aside, nav, article) {
271
+ margin-block: var(--bbg-300) 0;
272
+ }
273
+
274
+ :is(section, aside, nav, article)
275
+ :is(section, aside, nav, article)
276
+ :is(section, aside, nav, article)
277
+ :is(section, aside, nav, article)
278
+ :is(section, aside, nav, article) {
279
+ margin-block: var(--bbg-400) 0;
280
+ }
281
+
282
+ :is(section, aside, nav, article)
283
+ :is(section, aside, nav, article)
284
+ :is(section, aside, nav, article)
285
+ :is(section, aside, nav, article) {
286
+ margin-block: var(--bbg-500) 0;
287
+ }
288
+
289
+ :is(section, aside, nav, article)
290
+ :is(section, aside, nav, article)
291
+ :is(section, aside, nav, article) {
292
+ margin-block: var(--bbg-600) 0;
293
+ }
294
+
295
+ :is(section, aside, nav, article)
296
+ :is(section, aside, nav, article) {
297
+ margin-block: var(--bbg-700) 0;
298
+ }
299
+
300
+ :is(section, aside, nav, article) {
301
+ margin-block: var(--bbg-800);
302
+ }
303
+
304
+ /* 6 */
305
+ p + p {
306
+ text-indent: calc(var(--base-mode-indent) * 1em);
307
+ }
308
+
309
+ :is(hgroup, form, search, fieldset) p + p {
310
+ text-indent: 0;
311
+ }
312
+
313
+ /**
314
+ * 7
315
+ *
316
+ * hgroup to contain kickers
317
+ * bordered cards to shift inline borders to content
318
+ * list layers to contain their markers
319
+ */
320
+ hgroup,
321
+ summary, legend, th, dt,
322
+ p, pre,
323
+ blockquote, fieldset, address, figure, del, ins, a,
324
+ ol, ul, dl
325
+ {
326
+ margin-inline: auto;
327
+ max-width: var(--base-line-length);
328
+ }
329
+
330
+ /* 8 */
331
+ iframe, object, embed, video, audio, img
332
+ {
333
+ display: block;
334
+ margin-inline: auto;
335
+ max-width: 100%;
336
+ }
337
+
338
+ /* 9 */
339
+ table {
340
+ margin-inline: auto;
341
+ }
342
+
343
+
344
+ /* 10 */
345
+ svg, math {
346
+ vertical-align: middle;
347
+ }
348
+
349
+ /* 11 */
350
+ ol, ul, dl
351
+ {
352
+ padding-inline-start: 2em;
353
+ }
354
+
355
+ /* 12 */
356
+ /* redirect margin of body to frames */
357
+ body {
358
+ margin: 0;
359
+ }
360
+
361
+ dialog {
362
+ padding: 0;
363
+ }
364
+
365
+ main, td, caption {
366
+ padding-inline: 1rem;
367
+ }
368
+
369
+
370
+
371
+
372
+
373
+
374
+ /* COLOR
375
+ ========================================================= */
376
+
377
+ @supports
378
+ (color: oklch(0 0 0)) and
379
+ (color: light-dark(#000, #fff))
380
+ {
381
+ :root {
382
+ --base-color-hue: 230;
383
+ }
384
+
385
+ body, dialog, select, input, button, textarea {
386
+ color: light-dark(
387
+ oklch(0.45 .02 var(--base-color-hue)),
388
+ oklch(.72 .01 var(--base-color-hue))
389
+ );
390
+ background-color: light-dark(
391
+ oklch(0.99 0.003 var(--base-color-hue)),
392
+ oklch(0.20 .03 var(--base-color-hue))
393
+ );
394
+ }
395
+ }
396
+
397
+
398
+ select, input, button, textarea {
399
+ accent-color: currentColor;
400
+ }
401
+
402
+
403
+
404
+
405
+
406
+ /************************
407
+ ** CUSTOMS
408
+ *************************/
409
+
410
+
411
+ /* Cued Parts */
412
+
413
+ header {
414
+ background-image: repeating-linear-gradient(
415
+ 45deg,
416
+ currentColor 0,
417
+ currentColor 1.4px,
418
+ transparent 1.4px,
419
+ transparent 5px
420
+ );
421
+ background-size: var(--base-line-length) 5px;
422
+ background-repeat: no-repeat;
423
+ background-position: 50% 100%;
424
+ }
425
+
426
+ figcaption:first-child {
427
+ background-image: repeating-linear-gradient(
428
+ 45deg,
429
+ currentColor 0,
430
+ currentColor 1.4px,
431
+ transparent 1.4px,
432
+ transparent 5px
433
+ );
434
+ background-size: 50% 5px;
435
+ background-repeat: no-repeat;
436
+ background-position: 0% 100%;
437
+ }
438
+
439
+ hr {
440
+ background-image: repeating-linear-gradient(
441
+ 90deg,
442
+ currentColor 0,
443
+ currentColor 1px,
444
+ transparent 1px,
445
+ transparent 5px
446
+ );
447
+ border: 0 none;
448
+ height: 5px;
449
+ background-size: var(--base-line-length) 5px;
450
+ background-position: 50% 100%;
451
+ background-repeat: no-repeat;
452
+ }
453
+
454
+ figcaption:last-child {
455
+ background-image: repeating-linear-gradient(
456
+ 135deg,
457
+ currentColor 0,
458
+ currentColor 1.4px,
459
+ transparent 1.4px,
460
+ transparent 5px
461
+ );
462
+ background-size: 50% 5px;
463
+ background-repeat: no-repeat;
464
+ background-position: 0% 0%;
465
+ }
466
+
467
+ footer {
468
+ background-image: repeating-linear-gradient(
469
+ 135deg,
470
+ currentColor 0,
471
+ currentColor 1.4px,
472
+ transparent 1.4px,
473
+ transparent 5px
474
+ );
475
+ background-size: var(--base-line-length) 5px;
476
+ background-repeat: no-repeat;
477
+ background-position: 50% 0%;
478
+ }
479
+
480
+
481
+
482
+ /* Multi Kickers */
483
+ p:has(~ :is(h1, h2, h3, h4, h5, h6)) {
484
+ width: auto;
485
+ display: inline-block;
486
+ margin-inline-end: calc(2*var(--bbg));
487
+ }
488
+
489
+
490
+ /* Indented Disclosure */
491
+ summary {
492
+ text-indent: .3em;
493
+ }
494
+
495
+
496
+ /* Bordered Legend */
497
+ legend {
498
+ border: 1px solid currentColor;
499
+ padding: 0 .75em .3em;
500
+ margin-inline: 0;
501
+ }
502
+
503
+
504
+ /* Bordered Table Layer*/
505
+
506
+ table {
507
+ border-collapse: collapse;
508
+ }
509
+
510
+ table, th, td {
511
+ border: 1px solid currentColor;
512
+ }
513
+
514
+ caption {
515
+ text-align: start;
516
+
517
+ /* border caption to table */
518
+ border: 1px solid currentColor;
519
+ border-bottom: 0;
520
+ border-bottom-left-radius: 0;
521
+ border-bottom-right-radius: 0;
522
+ }
523
+
524
+ /* Marked Definition List */
525
+ dt, dd {
526
+ position: relative;
527
+ }
528
+
529
+ dt::before,
530
+ dd::before {
531
+ position: absolute;
532
+ left: -.875em;
533
+ }
534
+
535
+ dt::before {
536
+ content: "\203A";
537
+ }
538
+
539
+ dd::before {
540
+ content: "\00BB";
541
+ }
542
+
543
+
544
+ /* Ordered List */
545
+
546
+ ol {
547
+ list-style-type: decimal;
548
+ }
549
+
550
+ ol ol {
551
+ list-style-type: lower-alpha;
552
+ }
553
+
554
+ ol ol ol {
555
+ list-style-type: lower-roman;
556
+ }
557
+
558
+
559
+ /* Marked Cards */
560
+
561
+ blockquote, fieldset, address, figure,
562
+ del:has(p, pre, details, fieldset, table, dl),
563
+ ins:has(p, pre, details, fieldset, table, dl),
564
+ a[href]:has(p, pre, details, fieldset, table, dl)
565
+ {
566
+ border: 1px solid currentColor;
567
+ padding: 0 calc(1.5 * var(--bbg)) calc(.5 * var(--bbg));
568
+ position: relative;
569
+ font-style: normal;
570
+ display: block;
571
+ text-decoration: none;
572
+ color: inherit;
573
+ }
574
+
575
+ blockquote::before,
576
+ blockquote::after,
577
+ address::before,
578
+ address::after,
579
+ del:has(p, pre, details, fieldset, table, dl)::before,
580
+ del:has(p, pre, details, fieldset, table, dl)::after,
581
+ ins:has(p, pre, details, fieldset, table, dl)::before,
582
+ ins:has(p, pre, details, fieldset, table, dl)::after,
583
+ a[href]:has(p, pre, details, fieldset, table, dl)::before,
584
+ a[href]:has(p, pre, details, fieldset, table, dl)::after
585
+ {
586
+ content: "";
587
+ position: absolute;
588
+ left: .2em;
589
+ display: flex;
590
+ width: .4em;
591
+ height: .4em;
592
+ background-color: currentColor;
593
+ }
594
+
595
+ blockquote::before {
596
+ top: .2em;
597
+ clip-path: polygon(77% 96%, 22% 96%, 22% 48%, 53% 4%, 72% 4%, 51% 48%, 77% 48%, 77% 96%);
598
+ }
599
+
600
+ blockquote::after {
601
+ bottom: .2em;
602
+ clip-path: polygon(23% 4%, 78% 4%, 78% 52%, 47% 96%, 28% 96%, 49% 52%, 23% 52%, 23% 4%);
603
+ }
604
+
605
+ address::before {
606
+ top: .15em;
607
+ clip-path: circle(30% at 50% 50%);
608
+ }
609
+
610
+ address::after {
611
+ bottom: .15em;
612
+ clip-path: circle(30% at 50% 50%);
613
+ }
614
+
615
+ del:has(p, pre, details, fieldset, table, dl)::before {
616
+ top: .2em;
617
+ clip-path: polygon(100% 60%, 0% 60%, 0% 40%, 100% 40%, 100% 60%);
618
+ }
619
+
620
+ del:has(p, pre, details, fieldset, table, dl)::after {
621
+ bottom: .2em;
622
+ clip-path: polygon(100% 60%, 0% 60%, 0% 40%, 100% 40%, 100% 60%);
623
+ }
624
+
625
+ ins:has(p, pre, details, fieldset, table, dl)::before {
626
+ top: .2em;
627
+ clip-path: polygon(60% 40%, 100% 40%, 100% 60%, 60% 60%, 60% 100%, 40% 100%, 40% 60%, 0% 60%, 0% 40%, 40% 40%, 40% 0%, 60% 0%, 60% 40%);
628
+ }
629
+
630
+ ins:has(p, pre, details, fieldset, table, dl)::after {
631
+ bottom: .2em;
632
+ clip-path: polygon(60% 40%, 100% 40%, 100% 60%, 60% 60%, 60% 100%, 40% 100%, 40% 60%, 0% 60%, 0% 40%, 40% 40%, 40% 0%, 60% 0%, 60% 40%);
633
+ }
634
+
635
+ a[href]:has(p, pre, details, fieldset, table, dl)::before {
636
+ top: .2em;
637
+ clip-path: polygon(100% 0%, 100% 70%, 72% 42%, 22% 92%, 8% 78%, 58% 28%, 30% 0%, 100% 0%);
638
+ }
639
+
640
+ a[href]:has(p, pre, details, fieldset, table, dl)::after {
641
+ bottom: .2em;
642
+ clip-path: polygon(100% 0%, 100% 70%, 72% 42%, 22% 92%, 8% 78%, 58% 28%, 30% 0%, 100% 0%);
643
+ }
644
+
645
+
646
+
647
+ /* Scrollable Pres */
648
+ pre {
649
+ padding: 1em;
650
+ border: 1px solid currentColor;
651
+ overflow: auto;
652
+ }
653
+
654
+
655
+
656
+
657
+ /* Trued Forms */
658
+
659
+ select,
660
+ button,
661
+ input:not([type]),
662
+ input[type=tel],
663
+ input[type=url],
664
+ input[type=text],
665
+ input[type=date],
666
+ input[type=week],
667
+ input[type=time],
668
+ input[type=file],
669
+ input[type=email],
670
+ input[type=month],
671
+ input[type=color],
672
+ input[type=reset],
673
+ input[type=submit],
674
+ input[type=button],
675
+ input[type=number],
676
+ input[type=search],
677
+ input[type=password],
678
+ input[type=datetime-local] {
679
+ border: 1px solid;
680
+ font: inherit;
681
+ padding: 0 .5em .15em;
682
+ height: 2em;
683
+ vertical-align: middle;
684
+ line-height: 1.2;
685
+ }
686
+
687
+ select {
688
+ padding-inline: .15em 1.5em;
689
+ }
690
+
691
+ input[type=range]
692
+ {
693
+ vertical-align: middle;
694
+ }
695
+
696
+ input[type=radio], input[type=checkbox] {
697
+ width: 1em;
698
+ height: 1em;
699
+ font: inherit;
700
+ vertical-align: -.15em;
701
+ outline-offset: 0;
702
+ }
703
+
704
+ textarea {
705
+ border: 1px solid currentColor;
706
+ font: inherit;
707
+ padding: 0 .5em .25em;
708
+ }
709
+
710
+
711
+
712
+ /* Pointed Interractables */
713
+ summary,
714
+ a,
715
+ label,
716
+ button,
717
+ select,
718
+ input[type=date],
719
+ input[type=week],
720
+ input[type=time],
721
+ input[type=file],
722
+ input[type=month],
723
+ input[type=color],
724
+ input[type=reset],
725
+ input[type=range],
726
+ input[type=radio],
727
+ input[type=button],
728
+ input[type=submit],
729
+ input[type=checkbox],
730
+ input[type=datetime-local] {
731
+ cursor: pointer;
732
+ }
733
+
734
+
735
+
736
+
737
+
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@toheeb/base",
3
+ "version": "1.0.0",
4
+ "description": "A classless stylesheet for Personalizable Web Design",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "keywords": ["css"],
10
+ "author": "2",
11
+ "license": "AGPL-3.0-or-later"
12
+ }