@yuneta/gobj-ui 7.32.5 → 7.32.6
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/README.md +45 -3
- package/dist/gobj-ui.cjs.js +132 -107
- package/dist/gobj-ui.es.js +132 -107
- package/package.json +1 -1
- package/src/lib_icons.js +35 -4
- package/src/lib_icons.test.js +23 -0
- package/src/tabulator.css +81 -0
- package/src/tabulator_css.test.js +40 -49
- package/src/yui_icons.css +80 -8
- package/src/yui_icons.test.js +95 -0
package/package.json
CHANGED
package/src/lib_icons.js
CHANGED
|
@@ -403,8 +403,8 @@ export function rebuild_svg_from_shapes(root)
|
|
|
403
403
|
}
|
|
404
404
|
|
|
405
405
|
/*
|
|
406
|
-
* The viewBox is what scales the drawing into the
|
|
407
|
-
* icon. Without one, the width and height of the root say the size
|
|
406
|
+
* The viewBox is what scales the drawing into the box of an
|
|
407
|
+
* icon (svg_icon_width). Without one, the width and height of the root say the size
|
|
408
408
|
* it was drawn at, and that is the box.
|
|
409
409
|
*/
|
|
410
410
|
let view_box = (root.getAttribute("viewBox") || "").trim();
|
|
@@ -464,6 +464,32 @@ export function svg_mask_url(svg)
|
|
|
464
464
|
return `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
|
|
465
465
|
}
|
|
466
466
|
|
|
467
|
+
/************************************************************
|
|
468
|
+
* The width of the box of an icon, in em: 1, or more for a
|
|
469
|
+
* drawing wider than tall, so that it is 1em TALL like every
|
|
470
|
+
* icon (yui_icons.css, "THE BOX"). Its viewBox says the ratio.
|
|
471
|
+
*
|
|
472
|
+
* Capped at 1.25em, the widest icon of Font Awesome: a wider
|
|
473
|
+
* drawing is a logo or a banner, and a box any wider would
|
|
474
|
+
* push the controls of its row aside. It is drawn smaller.
|
|
475
|
+
************************************************************/
|
|
476
|
+
export const USER_ICON_MAX_WIDTH = 1.25;
|
|
477
|
+
|
|
478
|
+
export function svg_icon_width(svg)
|
|
479
|
+
{
|
|
480
|
+
let m = /viewBox="([^"]*)"/.exec(String(svg || ""));
|
|
481
|
+
if(!m) {
|
|
482
|
+
return 1;
|
|
483
|
+
}
|
|
484
|
+
let parts = m[1].trim().split(/[\s,]+/).map(Number);
|
|
485
|
+
let w = parts[2];
|
|
486
|
+
let h = parts[3];
|
|
487
|
+
if(!(w > 0 && h > 0) || w <= h) {
|
|
488
|
+
return 1;
|
|
489
|
+
}
|
|
490
|
+
return Math.round(Math.min(w / h, USER_ICON_MAX_WIDTH) * 1000) / 1000;
|
|
491
|
+
}
|
|
492
|
+
|
|
467
493
|
/************************************************************
|
|
468
494
|
* An element that shows an svg as an icon, before it is
|
|
469
495
|
* registered (a form preview, a cell of __icons__ itself).
|
|
@@ -480,6 +506,10 @@ export function yui_svg_icon_element(svg_text)
|
|
|
480
506
|
let mask = svg_mask_url(clean.svg);
|
|
481
507
|
el.style.setProperty("-webkit-mask-image", mask);
|
|
482
508
|
el.style.setProperty("mask-image", mask);
|
|
509
|
+
let width = svg_icon_width(clean.svg);
|
|
510
|
+
if(width > 1) {
|
|
511
|
+
el.style.setProperty("width", `${width}em`);
|
|
512
|
+
}
|
|
483
513
|
return {element: el, dropped: clean.dropped};
|
|
484
514
|
}
|
|
485
515
|
|
|
@@ -490,8 +520,9 @@ function rebuild_user_icons_stylesheet()
|
|
|
490
520
|
{
|
|
491
521
|
let css = "";
|
|
492
522
|
for(const [id, icon] of __user_icons__) {
|
|
523
|
+
let width = (icon.width > 1) ? ` width: ${icon.width}em;` : "";
|
|
493
524
|
css += `.${yui_user_icon_class(id)}::before {` +
|
|
494
|
-
`-webkit-mask-image: ${icon.mask}; mask-image: ${icon.mask}
|
|
525
|
+
`-webkit-mask-image: ${icon.mask}; mask-image: ${icon.mask};${width}}\n`;
|
|
495
526
|
}
|
|
496
527
|
|
|
497
528
|
try {
|
|
@@ -530,7 +561,7 @@ function user_icon_entry(node)
|
|
|
530
561
|
log_warning(`user icons: icon '${id}' not drawn: ${clean.error}`);
|
|
531
562
|
return null;
|
|
532
563
|
}
|
|
533
|
-
return {svg: clean.svg, mask: svg_mask_url(clean.svg)};
|
|
564
|
+
return {svg: clean.svg, mask: svg_mask_url(clean.svg), width: svg_icon_width(clean.svg)};
|
|
534
565
|
}
|
|
535
566
|
|
|
536
567
|
/************************************************************
|
package/src/lib_icons.test.js
CHANGED
|
@@ -28,6 +28,8 @@ const {
|
|
|
28
28
|
yui_icons_put_user,
|
|
29
29
|
yui_icons_remove_user,
|
|
30
30
|
yui_icons_list,
|
|
31
|
+
svg_icon_width,
|
|
32
|
+
USER_ICON_MAX_WIDTH,
|
|
31
33
|
USER_ICON_PREFIX,
|
|
32
34
|
ICONS_TOPIC,
|
|
33
35
|
} = await import("./lib_icons.js");
|
|
@@ -163,6 +165,7 @@ test("a user icon lives in its own namespace", () => {
|
|
|
163
165
|
const TREES = {
|
|
164
166
|
"bolt": BOLT,
|
|
165
167
|
"box": el("svg", {viewBox: "0 0 2 2"}, [el("rect", {width: "2", height: "2"})]),
|
|
168
|
+
"wide": el("svg", {viewBox: "0 0 576 512"}, [el("rect", {width: "576", height: "512"})]),
|
|
166
169
|
"empty": el("svg", {viewBox: "0 0 2 2"}, [])
|
|
167
170
|
};
|
|
168
171
|
|
|
@@ -212,3 +215,23 @@ test("a write puts or takes away one icon", () => {
|
|
|
212
215
|
expect(user_css()).toBe("");
|
|
213
216
|
expect(yui_icons_list().filter(icon => icon.user)).toEqual([]);
|
|
214
217
|
});
|
|
218
|
+
|
|
219
|
+
/*
|
|
220
|
+
* Every icon is 1em TALL (yui_icons.css, "THE BOX"): a drawing wider
|
|
221
|
+
* than tall gets a wider box, up to the widest of Font Awesome.
|
|
222
|
+
*/
|
|
223
|
+
test("the box of a user icon is as wide as its drawing, up to a cap", () => {
|
|
224
|
+
expect(svg_icon_width('<svg viewBox="0 0 24 24"></svg>')).toBe(1);
|
|
225
|
+
expect(svg_icon_width('<svg viewBox="0 0 384 512"></svg>')).toBe(1);
|
|
226
|
+
expect(svg_icon_width('<svg viewBox="0 0 576 512"></svg>')).toBe(1.125);
|
|
227
|
+
expect(svg_icon_width('<svg viewBox="0,0,640,512"></svg>')).toBe(1.25);
|
|
228
|
+
expect(svg_icon_width('<svg viewBox="0 0 1000 100"></svg>')).toBe(USER_ICON_MAX_WIDTH);
|
|
229
|
+
expect(svg_icon_width('<svg></svg>')).toBe(1);
|
|
230
|
+
expect(svg_icon_width('<svg viewBox="0 0 0 0"></svg>')).toBe(1);
|
|
231
|
+
|
|
232
|
+
yui_icons_set_user([{id: "box", svg: "box"}, {id: "wide", svg: "wide"}]);
|
|
233
|
+
let css = user_css();
|
|
234
|
+
expect(css).toMatch(/\.yi-u-wide::before \{[^}]*; width: 1\.125em;\}/);
|
|
235
|
+
expect(css).not.toMatch(/\.yi-u-box::before \{[^}]*; width: /);
|
|
236
|
+
yui_icons_set_user([]);
|
|
237
|
+
});
|
package/src/tabulator.css
CHANGED
|
@@ -35,6 +35,87 @@
|
|
|
35
35
|
white-space: nowrap;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/* ====================================================================
|
|
39
|
+
* The paginator on a NARROW screen: icons, and one line.
|
|
40
|
+
*
|
|
41
|
+
* On a phone the words of the paginator ("Rows per page", First, Prev,
|
|
42
|
+
* the pages, Next, Last) took three lines of the footer. At the mobile
|
|
43
|
+
* width of Bulma (768px, where `is-hidden-mobile` hides a label):
|
|
44
|
+
*
|
|
45
|
+
* - First, Prev, Next, Last are the icons of the period navigator
|
|
46
|
+
* (C_YUI_PERIOD): |< < > >|. The word is hidden, and the name
|
|
47
|
+
* stays: Tabulator writes "First Page", ... as `title` and
|
|
48
|
+
* `aria-label`, in the table's language.
|
|
49
|
+
* - "Rows per page" is hidden. The select keeps the same text as its
|
|
50
|
+
* `title` and `aria-label`.
|
|
51
|
+
* - Of the numbered pages only the current one shows: the steps and the
|
|
52
|
+
* ends reach the others.
|
|
53
|
+
*
|
|
54
|
+
* The paginator is the toolbar at the bottom of the table, and its
|
|
55
|
+
* icons are the size of the icons of the toolbar above it: 1.25rem,
|
|
56
|
+
* `YUI_TOOLBAR_ICON_SIZE` of yui_toolbar.js (tabulator_css.test.js
|
|
57
|
+
* keeps the two equal). Every button of the paginator is the same
|
|
58
|
+
* 2rem box. The masks come from yui_icons.css (`--yi-backward-step`,
|
|
59
|
+
* ...): a button that Tabulator draws takes no class, and the path of
|
|
60
|
+
* each icon is written once.
|
|
61
|
+
* ==================================================================== */
|
|
62
|
+
@media screen and (max-width: 768px) {
|
|
63
|
+
.tabulator .tabulator-footer .tabulator-paginator > label {
|
|
64
|
+
display: none;
|
|
65
|
+
}
|
|
66
|
+
.tabulator .tabulator-footer .tabulator-pages {
|
|
67
|
+
margin: 0 2px;
|
|
68
|
+
}
|
|
69
|
+
.tabulator .tabulator-footer .tabulator-pages .tabulator-page:not(.active) {
|
|
70
|
+
display: none;
|
|
71
|
+
}
|
|
72
|
+
.tabulator .tabulator-footer .tabulator-page {
|
|
73
|
+
display: inline-flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
justify-content: center;
|
|
76
|
+
min-width: 2rem;
|
|
77
|
+
height: 2rem;
|
|
78
|
+
padding: 0 0.25rem;
|
|
79
|
+
vertical-align: middle;
|
|
80
|
+
}
|
|
81
|
+
/* `data-page` names the four ends and steps, and the NUMBER of each
|
|
82
|
+
* numbered page too: name them one by one. */
|
|
83
|
+
.tabulator .tabulator-footer .tabulator-page:is([data-page=first], [data-page=prev],
|
|
84
|
+
[data-page=next], [data-page=last]) {
|
|
85
|
+
font-size: 0;
|
|
86
|
+
}
|
|
87
|
+
.tabulator .tabulator-footer .tabulator-page:is([data-page=first], [data-page=prev],
|
|
88
|
+
[data-page=next], [data-page=last])::before {
|
|
89
|
+
content: "";
|
|
90
|
+
display: inline-block;
|
|
91
|
+
width: 1.25rem;
|
|
92
|
+
height: 1.25rem;
|
|
93
|
+
background-color: currentColor;
|
|
94
|
+
-webkit-mask-repeat: no-repeat;
|
|
95
|
+
mask-repeat: no-repeat;
|
|
96
|
+
-webkit-mask-position: center;
|
|
97
|
+
mask-position: center;
|
|
98
|
+
-webkit-mask-size: contain;
|
|
99
|
+
mask-size: contain;
|
|
100
|
+
}
|
|
101
|
+
.tabulator .tabulator-footer .tabulator-page[data-page=first]::before {
|
|
102
|
+
-webkit-mask-image: var(--yi-backward-step);
|
|
103
|
+
mask-image: var(--yi-backward-step);
|
|
104
|
+
}
|
|
105
|
+
.tabulator .tabulator-footer .tabulator-page[data-page=prev]::before {
|
|
106
|
+
-webkit-mask-image: var(--yi-chevron-left);
|
|
107
|
+
mask-image: var(--yi-chevron-left);
|
|
108
|
+
}
|
|
109
|
+
.tabulator .tabulator-footer .tabulator-page[data-page=next]::before {
|
|
110
|
+
-webkit-mask-image: var(--yi-chevron-right);
|
|
111
|
+
mask-image: var(--yi-chevron-right);
|
|
112
|
+
}
|
|
113
|
+
.tabulator .tabulator-footer .tabulator-page[data-page=last]::before {
|
|
114
|
+
-webkit-mask-image: var(--yi-forward-step);
|
|
115
|
+
mask-image: var(--yi-forward-step);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
38
119
|
/* ====================================================================
|
|
39
120
|
* Active / selected row highlight.
|
|
40
121
|
* Green wash + left accent, theme-aware, with enough specificity
|
|
@@ -1,63 +1,54 @@
|
|
|
1
1
|
/***********************************************************************
|
|
2
2
|
* tabulator_css.test.js
|
|
3
3
|
*
|
|
4
|
-
* The
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* tickCross editor of an app's "validated" opened as a huge
|
|
8
|
-
* empty box on a phone, gobj-ui 7.26.36).
|
|
9
|
-
*
|
|
10
|
-
* Read as text, as the window layer's invariants are: jsdom applies
|
|
11
|
-
* no stylesheet.
|
|
4
|
+
* The paginator on a narrow screen (tabulator.css): its icons are
|
|
5
|
+
* the size of the icons of a view's toolbar, and each step button
|
|
6
|
+
* reads its mask from a property that yui_icons.css defines.
|
|
12
7
|
*
|
|
13
8
|
* Copyright (c) 2026, ArtGins.
|
|
14
9
|
* All Rights Reserved.
|
|
15
10
|
***********************************************************************/
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
18
|
-
import {
|
|
19
|
-
|
|
11
|
+
import {test, expect} from "vitest";
|
|
12
|
+
import fs from "node:fs";
|
|
13
|
+
import {install_dom_double} from "../test/dom_double.js";
|
|
14
|
+
|
|
15
|
+
install_dom_double();
|
|
20
16
|
|
|
21
|
-
const
|
|
22
|
-
.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
17
|
+
const {YUI_TOOLBAR_ICON_SIZE} = await import("./yui_toolbar.js");
|
|
23
18
|
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
const CSS = fs.readFileSync(new URL("./tabulator.css", import.meta.url), "utf8");
|
|
20
|
+
const ICONS = fs.readFileSync(new URL("./yui_icons.css", import.meta.url), "utf8");
|
|
21
|
+
|
|
22
|
+
/* The block of the narrow screen. */
|
|
23
|
+
function narrow()
|
|
26
24
|
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
while((m = re.exec(CSS)) !== null) {
|
|
31
|
-
out.push({
|
|
32
|
-
selectors: m[1].split(",").map((s) => s.trim()).filter(Boolean),
|
|
33
|
-
body: m[2]
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return out;
|
|
25
|
+
let start = CSS.indexOf("@media screen and (max-width: 768px) {");
|
|
26
|
+
expect(start).toBeGreaterThan(0);
|
|
27
|
+
return CSS.slice(start, CSS.indexOf("\n}\n", start));
|
|
37
28
|
}
|
|
38
29
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
30
|
+
test("the paginator's icons are the size of the toolbar's", () => {
|
|
31
|
+
let m = /\[data-page=last\]\)::before \{[^}]*?width: ([\d.]+rem);\s*height: ([\d.]+rem);/.exec(narrow());
|
|
32
|
+
expect(m).not.toBeNull();
|
|
33
|
+
expect(m[1]).toBe(YUI_TOOLBAR_ICON_SIZE);
|
|
34
|
+
expect(m[2]).toBe(YUI_TOOLBAR_ICON_SIZE);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("each step has the icon of the period navigator, from yui_icons.css", () => {
|
|
38
|
+
const STEPS = {
|
|
39
|
+
first: "yi-backward-step",
|
|
40
|
+
prev: "yi-chevron-left",
|
|
41
|
+
next: "yi-chevron-right",
|
|
42
|
+
last: "yi-forward-step"
|
|
43
|
+
};
|
|
44
|
+
for(const [page, icon] of Object.entries(STEPS)) {
|
|
45
|
+
expect(narrow()).toMatch(new RegExp(
|
|
46
|
+
`\\[data-page=${page}\\]::before \\{\\s*-webkit-mask-image: var\\(--${icon}\\);` +
|
|
47
|
+
`\\s*mask-image: var\\(--${icon}\\);`));
|
|
48
|
+
expect(ICONS).toMatch(new RegExp(`\\n {4}--${icon}: url\\(`));
|
|
49
|
+
}
|
|
50
|
+
});
|
|
57
51
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
r.selectors.some((s) => /tabulator-editing input:not\(\[type=checkbox\]\)/.test(s)));
|
|
61
|
-
expect(fill.length).toBeGreaterThan(0);
|
|
62
|
-
});
|
|
52
|
+
test("the numbered pages keep their number: only the steps lose the word", () => {
|
|
53
|
+
expect(narrow()).not.toMatch(/\.tabulator-page\[data-page\]/);
|
|
63
54
|
});
|
package/src/yui_icons.css
CHANGED
|
@@ -26,6 +26,78 @@
|
|
|
26
26
|
vertical-align: -0.125em;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/*
|
|
30
|
+
* The masks of the NAVIGATION icons, as custom properties: a widget
|
|
31
|
+
* that draws its own DOM (Tabulator's paginator, tabulator.css) puts
|
|
32
|
+
* them on an element it cannot give a class to. One copy of each path:
|
|
33
|
+
* the classes below read the same property.
|
|
34
|
+
*/
|
|
35
|
+
:root {
|
|
36
|
+
--yi-backward-step: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 512'%3E%3Cpath d='M267.5 440.6c9.5 7.9 22.8 9.7 34.1 4.4s18.4-16.6 18.4-29l0-320c0-12.4-7.2-23.7-18.4-29s-24.5-3.6-34.1 4.4l-192 160L64 241l0-145c0-17.7-14.3-32-32-32S0 78.3 0 96L0 416c0 17.7 14.3 32 32 32s32-14.3 32-32l0-145 11.5 9.6 192 160z'/%3E%3C/svg%3E");
|
|
37
|
+
--yi-chevron-left: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 512'%3E%3Cpath d='M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z'/%3E%3C/svg%3E");
|
|
38
|
+
--yi-chevron-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 512'%3E%3Cpath d='M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z'/%3E%3C/svg%3E");
|
|
39
|
+
--yi-forward-step: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 320 512'%3E%3Cpath d='M52.5 440.6c-9.5 7.9-22.8 9.7-34.1 4.4S0 428.4 0 416L0 96C0 83.6 7.2 72.3 18.4 67s24.5-3.6 34.1 4.4l192 160L256 241l0-145c0-17.7 14.3-32 32-32s32 14.3 32 32l0 320c0 17.7-14.3 32-32 32s-32-14.3-32-32l0-145-11.5 9.6-192 160z'/%3E%3C/svg%3E");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
* THE BOX: every icon is 1em TALL.
|
|
44
|
+
*
|
|
45
|
+
* The box is 1em wide, and wider for a glyph that is wider than it is
|
|
46
|
+
* tall: its width is the width of its viewBox over its height (576 ->
|
|
47
|
+
* 1.125em, 640 -> 1.25em, the widest of Font Awesome). `mask-size:
|
|
48
|
+
* contain` then fills the height of the box with every glyph.
|
|
49
|
+
*
|
|
50
|
+
* Up to 7.32.5 every box was a 1em square, and `contain` drew a wide
|
|
51
|
+
* glyph SMALLER to fit its width: `yi-code` at 80% of the height,
|
|
52
|
+
* `yi-file-csv` at 89%, beside the full height of the square ones. A
|
|
53
|
+
* row of tool buttons showed icons of three sizes.
|
|
54
|
+
*
|
|
55
|
+
* A new icon whose viewBox is wider than tall goes in the list of its
|
|
56
|
+
* width below (yui_icons.test.js says which one is missing).
|
|
57
|
+
*/
|
|
58
|
+
.yi-broom::before,
|
|
59
|
+
.yi-language::before,
|
|
60
|
+
.yi-location-crosshairs::before,
|
|
61
|
+
.yi-sun::before,
|
|
62
|
+
.yi-terminal::before,
|
|
63
|
+
.yi-broom-wide::before,
|
|
64
|
+
.yi-eye::before,
|
|
65
|
+
.yi-eye-slash::before,
|
|
66
|
+
.yi-sitemap::before,
|
|
67
|
+
.yi-file-csv::before,
|
|
68
|
+
.yi-file-pdf::before,
|
|
69
|
+
.yi-user-slash::before,
|
|
70
|
+
.yi-user-clock::before,
|
|
71
|
+
.yi-wand-magic-sparkles::before,
|
|
72
|
+
.yi-clock-rotate-left::before,
|
|
73
|
+
.yi-bug::before,
|
|
74
|
+
.yi-folder-tree::before,
|
|
75
|
+
.yi-user-shield::before {
|
|
76
|
+
width: 1.125em;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.yi-arrows-to-eye::before,
|
|
80
|
+
.yi-cloudversify::before,
|
|
81
|
+
.yi-link::before,
|
|
82
|
+
.yi-code::before,
|
|
83
|
+
.yi-gears::before,
|
|
84
|
+
.yi-user-check::before,
|
|
85
|
+
.yi-robot::before,
|
|
86
|
+
.yi-user-plus::before {
|
|
87
|
+
width: 1.25em;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/*
|
|
91
|
+
* Bulma's `.icon` is a SQUARE of a fixed width (1.5rem, 1.5em in a
|
|
92
|
+
* button): a wide glyph of the list above hung out of it on both sides,
|
|
93
|
+
* into the control beside it (the code icon touched the back arrow in
|
|
94
|
+
* the bar of the shell on a 360px phone). It grows to hold its glyph,
|
|
95
|
+
* and stays the square for every other one.
|
|
96
|
+
*/
|
|
97
|
+
.icon:has(> [class^="yi-"], > [class*=" yi-"]) {
|
|
98
|
+
min-width: max-content;
|
|
99
|
+
}
|
|
100
|
+
|
|
29
101
|
/* --- Solid icons --- */
|
|
30
102
|
.yi-arrows-rotate::before {
|
|
31
103
|
-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath d='M65.9 228.5c13.3-93 93.4-164.5 190.1-164.5 53 0 101 21.5 135.8 56.2 .2 .2 .4 .4 .6 .6l7.6 7.2-47.9 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l128 0c17.7 0 32-14.3 32-32l0-128c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 53.4-11.3-10.7C390.5 28.6 326.5 0 256 0 127 0 20.3 95.4 2.6 219.5 .1 237 12.2 253.2 29.7 255.7s33.7-9.7 36.2-27.1zm443.5 64c2.5-17.5-9.7-33.7-27.1-36.2s-33.7 9.7-36.2 27.1c-13.3 93-93.4 164.5-190.1 164.5-53 0-101-21.5-135.8-56.2-.2-.2-.4-.4-.6-.6l-7.6-7.2 47.9 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 320c-8.5 0-16.7 3.4-22.7 9.5S-.1 343.7 0 352.3l1 127c.1 17.7 14.6 31.9 32.3 31.7S65.2 496.4 65 478.7l-.4-51.5 10.7 10.1c46.3 46.1 110.2 74.7 180.7 74.7 129 0 235.7-95.4 253.4-219.5z'/%3E%3C/svg%3E");
|
|
@@ -317,13 +389,13 @@
|
|
|
317
389
|
}
|
|
318
390
|
|
|
319
391
|
.yi-chevron-left::before {
|
|
320
|
-
-webkit-mask-image:
|
|
321
|
-
mask-image:
|
|
392
|
+
-webkit-mask-image: var(--yi-chevron-left);
|
|
393
|
+
mask-image: var(--yi-chevron-left);
|
|
322
394
|
}
|
|
323
395
|
|
|
324
396
|
.yi-chevron-right::before {
|
|
325
|
-
-webkit-mask-image:
|
|
326
|
-
mask-image:
|
|
397
|
+
-webkit-mask-image: var(--yi-chevron-right);
|
|
398
|
+
mask-image: var(--yi-chevron-right);
|
|
327
399
|
}
|
|
328
400
|
|
|
329
401
|
.yi-chevron-up::before {
|
|
@@ -332,8 +404,8 @@
|
|
|
332
404
|
}
|
|
333
405
|
|
|
334
406
|
.yi-forward-step::before {
|
|
335
|
-
-webkit-mask-image:
|
|
336
|
-
mask-image:
|
|
407
|
+
-webkit-mask-image: var(--yi-forward-step);
|
|
408
|
+
mask-image: var(--yi-forward-step);
|
|
337
409
|
}
|
|
338
410
|
|
|
339
411
|
.yi-calendar-days::before {
|
|
@@ -347,8 +419,8 @@
|
|
|
347
419
|
}
|
|
348
420
|
|
|
349
421
|
.yi-backward-step::before {
|
|
350
|
-
-webkit-mask-image:
|
|
351
|
-
mask-image:
|
|
422
|
+
-webkit-mask-image: var(--yi-backward-step);
|
|
423
|
+
mask-image: var(--yi-backward-step);
|
|
352
424
|
}
|
|
353
425
|
|
|
354
426
|
/* yi-bolt / yi-droplet: hand-drawn masks, for electricity and water:
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/***********************************************************************
|
|
2
|
+
* yui_icons.test.js
|
|
3
|
+
*
|
|
4
|
+
* The icon set (yui_icons.css): every icon is 1em TALL. The box of
|
|
5
|
+
* a glyph wider than tall is as wide as the glyph, so that
|
|
6
|
+
* `mask-size: contain` never draws it smaller than the others.
|
|
7
|
+
* And the masks a widget needs without a class (the paginator)
|
|
8
|
+
* are custom properties that the classes read too.
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2026, ArtGins.
|
|
11
|
+
* All Rights Reserved.
|
|
12
|
+
***********************************************************************/
|
|
13
|
+
import {test, expect} from "vitest";
|
|
14
|
+
import fs from "node:fs";
|
|
15
|
+
|
|
16
|
+
const CSS = fs.readFileSync(new URL("./yui_icons.css", import.meta.url), "utf8");
|
|
17
|
+
|
|
18
|
+
/* {name: [width, height]} of every icon drawn with a viewBox. */
|
|
19
|
+
function icons()
|
|
20
|
+
{
|
|
21
|
+
let out = {};
|
|
22
|
+
let re = /\n\.(yi-[a-z0-9-]+)::before \{\n([^}]*)\}/g;
|
|
23
|
+
let m;
|
|
24
|
+
while((m = re.exec(CSS)) !== null) {
|
|
25
|
+
let body = m[2];
|
|
26
|
+
let vb = /viewBox='([-\d. ]+)'/.exec(body);
|
|
27
|
+
if(!vb) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
let [, , w, h] = vb[1].trim().split(/\s+/).map(Number);
|
|
31
|
+
out[m[1]] = [w, h];
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* The masks given by custom property: {name: viewBox [w, h]}. */
|
|
37
|
+
function properties()
|
|
38
|
+
{
|
|
39
|
+
let out = {};
|
|
40
|
+
let re = /\n {4}--(yi-[a-z0-9-]+): url\("[^"]*viewBox='([-\d. ]+)'/g;
|
|
41
|
+
let m;
|
|
42
|
+
while((m = re.exec(CSS)) !== null) {
|
|
43
|
+
let [, , w, h] = m[2].trim().split(/\s+/).map(Number);
|
|
44
|
+
out[m[1]] = [w, h];
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* {name: width} from the rules that set only a width. */
|
|
50
|
+
function widths()
|
|
51
|
+
{
|
|
52
|
+
let out = {};
|
|
53
|
+
let re = /((?:\.yi-[a-z0-9-]+::before,?\s*)+)\{\s*width: ([\d.]+)em;\s*\}/g;
|
|
54
|
+
let m;
|
|
55
|
+
while((m = re.exec(CSS)) !== null) {
|
|
56
|
+
for(const name of m[1].match(/yi-[a-z0-9-]+/g)) {
|
|
57
|
+
out[name] = Number(m[2]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
test("the set is read: icons, and the box of the wide ones", () => {
|
|
64
|
+
expect(Object.keys(icons()).length).toBeGreaterThan(100);
|
|
65
|
+
expect(Object.keys(widths()).length).toBeGreaterThan(20);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test("every glyph wider than tall has a box as wide as it is", () => {
|
|
69
|
+
let all = {...icons(), ...properties()};
|
|
70
|
+
let w = widths();
|
|
71
|
+
let wrong = [];
|
|
72
|
+
for(const [name, [vw, vh]] of Object.entries(all)) {
|
|
73
|
+
let want = vw > vh ? vw / vh : undefined;
|
|
74
|
+
if(w[name] !== want) {
|
|
75
|
+
wrong.push(`${name}: viewBox ${vw}x${vh}, width ${w[name] ?? "1 (the base)"}, ` +
|
|
76
|
+
`wants ${want ?? "1 (the base)"}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
expect(wrong).toEqual([]);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test("a width rule names icons that exist", () => {
|
|
83
|
+
let all = {...icons(), ...properties()};
|
|
84
|
+
let unknown = Object.keys(widths()).filter((name) => !all[name]);
|
|
85
|
+
expect(unknown).toEqual([]);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test("the paginator's masks are properties, and their classes read them", () => {
|
|
89
|
+
for(const name of ["yi-backward-step", "yi-chevron-left", "yi-chevron-right", "yi-forward-step"]) {
|
|
90
|
+
expect(properties()[name]).toBeDefined();
|
|
91
|
+
let rule = new RegExp(`\\n\\.${name}::before \\{\\n {4}-webkit-mask-image: var\\(--${name}\\);` +
|
|
92
|
+
`\\n {4}mask-image: var\\(--${name}\\);\\n\\}`);
|
|
93
|
+
expect(CSS).toMatch(rule);
|
|
94
|
+
}
|
|
95
|
+
});
|