@yuneta/gobj-ui 7.32.6 → 7.32.8
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 +23 -1
- package/dist/gobj-ui.cjs.js +144 -123
- package/dist/gobj-ui.es.js +144 -123
- package/package.json +1 -1
- package/src/c_yui_nav.js +12 -6
- package/src/c_yui_treedb_topics.js +1 -3
- package/src/nav_icon_size.wiring.test.js +111 -0
- package/src/tabulator_css.test.js +88 -32
- package/src/yui_toolbar.js +1 -33
- package/src/yui_toolbar_icon.js +63 -0
package/package.json
CHANGED
package/src/c_yui_nav.js
CHANGED
|
@@ -111,6 +111,7 @@ import {
|
|
|
111
111
|
import {text_node} from "./yui_text.js";
|
|
112
112
|
import {css_string} from "./yui_selector.js";
|
|
113
113
|
import {badge_node, badge_tone, paint_badge, name_control_with_badge} from "./yui_badge.js";
|
|
114
|
+
import {yui_toolbar_icon} from "./yui_toolbar_icon.js";
|
|
114
115
|
|
|
115
116
|
/***************************************************************
|
|
116
117
|
* Constants
|
|
@@ -444,7 +445,7 @@ function render_tabs(gobj, items)
|
|
|
444
445
|
let pinned = !empty_string(it.icon) && !has_label;
|
|
445
446
|
let badge_el = item_badge_node(gobj, it, pinned);
|
|
446
447
|
if(!empty_string(it.icon)) {
|
|
447
|
-
children.push(icon_span(it.icon, "icon
|
|
448
|
+
children.push(icon_span(it.icon, "icon", pinned ? badge_el : null, true));
|
|
448
449
|
}
|
|
449
450
|
if(has_label) {
|
|
450
451
|
children.push(["span", {i18n: it.name}, text_node(it.name)]);
|
|
@@ -598,8 +599,7 @@ function render_backbar(gobj)
|
|
|
598
599
|
return createElement2(
|
|
599
600
|
["div", {},
|
|
600
601
|
["a", a_attrs, [
|
|
601
|
-
|
|
602
|
-
["i", {class: "yi-arrow-left", "aria-hidden": "true"}]],
|
|
602
|
+
icon_span("yi-arrow-left", "icon", null, true),
|
|
603
603
|
["span", label_attrs, text_node(label)]
|
|
604
604
|
]]
|
|
605
605
|
]
|
|
@@ -772,7 +772,7 @@ function item_li(gobj, it, opts)
|
|
|
772
772
|
let pinned = !empty_string(it.icon) && (is_stacked || !label_el);
|
|
773
773
|
let badge_el = item_badge_node(gobj, it, pinned);
|
|
774
774
|
let icon_el = !empty_string(it.icon)
|
|
775
|
-
? icon_span(it.icon, "icon", pinned ? badge_el : null)
|
|
775
|
+
? icon_span(it.icon, "icon", pinned ? badge_el : null, true)
|
|
776
776
|
: null;
|
|
777
777
|
|
|
778
778
|
let a_class = "yui-nav-item";
|
|
@@ -927,10 +927,16 @@ function item_badge_node(gobj, it, pinned)
|
|
|
927
927
|
|
|
928
928
|
/************************************************************
|
|
929
929
|
* An item's icon, with its badge on the corner when given one.
|
|
930
|
+
* `row_glyph`: the glyph of a tab or a menu entry, at the one
|
|
931
|
+
* size of the toolbars (yui_toolbar_icon). Without it the
|
|
932
|
+
* glyph takes the size the layout gives it (the icon bar, the
|
|
933
|
+
* cards).
|
|
930
934
|
************************************************************/
|
|
931
|
-
function icon_span(icon, classes, badge_el)
|
|
935
|
+
function icon_span(icon, classes, badge_el, row_glyph)
|
|
932
936
|
{
|
|
933
|
-
let glyph =
|
|
937
|
+
let glyph = row_glyph ?
|
|
938
|
+
yui_toolbar_icon(icon) :
|
|
939
|
+
["i", {class: icon, "aria-hidden": "true"}];
|
|
934
940
|
if(!badge_el) {
|
|
935
941
|
return ["span", {class: classes}, glyph];
|
|
936
942
|
}
|
|
@@ -616,9 +616,7 @@ function add_tab(gobj, gobj2, id, text, icon)
|
|
|
616
616
|
if(icon) {
|
|
617
617
|
$a.appendChild(
|
|
618
618
|
createElement2(
|
|
619
|
-
['span', {class: 'icon is-
|
|
620
|
-
['i', {class: `${icon}`, 'aria-hidden': 'true'}]
|
|
621
|
-
]
|
|
619
|
+
['span', {class: 'icon is-hidden-mobile'}, [yui_toolbar_icon(icon)]]
|
|
622
620
|
)
|
|
623
621
|
);
|
|
624
622
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/***********************************************************************
|
|
2
|
+
* nav_icon_size.wiring.test.js
|
|
3
|
+
*
|
|
4
|
+
* The glyph of a tab and of a menu entry of C_YUI_NAV is the size
|
|
5
|
+
* of the glyphs of a toolbar: YUI_TOOLBAR_ICON_SIZE (yui_toolbar_icon.js).
|
|
6
|
+
* Up to 7.32.6 a tab and a menu entry took the 16px of their text,
|
|
7
|
+
* and right under a toolbar of 20px their icons read as smaller.
|
|
8
|
+
* The icon bar and the cards are other bands: they keep their own
|
|
9
|
+
* size. The close mark of a tab is no icon of the tab: it keeps
|
|
10
|
+
* its own size too.
|
|
11
|
+
*
|
|
12
|
+
* The nav takes the size from yui_toolbar_icon.js, a module with
|
|
13
|
+
* no key and no CSS, and never from yui_toolbar.js: validate-locales
|
|
14
|
+
* reads every module an app imports, and in 7.32.7 the keys of the
|
|
15
|
+
* toolbar's scroll arrows failed the build of each app that mounts
|
|
16
|
+
* a nav and no toolbar.
|
|
17
|
+
*
|
|
18
|
+
* Driven through the real gclass on a document double.
|
|
19
|
+
*
|
|
20
|
+
* Copyright (c) 2026, ArtGins.
|
|
21
|
+
* All Rights Reserved.
|
|
22
|
+
***********************************************************************/
|
|
23
|
+
import {test, expect, beforeAll} from "vitest";
|
|
24
|
+
import {readFileSync} from "fs";
|
|
25
|
+
import {install_dom_double} from "../test/dom_double.js";
|
|
26
|
+
|
|
27
|
+
install_dom_double();
|
|
28
|
+
|
|
29
|
+
const {
|
|
30
|
+
SDATA_END, gclass_create, gobj_start_up, gobj_create_yuno, gobj_create,
|
|
31
|
+
gobj_read_attr,
|
|
32
|
+
} = await import("@yuneta/gobj-js");
|
|
33
|
+
const {register_c_yui_nav} = await import("./c_yui_nav.js");
|
|
34
|
+
const {YUI_TOOLBAR_ICON_SIZE} = await import("./yui_toolbar.js");
|
|
35
|
+
|
|
36
|
+
let yuno = null;
|
|
37
|
+
let seq = 0;
|
|
38
|
+
|
|
39
|
+
beforeAll(async () => {
|
|
40
|
+
const i18next = (await import("i18next")).default;
|
|
41
|
+
await i18next.init({lng: "en", resources: {en: {translation: {}}}});
|
|
42
|
+
gobj_start_up(null, null, null, null, null, null, null);
|
|
43
|
+
gclass_create("C_TEST_NAV_ICON_HOST", [], [["ST_IDLE", []]], {}, 0, [SDATA_END()], {}, 0, 0, 0, 0);
|
|
44
|
+
register_c_yui_nav();
|
|
45
|
+
yuno = gobj_create_yuno("nav_icon_size_yuno", "C_TEST_NAV_ICON_HOST", {});
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const ITEMS = [
|
|
49
|
+
{id: "topics", name: "topics", route: "/topics", icon: "yi-table", closable: true},
|
|
50
|
+
{id: "graphs", name: "graphs", route: "/graphs", icon: "yi-hexagon-nodes", badge: 2},
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
/* The container of a new C_YUI_NAV of this layout */
|
|
54
|
+
function nav_container(kw)
|
|
55
|
+
{
|
|
56
|
+
const nav = gobj_create(`nav_icon_${++seq}`, "C_YUI_NAV",
|
|
57
|
+
Object.assign({menu_items: ITEMS}, kw), yuno);
|
|
58
|
+
return gobj_read_attr(nav, "$container");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* The font size each glyph of the items carries in its own style */
|
|
62
|
+
function glyph_sizes($container, selector)
|
|
63
|
+
{
|
|
64
|
+
return $container.querySelectorAll(selector).map(($i) => {
|
|
65
|
+
const m = /font-size:\s*([^;]+)/.exec($i.style.cssText || "");
|
|
66
|
+
return m ? m[1].trim() : "";
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
test("a tab's glyph is the size of a toolbar's", () => {
|
|
71
|
+
const $c = nav_container({layout: "tabs"});
|
|
72
|
+
expect(glyph_sizes($c, "i.yi-table")).toEqual([YUI_TOOLBAR_ICON_SIZE]);
|
|
73
|
+
expect(glyph_sizes($c, "i.yi-hexagon-nodes")).toEqual([YUI_TOOLBAR_ICON_SIZE]);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test("the close mark of a tab keeps its own size", () => {
|
|
77
|
+
const $c = nav_container({layout: "tabs"});
|
|
78
|
+
expect(glyph_sizes($c, "i.yi-xmark")).toEqual([""]);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test("a menu entry's glyph is the size of a toolbar's", () => {
|
|
82
|
+
const $c = nav_container({layout: "vertical"});
|
|
83
|
+
expect(glyph_sizes($c, "i.yi-table")).toEqual([YUI_TOOLBAR_ICON_SIZE]);
|
|
84
|
+
expect(glyph_sizes($c, "i.yi-hexagon-nodes")).toEqual([YUI_TOOLBAR_ICON_SIZE]);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test("the back arrow of a backbar is the size of a toolbar's", () => {
|
|
88
|
+
const $c = nav_container({layout: "backbar", back_route: "/home"});
|
|
89
|
+
expect(glyph_sizes($c, "i.yi-arrow-left")).toEqual([YUI_TOOLBAR_ICON_SIZE]);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test("the icon bar keeps its own size", () => {
|
|
93
|
+
const $c = nav_container({layout: "icon-bar"});
|
|
94
|
+
expect(glyph_sizes($c, "i.yi-table")).toEqual([""]);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("the glyph is decoration: the control carries the name", () => {
|
|
98
|
+
const $c = nav_container({layout: "tabs"});
|
|
99
|
+
const $i = $c.querySelector("i.yi-table");
|
|
100
|
+
expect($i.getAttribute("aria-hidden")).toBe("true");
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test("the nav takes the size from a module with no key and no CSS", () => {
|
|
104
|
+
const nav_src = readFileSync(new URL("./c_yui_nav.js", import.meta.url), "utf8");
|
|
105
|
+
expect(nav_src).toContain('from "./yui_toolbar_icon.js"');
|
|
106
|
+
expect(nav_src).not.toContain('from "./yui_toolbar.js"');
|
|
107
|
+
|
|
108
|
+
const icon_src = readFileSync(new URL("./yui_toolbar_icon.js", import.meta.url), "utf8");
|
|
109
|
+
expect(icon_src).not.toMatch(/^\s*import\b/m);
|
|
110
|
+
expect(icon_src).not.toMatch(/\bt\(/);
|
|
111
|
+
});
|
|
@@ -1,54 +1,110 @@
|
|
|
1
1
|
/***********************************************************************
|
|
2
2
|
* tabulator_css.test.js
|
|
3
3
|
*
|
|
4
|
-
* The
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* The stylesheet of the tables: an editor fills its cell only when
|
|
5
|
+
* it is a box to TYPE in. A checkbox or a radio given width and
|
|
6
|
+
* height 100% is drawn as a square the size of the cell (the
|
|
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
|
+
* And the paginator on a narrow screen: its icons are the size of
|
|
11
|
+
* the icons of a view's toolbar, and each step button reads its
|
|
12
|
+
* mask from a property that yui_icons.css defines (7.32.6).
|
|
13
|
+
*
|
|
14
|
+
* Read as text, as the window layer's invariants are: jsdom applies
|
|
15
|
+
* no stylesheet.
|
|
7
16
|
*
|
|
8
17
|
* Copyright (c) 2026, ArtGins.
|
|
9
18
|
* All Rights Reserved.
|
|
10
19
|
***********************************************************************/
|
|
11
|
-
import {test, expect} from "vitest";
|
|
12
|
-
import
|
|
20
|
+
import {describe, test, expect} from "vitest";
|
|
21
|
+
import {readFileSync} from "node:fs";
|
|
22
|
+
import {dirname, join} from "node:path";
|
|
23
|
+
import {fileURLToPath} from "node:url";
|
|
13
24
|
import {install_dom_double} from "../test/dom_double.js";
|
|
14
25
|
|
|
15
26
|
install_dom_double();
|
|
16
27
|
|
|
17
28
|
const {YUI_TOOLBAR_ICON_SIZE} = await import("./yui_toolbar.js");
|
|
18
29
|
|
|
19
|
-
const
|
|
20
|
-
const ICONS = fs.readFileSync(new URL("./yui_icons.css", import.meta.url), "utf8");
|
|
30
|
+
const ICONS = readFileSync(join(dirname(fileURLToPath(import.meta.url)), "yui_icons.css"), "utf8");
|
|
21
31
|
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
const CSS = readFileSync(join(dirname(fileURLToPath(import.meta.url)), "tabulator.css"), "utf8")
|
|
33
|
+
.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
34
|
+
|
|
35
|
+
/* Every rule: its selectors, and its body. */
|
|
36
|
+
function rules()
|
|
24
37
|
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
38
|
+
const out = [];
|
|
39
|
+
const re = /([^{}]+)\{([^{}]*)\}/g;
|
|
40
|
+
let m;
|
|
41
|
+
while((m = re.exec(CSS)) !== null) {
|
|
42
|
+
out.push({
|
|
43
|
+
selectors: m[1].split(",").map((s) => s.trim()).filter(Boolean),
|
|
44
|
+
body: m[2]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
28
48
|
}
|
|
29
49
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
50
|
+
describe("an editor fills its cell only when it is a box to type in", () => {
|
|
51
|
+
test("no rule sizes a checkbox or a radio of a table to its cell", () => {
|
|
52
|
+
const offenders = [];
|
|
53
|
+
for(const r of rules()) {
|
|
54
|
+
if(!/\b(width|height)\s*:\s*100%/.test(r.body)) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
for(const sel of r.selectors) {
|
|
58
|
+
/* A bare `input` in a cell editor or a header filter reaches
|
|
59
|
+
* a checkbox too, unless the selector leaves it out. */
|
|
60
|
+
if(/\binput\b/.test(sel) && /tabulator/.test(sel) &&
|
|
61
|
+
!(/:not\(\[type=checkbox\]\)/.test(sel) && /:not\(\[type=radio\]\)/.test(sel))) {
|
|
62
|
+
offenders.push(sel);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
expect(offenders).toEqual([]);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("a text input of a cell being edited still fills it", () => {
|
|
70
|
+
const fill = rules().filter((r) => /\bwidth\s*:\s*100%/.test(r.body) &&
|
|
71
|
+
r.selectors.some((s) => /tabulator-editing input:not\(\[type=checkbox\]\)/.test(s)));
|
|
72
|
+
expect(fill.length).toBeGreaterThan(0);
|
|
73
|
+
});
|
|
35
74
|
});
|
|
36
75
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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\\(`));
|
|
76
|
+
describe("the paginator on a narrow screen", () => {
|
|
77
|
+
/* The block of the narrow screen. */
|
|
78
|
+
function narrow()
|
|
79
|
+
{
|
|
80
|
+
let start = CSS.indexOf("@media screen and (max-width: 768px) {");
|
|
81
|
+
expect(start).toBeGreaterThan(0);
|
|
82
|
+
return CSS.slice(start, CSS.indexOf("\n}\n", start));
|
|
49
83
|
}
|
|
50
|
-
});
|
|
51
84
|
|
|
52
|
-
test("
|
|
53
|
-
|
|
85
|
+
test("its icons are the size of the toolbar's", () => {
|
|
86
|
+
let m = /\[data-page=last\]\)::before \{[^}]*?width: ([\d.]+rem);\s*height: ([\d.]+rem);/.exec(narrow());
|
|
87
|
+
expect(m).not.toBeNull();
|
|
88
|
+
expect(m[1]).toBe(YUI_TOOLBAR_ICON_SIZE);
|
|
89
|
+
expect(m[2]).toBe(YUI_TOOLBAR_ICON_SIZE);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test("each step has the icon of the period navigator, from yui_icons.css", () => {
|
|
93
|
+
const STEPS = {
|
|
94
|
+
first: "yi-backward-step",
|
|
95
|
+
prev: "yi-chevron-left",
|
|
96
|
+
next: "yi-chevron-right",
|
|
97
|
+
last: "yi-forward-step"
|
|
98
|
+
};
|
|
99
|
+
for(const [page, icon] of Object.entries(STEPS)) {
|
|
100
|
+
expect(narrow()).toMatch(new RegExp(
|
|
101
|
+
`\\[data-page=${page}\\]::before \\{\\s*-webkit-mask-image: var\\(--${icon}\\);` +
|
|
102
|
+
`\\s*mask-image: var\\(--${icon}\\);`));
|
|
103
|
+
expect(ICONS).toMatch(new RegExp(`\\n {4}--${icon}: url\\(`));
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test("the numbered pages keep their number: only the steps lose the word", () => {
|
|
108
|
+
expect(narrow()).not.toMatch(/\.tabulator-page\[data-page\]/);
|
|
109
|
+
});
|
|
54
110
|
});
|
package/src/yui_toolbar.js
CHANGED
|
@@ -18,40 +18,8 @@ import {t} from "i18next";
|
|
|
18
18
|
|
|
19
19
|
import "./yui_toolbar.css"; // Must be in index.js ?
|
|
20
20
|
|
|
21
|
+
import {yui_toolbar_icon, YUI_TOOLBAR_ICON_SIZE} from "./yui_toolbar_icon.js";
|
|
21
22
|
|
|
22
|
-
/************************************************************
|
|
23
|
-
* ONE size for every glyph of a view's toolbar, in `rem`.
|
|
24
|
-
*
|
|
25
|
-
* It lives here because it belongs to the TOOLBAR and not to
|
|
26
|
-
* any one view: it was born in the graph rows (7.23.86) and the
|
|
27
|
-
* JSON viewer beside them still drew 16px, which is the same
|
|
28
|
-
* drift one level up.
|
|
29
|
-
*
|
|
30
|
-
* `rem` and not `em` is the whole lesson: `em` is measured
|
|
31
|
-
* against the button, so one declaration draws three icons --
|
|
32
|
-
* `1.5em` is 24px in a plain button, 18px in an `is-small`
|
|
33
|
-
* chip, and a labelled button that declares nothing keeps the
|
|
34
|
-
* inherited 16px. `rem` is measured against the page, so a
|
|
35
|
-
* chip deliberately shorter than a button still carries the
|
|
36
|
-
* same glyph.
|
|
37
|
-
*
|
|
38
|
-
* 20px against a row's 16px text: an icon-only button is
|
|
39
|
-
* legible at half its 40px height, and beside a label the
|
|
40
|
-
* glyph reads as a marker rather than as a second word. The
|
|
41
|
-
* app BAR is a different band and keeps its own, bigger size
|
|
42
|
-
* (`.yui-toolbar-item .icon`, 1.35rem on 44px items).
|
|
43
|
-
************************************************************/
|
|
44
|
-
const YUI_TOOLBAR_ICON_SIZE = "1.25rem";
|
|
45
|
-
|
|
46
|
-
/* The `<i>` spec of a toolbar glyph, at that one size. */
|
|
47
|
-
function yui_toolbar_icon(icon_class, extra_style)
|
|
48
|
-
{
|
|
49
|
-
return ['i', {
|
|
50
|
-
class: icon_class,
|
|
51
|
-
style: `font-size:${YUI_TOOLBAR_ICON_SIZE}; line-height:1; color:inherit;` +
|
|
52
|
-
(extra_style || ''),
|
|
53
|
-
}];
|
|
54
|
-
}
|
|
55
23
|
|
|
56
24
|
function yui_toolbar(attrs={}, items = [])
|
|
57
25
|
{
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/***********************************************************************
|
|
2
|
+
* yui_toolbar_icon.js
|
|
3
|
+
*
|
|
4
|
+
* The one size of the glyphs of a row of controls, and the
|
|
5
|
+
* `<i>` that draws one at it.
|
|
6
|
+
*
|
|
7
|
+
* A module of its own, with no key and no CSS, so that a view
|
|
8
|
+
* can take the size without taking the toolbar widget. In
|
|
9
|
+
* 7.32.7 C_YUI_NAV imported it from yui_toolbar.js, and every
|
|
10
|
+
* app that mounts a nav had to define the keys of the toolbar's
|
|
11
|
+
* scroll arrows ("scroll left", "scroll right"), which
|
|
12
|
+
* validate-locales reads in every module the app imports.
|
|
13
|
+
* yui_toolbar.js exports the two names too, as before.
|
|
14
|
+
*
|
|
15
|
+
* Copyright (c) 2026, ArtGins.
|
|
16
|
+
* All Rights Reserved.
|
|
17
|
+
***********************************************************************/
|
|
18
|
+
|
|
19
|
+
/************************************************************
|
|
20
|
+
* ONE size for every glyph of a view's toolbar, in `rem`.
|
|
21
|
+
*
|
|
22
|
+
* It lives here because it belongs to the TOOLBAR and not to
|
|
23
|
+
* any one view: it was born in the graph rows (7.23.86) and the
|
|
24
|
+
* JSON viewer beside them still drew 16px, which is the same
|
|
25
|
+
* drift one level up.
|
|
26
|
+
*
|
|
27
|
+
* `rem` and not `em` is the whole lesson: `em` is measured
|
|
28
|
+
* against the button, so one declaration draws three icons --
|
|
29
|
+
* `1.5em` is 24px in a plain button, 18px in an `is-small`
|
|
30
|
+
* chip, and a labelled button that declares nothing keeps the
|
|
31
|
+
* inherited 16px. `rem` is measured against the page, so a
|
|
32
|
+
* chip deliberately shorter than a button still carries the
|
|
33
|
+
* same glyph.
|
|
34
|
+
*
|
|
35
|
+
* 20px against a row's 16px text: an icon-only button is
|
|
36
|
+
* legible at half its 40px height, and beside a label the
|
|
37
|
+
* glyph reads as a marker rather than as a second word. The
|
|
38
|
+
* app BAR is a different band and keeps its own, bigger size
|
|
39
|
+
* (`.yui-toolbar-item .icon`, 1.35rem on 44px items).
|
|
40
|
+
*
|
|
41
|
+
* It is also the size of the glyphs of the TABS and of the
|
|
42
|
+
* MENU entries (C_YUI_NAV, the topic tabs of
|
|
43
|
+
* C_YUI_TREEDB_TOPICS), and of the paginator of a table on a
|
|
44
|
+
* phone (tabulator.css). Up to 7.32.6 a tab took the 16px of
|
|
45
|
+
* its text, and right under a toolbar its icons read as
|
|
46
|
+
* smaller than the toolbar's. The rows of a tab or a menu
|
|
47
|
+
* entry are 24px of line, so the glyph changes no height.
|
|
48
|
+
************************************************************/
|
|
49
|
+
const YUI_TOOLBAR_ICON_SIZE = "1.25rem";
|
|
50
|
+
|
|
51
|
+
/* The `<i>` spec of a toolbar glyph, at that one size. The
|
|
52
|
+
* glyph is decoration: the control around it carries the name. */
|
|
53
|
+
function yui_toolbar_icon(icon_class, extra_style)
|
|
54
|
+
{
|
|
55
|
+
return ['i', {
|
|
56
|
+
class: icon_class,
|
|
57
|
+
'aria-hidden': 'true',
|
|
58
|
+
style: `font-size:${YUI_TOOLBAR_ICON_SIZE}; line-height:1; color:inherit;` +
|
|
59
|
+
(extra_style || ''),
|
|
60
|
+
}];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export {yui_toolbar_icon, YUI_TOOLBAR_ICON_SIZE};
|