@toheeb/base 1.5.6 → 1.6.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/base-settings.js +54 -39
- package/base.html +10 -0
- package/package.json +1 -1
package/base-settings.js
CHANGED
|
@@ -86,7 +86,7 @@ class BaseSettings extends HTMLElement {
|
|
|
86
86
|
</main>
|
|
87
87
|
</dialog>
|
|
88
88
|
<style>
|
|
89
|
-
._bs {
|
|
89
|
+
:where(._bs) {
|
|
90
90
|
box-shadow:
|
|
91
91
|
-0px -0px 1px oklch(from currentColor l c h / .01),
|
|
92
92
|
-2px -2px 3px oklch(from currentColor l c h / .03),
|
|
@@ -105,7 +105,7 @@ class BaseSettings extends HTMLElement {
|
|
|
105
105
|
(color: oklch(0 0 0)) and
|
|
106
106
|
(color: light-dark(#000, #fff))
|
|
107
107
|
{
|
|
108
|
-
._bs {
|
|
108
|
+
:where(._bs) {
|
|
109
109
|
background-color: light-dark(
|
|
110
110
|
oklch(1 0.003 var(--base-color-hue)),
|
|
111
111
|
oklch(0.22 .03 var(--base-color-hue))
|
|
@@ -113,11 +113,11 @@ class BaseSettings extends HTMLElement {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
dialog::backdrop {
|
|
116
|
+
:where(dialog::backdrop) {
|
|
117
117
|
background: transparent;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
._bs button[type=submit] {
|
|
120
|
+
:where(._bs button[type=submit]) {
|
|
121
121
|
display: flex;
|
|
122
122
|
justify-content: center;
|
|
123
123
|
align-items: center;
|
|
@@ -126,13 +126,13 @@ class BaseSettings extends HTMLElement {
|
|
|
126
126
|
padding: .25em;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
._bs form {
|
|
129
|
+
:where(._bs form) {
|
|
130
130
|
display: grid;
|
|
131
131
|
width: 100%;
|
|
132
132
|
gap: calc(.5 * var(--bbg));
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
._bs p {
|
|
135
|
+
:where(._bs p) {
|
|
136
136
|
width: 100%;
|
|
137
137
|
display: flex;
|
|
138
138
|
flex-flow: row wrap;
|
|
@@ -140,22 +140,22 @@ class BaseSettings extends HTMLElement {
|
|
|
140
140
|
gap: calc(.25 * var(--bbg)) calc(.75 * var(--bbg));
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
._bs .modes {
|
|
143
|
+
:where(._bs .modes) {
|
|
144
144
|
margin-top: var(--bbg);
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
._bs .fields label:not([hidden]) {
|
|
147
|
+
:where(._bs .fields label:not([hidden])) {
|
|
148
148
|
display: grid;
|
|
149
149
|
gap: .25em;
|
|
150
150
|
flex: 1 1 calc(50% - calc(.75 * var(--bbg)));
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
._bs .fields span {
|
|
153
|
+
:where(._bs .fields span) {
|
|
154
154
|
font-size: calc(var(--bfs-075) * 1rem);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
._bs .fields input,
|
|
158
|
-
._bs .fields select
|
|
157
|
+
:where(._bs .fields input),
|
|
158
|
+
:where(._bs .fields select)
|
|
159
159
|
{
|
|
160
160
|
width: 100%;
|
|
161
161
|
}
|
|
@@ -214,7 +214,7 @@ class BaseSettings extends HTMLElement {
|
|
|
214
214
|
|
|
215
215
|
if (has_other_sheet) {
|
|
216
216
|
label_mode_indent.hidden = true;
|
|
217
|
-
|
|
217
|
+
this.querySelector("#base-mode-indent").checked = false;
|
|
218
218
|
} else {
|
|
219
219
|
|
|
220
220
|
if (mode_indent) {
|
|
@@ -230,25 +230,27 @@ class BaseSettings extends HTMLElement {
|
|
|
230
230
|
// Font Family
|
|
231
231
|
{
|
|
232
232
|
const font_family = root_styles.getPropertyValue("--base-font-family").trim();
|
|
233
|
+
const font_family_toggle = root_styles.getPropertyValue("--base-font-family-toggle").trim();
|
|
233
234
|
const label_font_family = this.querySelector("#base-font-family").closest("label");
|
|
234
|
-
|
|
235
|
-
if (
|
|
235
|
+
|
|
236
|
+
if (parseInt(font_family_toggle) == 0) {
|
|
237
|
+
label_font_family.hidden = true;
|
|
238
|
+
} else {
|
|
236
239
|
label_font_family.hidden = false;
|
|
237
|
-
|
|
240
|
+
|
|
238
241
|
const def_typefaces = ["serif", "sans-serif", "cursive", "system-ui", "monospace"];
|
|
239
|
-
|
|
242
|
+
|
|
240
243
|
if (def_typefaces.includes(font_family.toLowerCase())) {
|
|
241
244
|
} else {
|
|
242
245
|
const option = document.createElement("option");
|
|
243
|
-
|
|
246
|
+
|
|
244
247
|
option.value = font_family;
|
|
245
248
|
option.textContent = font_family;
|
|
246
249
|
this.querySelector("#base-font-family").append(option);
|
|
247
250
|
}
|
|
248
251
|
|
|
249
252
|
this.querySelector("#base-font-family").value = font_family;
|
|
250
|
-
|
|
251
|
-
label_font_family.hidden = true;
|
|
253
|
+
|
|
252
254
|
}
|
|
253
255
|
|
|
254
256
|
}
|
|
@@ -256,23 +258,29 @@ class BaseSettings extends HTMLElement {
|
|
|
256
258
|
// Font Size
|
|
257
259
|
{
|
|
258
260
|
const font_size = root_styles.getPropertyValue("--base-font-size").trim();
|
|
261
|
+
const font_size_toggle = root_styles.getPropertyValue("--base-font-size-toggle").trim();
|
|
259
262
|
const label_font_size = this.querySelector("#base-font-size").closest("label");
|
|
260
263
|
const positive_numbers = /^\d+\.?\d*$/;
|
|
261
264
|
|
|
262
|
-
if (
|
|
263
|
-
label_font_size.hidden = false;
|
|
264
|
-
this.querySelector("#base-font-size").value = font_size;
|
|
265
|
-
} else {
|
|
265
|
+
if (parseInt(font_size_toggle) == 0) {
|
|
266
266
|
label_font_size.hidden = true;
|
|
267
|
+
} else {
|
|
268
|
+
if (positive_numbers.test(font_size)) {
|
|
269
|
+
label_font_size.hidden = false;
|
|
270
|
+
this.querySelector("#base-font-size").value = font_size;
|
|
271
|
+
}
|
|
267
272
|
}
|
|
268
273
|
}
|
|
269
274
|
|
|
270
275
|
// Font Scale
|
|
271
276
|
{
|
|
272
277
|
const font_scale = root_styles.getPropertyValue("--base-font-scale").trim();
|
|
278
|
+
const font_scale_toggle = root_styles.getPropertyValue("--base-font-scale-toggle").trim();
|
|
273
279
|
const label_font_scale = this.querySelector("#base-font-scale").closest("label");
|
|
274
|
-
|
|
275
|
-
if (
|
|
280
|
+
|
|
281
|
+
if (parseInt(font_scale_toggle) == 0) {
|
|
282
|
+
label_font_scale.hidden = true;
|
|
283
|
+
} else {
|
|
276
284
|
label_font_scale.hidden = false;
|
|
277
285
|
|
|
278
286
|
const scale_set = [1.067, 1.125, 1.2, 1.25, 1.333, 1.414, 1.5, 1.618];
|
|
@@ -287,8 +295,6 @@ class BaseSettings extends HTMLElement {
|
|
|
287
295
|
}
|
|
288
296
|
|
|
289
297
|
this.querySelector("#base-font-scale").value = font_scale;
|
|
290
|
-
} else {
|
|
291
|
-
label_font_scale.hidden = true;
|
|
292
298
|
}
|
|
293
299
|
|
|
294
300
|
}
|
|
@@ -296,41 +302,50 @@ class BaseSettings extends HTMLElement {
|
|
|
296
302
|
// Line Height
|
|
297
303
|
{
|
|
298
304
|
const line_height = root_styles.getPropertyValue("--base-line-height").trim();
|
|
305
|
+
const line_height_toggle = root_styles.getPropertyValue("--base-line-height-toggle").trim();
|
|
299
306
|
const label_line_height = this.querySelector("#base-line-height").closest("label");
|
|
300
307
|
const positive_numbers = /^\d*\.?\d*$/;
|
|
301
308
|
|
|
302
|
-
if (
|
|
303
|
-
label_line_height.hidden = false;
|
|
304
|
-
this.querySelector("#base-line-height").value = line_height;
|
|
305
|
-
} else {
|
|
309
|
+
if (parseInt(line_height_toggle) == 0) {
|
|
306
310
|
label_line_height.hidden = true;
|
|
311
|
+
} else {
|
|
312
|
+
if (positive_numbers.test(line_height)) {
|
|
313
|
+
label_line_height.hidden = false;
|
|
314
|
+
this.querySelector("#base-line-height").value = line_height;
|
|
315
|
+
}
|
|
307
316
|
}
|
|
308
317
|
}
|
|
309
318
|
|
|
310
319
|
// Line Length
|
|
311
320
|
{
|
|
312
321
|
const line_length = root_styles.getPropertyValue("--base-line-length").trim();
|
|
322
|
+
const line_length_toggle = root_styles.getPropertyValue("--base-line-length-toggle").trim();
|
|
313
323
|
const label_line_length = this.querySelector("#base-line-length").closest("label");
|
|
314
324
|
|
|
315
|
-
if (
|
|
316
|
-
label_line_length.hidden = false;
|
|
317
|
-
this.querySelector("#base-line-length").value = parseFloat(line_length);
|
|
318
|
-
} else {
|
|
325
|
+
if (parseInt(line_length_toggle) == 0) {
|
|
319
326
|
label_line_length.hidden = true;
|
|
327
|
+
} else {
|
|
328
|
+
if (parseFloat(line_length)) {
|
|
329
|
+
label_line_length.hidden = false;
|
|
330
|
+
this.querySelector("#base-line-length").value = parseFloat(line_length);
|
|
331
|
+
}
|
|
320
332
|
}
|
|
321
333
|
}
|
|
322
334
|
|
|
323
335
|
// Block Gap
|
|
324
336
|
{
|
|
325
337
|
const block_gap = root_styles.getPropertyValue("--base-block-gap").trim();
|
|
338
|
+
const block_gap_toggle = root_styles.getPropertyValue("--base-block-gap-toggle").trim();
|
|
326
339
|
const label_block_gap = this.querySelector("#base-block-gap").closest("label");
|
|
327
340
|
const positive_numbers = /^\d*\.?\d*$/;
|
|
328
341
|
|
|
329
|
-
if (
|
|
330
|
-
label_block_gap.hidden = false;
|
|
331
|
-
this.querySelector("#base-block-gap").value = block_gap;
|
|
332
|
-
} else {
|
|
342
|
+
if (parseInt(block_gap_toggle) == 0) {
|
|
333
343
|
label_block_gap.hidden = true;
|
|
344
|
+
} else {
|
|
345
|
+
if (positive_numbers.test(block_gap)) {
|
|
346
|
+
label_block_gap.hidden = false;
|
|
347
|
+
this.querySelector("#base-block-gap").value = block_gap;
|
|
348
|
+
}
|
|
334
349
|
}
|
|
335
350
|
}
|
|
336
351
|
|
package/base.html
CHANGED
|
@@ -8,6 +8,16 @@
|
|
|
8
8
|
<link rel="stylesheet" href="./base.css" title="Base">
|
|
9
9
|
<meta name="color-scheme" content="darks slight">
|
|
10
10
|
<script src="./base-settings.js"></script>
|
|
11
|
+
<style>
|
|
12
|
+
:root {
|
|
13
|
+
/* --base-font-family-toggle: 0;
|
|
14
|
+
--base-font-scale-toggle: 0;
|
|
15
|
+
--base-font-size-toggle: 0;
|
|
16
|
+
--base-line-length-toggle: 0;
|
|
17
|
+
--base-line-height-toggle: 0;
|
|
18
|
+
--base-block-gap-toggle: 0; */
|
|
19
|
+
}
|
|
20
|
+
</style>
|
|
11
21
|
</head>
|
|
12
22
|
|
|
13
23
|
<body>
|