@yuneta/gobj-ui 7.32.5 → 7.32.7

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 CHANGED
@@ -1481,7 +1481,9 @@ for a reason worth keeping: in `em` the same `1.5em` drew 24px inside a plain
1481
1481
  button, 18px inside an `is-small` chip of the legend, and a labelled button
1482
1482
  left its icon at the inherited 16px — three sizes in two strips that are read
1483
1483
  as one thing. It is the toolbar's size and not the graph's: the JSON viewer,
1484
- the treedb topics row and the treedb table row take it too. The app BAR keeps
1484
+ the treedb topics row and the treedb table row take it too, and since
1485
+ `7.32.7` the tabs and the menu entries of `C_YUI_NAV` and the topic tabs of
1486
+ `C_YUI_TREEDB_TOPICS`. The app BAR keeps
1485
1487
  its own, bigger glyph (`.yui-toolbar-item .icon`, 1.35rem on 44px items) —
1486
1488
  that is a different band, not drift. The legend under the toolbar
1487
1489
  follows it: topic name at `1rem`, count at `.875rem` (the one deliberate step
@@ -3249,6 +3251,10 @@ A row of that topic with `"icon": "yi-u-transformer"` shows that drawing.
3249
3251
  - **The drawing is a MASK**, like the library's: painted with `currentColor`,
3250
3252
  one colour, the shapes' alpha only. A multicolour svg comes out as a
3251
3253
  silhouette.
3254
+ - **It is 1em tall, like every icon.** A drawing that is wider than tall gets
3255
+ a wider box, from its viewBox (`svg_icon_width()`), up to 1.25em
3256
+ (`USER_ICON_MAX_WIDTH`, the widest icon of the library). A wider drawing
3257
+ is drawn smaller, so that it does not push the controls of its row aside.
3252
3258
  - **The svg is rebuilt, never inserted.** `yui_svg_sanitize()` parses it and
3253
3259
  writes a new one from the shapes alone (`path`, `circle`, `rect`, `ellipse`,
3254
3260
  `line`, `polyline`, `polygon`, `g`) and their geometric and stroke
@@ -4495,6 +4501,36 @@ text is in the yunetas `CLAUDE.md` ("JS GUI conventions"); in short:
4495
4501
  - **One icon shape per meaning** (chevron = open/close one thing, shafted
4496
4502
  arrow = step or back, tree box = one level, double chevron = all). Never
4497
4503
  reuse a glyph because it is there.
4504
+ - **Every icon is 1em tall** (`yui_icons.css`, 7.32.6+). The box of an icon
4505
+ is 1em wide. A glyph that is wider than tall gets a wider box, its viewBox
4506
+ width over its height: `yi-file-csv` (576 x 512) is 1.125em wide, and
4507
+ `yi-code` (640 x 512) is 1.25em. A new icon that is wider than tall goes
4508
+ into the list of its width, and `yui_icons.test.js` names an icon that is
4509
+ missing from it:
4510
+
4511
+ ```css
4512
+ .yi-file-csv::before,
4513
+ .yi-sitemap::before {
4514
+ width: 1.125em;
4515
+ }
4516
+ ```
4517
+
4518
+ A Bulma `.icon` grows to hold a wide glyph. Up to 7.32.5 every box was a
4519
+ 1em square, and a wide glyph was drawn smaller to fit: in one row of tool
4520
+ buttons, `yi-code` was 80% of the height of the others.
4521
+ - **The icons of a row of controls have one size**: `YUI_TOOLBAR_ICON_SIZE`
4522
+ (1.25rem, `yui_toolbar.js`). A toolbar, a tab, a menu entry and the
4523
+ paginator of a table on a phone take it (7.32.7+). Build the glyph with
4524
+ `yui_toolbar_icon()` in a plain Bulma `.icon`:
4525
+
4526
+ ```js
4527
+ ['span', {class: 'icon'}, [yui_toolbar_icon('yi-table')]]
4528
+ ```
4529
+
4530
+ The app bar, the icon bar and the cards are other bands, with their own
4531
+ bigger icons. The close mark of a tab is no icon of the tab and keeps the
4532
+ size of its text. Up to 7.32.6 a tab and a menu entry took the size of
4533
+ their text, 16px. Under a toolbar of 20px their icons looked smaller.
4498
4534
  - **Bulma helpers carry `!important`** (`.is-hidden`, `.is-flex`): toggle
4499
4535
  `is-hidden`, or use `style.setProperty('display', 'none', 'important')`.
4500
4536
  - **Data goes into the DOM as text, never as a string.** `createElement2()`
@@ -4587,7 +4623,7 @@ the tables of `gui_treedb` and `gui_agent`. Other tables can obey it too.
4587
4623
  a control has none, for example the action buttons or the selection
4588
4624
  checkbox.
4589
4625
  2. The footer shows the paginator at all times, also when all the rows fit
4590
- in one page.
4626
+ in one page. On a phone the paginator takes one line (see below).
4591
4627
  3. The table holds all its rows in the browser and pages them there. This
4592
4628
  is local pagination.
4593
4629
  4. Each toolbar above the table takes one row. When the row does not fit,
@@ -4620,10 +4656,31 @@ since 7.32.4. Up to 7.32.0 it hid the paginator when all the rows fit, and
4620
4656
  its toolbar wrapped into two rows on a phone. Up to 7.32.3 the columns of a
4621
4657
  document, a hook, a file and a time had no filter.
4622
4658
 
4659
+ The paginator on a phone takes one line, from `tabulator.css` (7.32.6+),
4660
+ for every table of an app that imports it. At the mobile width of Bulma
4661
+ (768 px and less):
4662
+
4663
+ - First, Prev, Next and Last show the icons of the period navigator
4664
+ (`C_YUI_PERIOD`): `yi-backward-step`, `yi-chevron-left`,
4665
+ `yi-chevron-right` and `yi-forward-step`. Each button keeps its name in
4666
+ the table's language: Tabulator writes "First Page" and the others as
4667
+ `title` and `aria-label`.
4668
+ - The label "Rows per page" is hidden. The select keeps the same text as its
4669
+ `title` and `aria-label`.
4670
+ - Of the numbered pages, only the current one shows. The steps and the ends
4671
+ reach the others.
4672
+ - Each icon is `YUI_TOOLBAR_ICON_SIZE` (1.25rem), the size of the icons of
4673
+ the toolbar above the table, in a 2rem button.
4674
+
4675
+ Up to 7.32.5 the words took three lines of the footer on a 390 px phone.
4676
+ `tabulator.css` takes the masks from `yui_icons.css` as custom properties
4677
+ (`--yi-backward-step` and the others), so the app must import it. Every app
4678
+ of the ecosystem does.
4679
+
4623
4680
  How to make sure that a table obeys it: open the DEPLOYED page at 390 px.
4624
4681
  Each control of the toolbar is on one line, the paginator
4625
- (`.tabulator-paginator`) has a width with one page of rows, and each column
4626
- of data has a filter box.
4682
+ (`.tabulator-paginator`) has a width with one page of rows and is one line,
4683
+ and each column of data has a filter box.
4627
4684
 
4628
4685
  Why each point:
4629
4686
 
@@ -10315,6 +10315,25 @@ function svg_mask_url(svg) {
10315
10315
  return `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
10316
10316
  }
10317
10317
  /************************************************************
10318
+ * The width of the box of an icon, in em: 1, or more for a
10319
+ * drawing wider than tall, so that it is 1em TALL like every
10320
+ * icon (yui_icons.css, "THE BOX"). Its viewBox says the ratio.
10321
+ *
10322
+ * Capped at 1.25em, the widest icon of Font Awesome: a wider
10323
+ * drawing is a logo or a banner, and a box any wider would
10324
+ * push the controls of its row aside. It is drawn smaller.
10325
+ ************************************************************/
10326
+ var USER_ICON_MAX_WIDTH = 1.25;
10327
+ function svg_icon_width(svg) {
10328
+ let m = /viewBox="([^"]*)"/.exec(String(svg || ""));
10329
+ if (!m) return 1;
10330
+ let parts = m[1].trim().split(/[\s,]+/).map(Number);
10331
+ let w = parts[2];
10332
+ let h = parts[3];
10333
+ if (!(w > 0 && h > 0) || w <= h) return 1;
10334
+ return Math.round(Math.min(w / h, USER_ICON_MAX_WIDTH) * 1e3) / 1e3;
10335
+ }
10336
+ /************************************************************
10318
10337
  * An element that shows an svg as an icon, before it is
10319
10338
  * registered (a form preview, a cell of __icons__ itself).
10320
10339
  * Return {element} or {error}.
@@ -10327,6 +10346,8 @@ function yui_svg_icon_element(svg_text) {
10327
10346
  let mask = svg_mask_url(clean.svg);
10328
10347
  el.style.setProperty("-webkit-mask-image", mask);
10329
10348
  el.style.setProperty("mask-image", mask);
10349
+ let width = svg_icon_width(clean.svg);
10350
+ if (width > 1) el.style.setProperty("width", `${width}em`);
10330
10351
  return {
10331
10352
  element: el,
10332
10353
  dropped: clean.dropped
@@ -10337,7 +10358,10 @@ function yui_svg_icon_element(svg_text) {
10337
10358
  ************************************************************/
10338
10359
  function rebuild_user_icons_stylesheet() {
10339
10360
  let css = "";
10340
- for (const [id, icon] of __user_icons__) css += `.${yui_user_icon_class(id)}::before {-webkit-mask-image: ${icon.mask}; mask-image: ${icon.mask};}\n`;
10361
+ for (const [id, icon] of __user_icons__) {
10362
+ let width = icon.width > 1 ? ` width: ${icon.width}em;` : "";
10363
+ css += `.${yui_user_icon_class(id)}::before {-webkit-mask-image: ${icon.mask}; mask-image: ${icon.mask};${width}}\n`;
10364
+ }
10341
10365
  try {
10342
10366
  let el = document.getElementById(USER_ICONS_STYLE_ID);
10343
10367
  if (!el) {
@@ -10368,7 +10392,8 @@ function user_icon_entry(node) {
10368
10392
  }
10369
10393
  return {
10370
10394
  svg: clean.svg,
10371
- mask: svg_mask_url(clean.svg)
10395
+ mask: svg_mask_url(clean.svg),
10396
+ width: svg_icon_width(clean.svg)
10372
10397
  };
10373
10398
  }
10374
10399
  /************************************************************
@@ -16554,11 +16579,20 @@ function register_c_yui_uplot() {
16554
16579
  * glyph reads as a marker rather than as a second word. The
16555
16580
  * app BAR is a different band and keeps its own, bigger size
16556
16581
  * (`.yui-toolbar-item .icon`, 1.35rem on 44px items).
16582
+ *
16583
+ * It is also the size of the glyphs of the TABS and of the
16584
+ * MENU entries (C_YUI_NAV, the topic tabs of
16585
+ * C_YUI_TREEDB_TOPICS), and of the paginator of a table on a
16586
+ * phone (tabulator.css). Up to 7.32.6 a tab took the 16px of
16587
+ * its text, and right under a toolbar its icons read as
16588
+ * smaller than the toolbar's. The rows of a tab or a menu
16589
+ * entry are 24px of line, so the glyph changes no height.
16557
16590
  ************************************************************/
16558
16591
  var YUI_TOOLBAR_ICON_SIZE = "1.25rem";
16559
16592
  function yui_toolbar_icon(icon_class, extra_style) {
16560
16593
  return ["i", {
16561
16594
  class: icon_class,
16595
+ "aria-hidden": "true",
16562
16596
  style: `font-size:${YUI_TOOLBAR_ICON_SIZE}; line-height:1; color:inherit;` + (extra_style || "")
16563
16597
  }];
16564
16598
  }
@@ -56297,7 +56331,7 @@ function render_tabs(gobj, items) {
56297
56331
  let has_label = show_label && !(0, _yuneta_gobj_js.empty_string)(it.name);
56298
56332
  let pinned = !(0, _yuneta_gobj_js.empty_string)(it.icon) && !has_label;
56299
56333
  let badge_el = item_badge_node(gobj, it, pinned);
56300
- if (!(0, _yuneta_gobj_js.empty_string)(it.icon)) children.push(icon_span(it.icon, "icon is-small", pinned ? badge_el : null));
56334
+ if (!(0, _yuneta_gobj_js.empty_string)(it.icon)) children.push(icon_span(it.icon, "icon", pinned ? badge_el : null, true));
56301
56335
  if (has_label) children.push([
56302
56336
  "span",
56303
56337
  { i18n: it.name },
@@ -56470,14 +56504,7 @@ function render_backbar(gobj) {
56470
56504
  [
56471
56505
  "a",
56472
56506
  a_attrs,
56473
- [[
56474
- "span",
56475
- { class: "icon is-small" },
56476
- ["i", {
56477
- class: "yi-arrow-left",
56478
- "aria-hidden": "true"
56479
- }]
56480
- ], [
56507
+ [icon_span("yi-arrow-left", "icon", null, true), [
56481
56508
  "span",
56482
56509
  label_attrs,
56483
56510
  text_node(label)
@@ -56627,7 +56654,7 @@ function item_li(gobj, it, opts) {
56627
56654
  ] : null;
56628
56655
  let pinned = !(0, _yuneta_gobj_js.empty_string)(it.icon) && (is_stacked || !label_el);
56629
56656
  let badge_el = item_badge_node(gobj, it, pinned);
56630
- let icon_el = !(0, _yuneta_gobj_js.empty_string)(it.icon) ? icon_span(it.icon, "icon", pinned ? badge_el : null) : null;
56657
+ let icon_el = !(0, _yuneta_gobj_js.empty_string)(it.icon) ? icon_span(it.icon, "icon", pinned ? badge_el : null, true) : null;
56631
56658
  let a_class = "yui-nav-item";
56632
56659
  if (is_stacked) a_class += " yui-nav-stacked";
56633
56660
  if (icon_pos === "right" || icon_pos === "bottom") {
@@ -56734,9 +56761,13 @@ function item_badge_node(gobj, it, pinned) {
56734
56761
  }
56735
56762
  /************************************************************
56736
56763
  * An item's icon, with its badge on the corner when given one.
56764
+ * `row_glyph`: the glyph of a tab or a menu entry, at the one
56765
+ * size of the toolbars (yui_toolbar_icon). Without it the
56766
+ * glyph takes the size the layout gives it (the icon bar, the
56767
+ * cards).
56737
56768
  ************************************************************/
56738
- function icon_span(icon, classes, badge_el) {
56739
- let glyph = ["i", {
56769
+ function icon_span(icon, classes, badge_el, row_glyph) {
56770
+ let glyph = row_glyph ? yui_toolbar_icon(icon) : ["i", {
56740
56771
  class: icon,
56741
56772
  "aria-hidden": "true"
56742
56773
  }];
@@ -58397,11 +58428,8 @@ function add_tab(gobj, gobj2, id, text, icon) {
58397
58428
  let $a = $item.querySelector("a");
58398
58429
  if (icon) $a.appendChild((0, _yuneta_gobj_js.createElement2)([
58399
58430
  "span",
58400
- { class: "icon is-small is-hidden-mobile" },
58401
- ["i", {
58402
- class: `${icon}`,
58403
- "aria-hidden": "true"
58404
- }]
58431
+ { class: "icon is-hidden-mobile" },
58432
+ [yui_toolbar_icon(icon)]
58405
58433
  ]));
58406
58434
  $a.appendChild((0, _yuneta_gobj_js.createElement2)([
58407
58435
  "span",
@@ -10310,6 +10310,25 @@ function svg_mask_url(svg) {
10310
10310
  return `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
10311
10311
  }
10312
10312
  /************************************************************
10313
+ * The width of the box of an icon, in em: 1, or more for a
10314
+ * drawing wider than tall, so that it is 1em TALL like every
10315
+ * icon (yui_icons.css, "THE BOX"). Its viewBox says the ratio.
10316
+ *
10317
+ * Capped at 1.25em, the widest icon of Font Awesome: a wider
10318
+ * drawing is a logo or a banner, and a box any wider would
10319
+ * push the controls of its row aside. It is drawn smaller.
10320
+ ************************************************************/
10321
+ var USER_ICON_MAX_WIDTH = 1.25;
10322
+ function svg_icon_width(svg) {
10323
+ let m = /viewBox="([^"]*)"/.exec(String(svg || ""));
10324
+ if (!m) return 1;
10325
+ let parts = m[1].trim().split(/[\s,]+/).map(Number);
10326
+ let w = parts[2];
10327
+ let h = parts[3];
10328
+ if (!(w > 0 && h > 0) || w <= h) return 1;
10329
+ return Math.round(Math.min(w / h, USER_ICON_MAX_WIDTH) * 1e3) / 1e3;
10330
+ }
10331
+ /************************************************************
10313
10332
  * An element that shows an svg as an icon, before it is
10314
10333
  * registered (a form preview, a cell of __icons__ itself).
10315
10334
  * Return {element} or {error}.
@@ -10322,6 +10341,8 @@ function yui_svg_icon_element(svg_text) {
10322
10341
  let mask = svg_mask_url(clean.svg);
10323
10342
  el.style.setProperty("-webkit-mask-image", mask);
10324
10343
  el.style.setProperty("mask-image", mask);
10344
+ let width = svg_icon_width(clean.svg);
10345
+ if (width > 1) el.style.setProperty("width", `${width}em`);
10325
10346
  return {
10326
10347
  element: el,
10327
10348
  dropped: clean.dropped
@@ -10332,7 +10353,10 @@ function yui_svg_icon_element(svg_text) {
10332
10353
  ************************************************************/
10333
10354
  function rebuild_user_icons_stylesheet() {
10334
10355
  let css = "";
10335
- for (const [id, icon] of __user_icons__) css += `.${yui_user_icon_class(id)}::before {-webkit-mask-image: ${icon.mask}; mask-image: ${icon.mask};}\n`;
10356
+ for (const [id, icon] of __user_icons__) {
10357
+ let width = icon.width > 1 ? ` width: ${icon.width}em;` : "";
10358
+ css += `.${yui_user_icon_class(id)}::before {-webkit-mask-image: ${icon.mask}; mask-image: ${icon.mask};${width}}\n`;
10359
+ }
10336
10360
  try {
10337
10361
  let el = document.getElementById(USER_ICONS_STYLE_ID);
10338
10362
  if (!el) {
@@ -10363,7 +10387,8 @@ function user_icon_entry(node) {
10363
10387
  }
10364
10388
  return {
10365
10389
  svg: clean.svg,
10366
- mask: svg_mask_url(clean.svg)
10390
+ mask: svg_mask_url(clean.svg),
10391
+ width: svg_icon_width(clean.svg)
10367
10392
  };
10368
10393
  }
10369
10394
  /************************************************************
@@ -16549,11 +16574,20 @@ function register_c_yui_uplot() {
16549
16574
  * glyph reads as a marker rather than as a second word. The
16550
16575
  * app BAR is a different band and keeps its own, bigger size
16551
16576
  * (`.yui-toolbar-item .icon`, 1.35rem on 44px items).
16577
+ *
16578
+ * It is also the size of the glyphs of the TABS and of the
16579
+ * MENU entries (C_YUI_NAV, the topic tabs of
16580
+ * C_YUI_TREEDB_TOPICS), and of the paginator of a table on a
16581
+ * phone (tabulator.css). Up to 7.32.6 a tab took the 16px of
16582
+ * its text, and right under a toolbar its icons read as
16583
+ * smaller than the toolbar's. The rows of a tab or a menu
16584
+ * entry are 24px of line, so the glyph changes no height.
16552
16585
  ************************************************************/
16553
16586
  var YUI_TOOLBAR_ICON_SIZE = "1.25rem";
16554
16587
  function yui_toolbar_icon(icon_class, extra_style) {
16555
16588
  return ["i", {
16556
16589
  class: icon_class,
16590
+ "aria-hidden": "true",
16557
16591
  style: `font-size:${YUI_TOOLBAR_ICON_SIZE}; line-height:1; color:inherit;` + (extra_style || "")
16558
16592
  }];
16559
16593
  }
@@ -56292,7 +56326,7 @@ function render_tabs(gobj, items) {
56292
56326
  let has_label = show_label && !empty_string(it.name);
56293
56327
  let pinned = !empty_string(it.icon) && !has_label;
56294
56328
  let badge_el = item_badge_node(gobj, it, pinned);
56295
- if (!empty_string(it.icon)) children.push(icon_span(it.icon, "icon is-small", pinned ? badge_el : null));
56329
+ if (!empty_string(it.icon)) children.push(icon_span(it.icon, "icon", pinned ? badge_el : null, true));
56296
56330
  if (has_label) children.push([
56297
56331
  "span",
56298
56332
  { i18n: it.name },
@@ -56465,14 +56499,7 @@ function render_backbar(gobj) {
56465
56499
  [
56466
56500
  "a",
56467
56501
  a_attrs,
56468
- [[
56469
- "span",
56470
- { class: "icon is-small" },
56471
- ["i", {
56472
- class: "yi-arrow-left",
56473
- "aria-hidden": "true"
56474
- }]
56475
- ], [
56502
+ [icon_span("yi-arrow-left", "icon", null, true), [
56476
56503
  "span",
56477
56504
  label_attrs,
56478
56505
  text_node(label)
@@ -56622,7 +56649,7 @@ function item_li(gobj, it, opts) {
56622
56649
  ] : null;
56623
56650
  let pinned = !empty_string(it.icon) && (is_stacked || !label_el);
56624
56651
  let badge_el = item_badge_node(gobj, it, pinned);
56625
- let icon_el = !empty_string(it.icon) ? icon_span(it.icon, "icon", pinned ? badge_el : null) : null;
56652
+ let icon_el = !empty_string(it.icon) ? icon_span(it.icon, "icon", pinned ? badge_el : null, true) : null;
56626
56653
  let a_class = "yui-nav-item";
56627
56654
  if (is_stacked) a_class += " yui-nav-stacked";
56628
56655
  if (icon_pos === "right" || icon_pos === "bottom") {
@@ -56729,9 +56756,13 @@ function item_badge_node(gobj, it, pinned) {
56729
56756
  }
56730
56757
  /************************************************************
56731
56758
  * An item's icon, with its badge on the corner when given one.
56759
+ * `row_glyph`: the glyph of a tab or a menu entry, at the one
56760
+ * size of the toolbars (yui_toolbar_icon). Without it the
56761
+ * glyph takes the size the layout gives it (the icon bar, the
56762
+ * cards).
56732
56763
  ************************************************************/
56733
- function icon_span(icon, classes, badge_el) {
56734
- let glyph = ["i", {
56764
+ function icon_span(icon, classes, badge_el, row_glyph) {
56765
+ let glyph = row_glyph ? yui_toolbar_icon(icon) : ["i", {
56735
56766
  class: icon,
56736
56767
  "aria-hidden": "true"
56737
56768
  }];
@@ -58392,11 +58423,8 @@ function add_tab(gobj, gobj2, id, text, icon) {
58392
58423
  let $a = $item.querySelector("a");
58393
58424
  if (icon) $a.appendChild(createElement2([
58394
58425
  "span",
58395
- { class: "icon is-small is-hidden-mobile" },
58396
- ["i", {
58397
- class: `${icon}`,
58398
- "aria-hidden": "true"
58399
- }]
58426
+ { class: "icon is-hidden-mobile" },
58427
+ [yui_toolbar_icon(icon)]
58400
58428
  ]));
58401
58429
  $a.appendChild(createElement2([
58402
58430
  "span",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.32.5",
3
+ "version": "7.32.7",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/gobj-ui.cjs.js",
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.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 is-small", pinned ? badge_el : null));
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
- ["span", {class: "icon is-small"},
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 = ["i", {class: icon, "aria-hidden": "true"}];
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-small is-hidden-mobile'},
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
  }
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 1em box of an
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};}\n`;
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
  /************************************************************
@@ -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
+ });
@@ -0,0 +1,94 @@
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.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
+ * Driven through the real gclass on a document double.
13
+ *
14
+ * Copyright (c) 2026, ArtGins.
15
+ * All Rights Reserved.
16
+ ***********************************************************************/
17
+ import {test, expect, beforeAll} from "vitest";
18
+ import {install_dom_double} from "../test/dom_double.js";
19
+
20
+ install_dom_double();
21
+
22
+ const {
23
+ SDATA_END, gclass_create, gobj_start_up, gobj_create_yuno, gobj_create,
24
+ gobj_read_attr,
25
+ } = await import("@yuneta/gobj-js");
26
+ const {register_c_yui_nav} = await import("./c_yui_nav.js");
27
+ const {YUI_TOOLBAR_ICON_SIZE} = await import("./yui_toolbar.js");
28
+
29
+ let yuno = null;
30
+ let seq = 0;
31
+
32
+ beforeAll(async () => {
33
+ const i18next = (await import("i18next")).default;
34
+ await i18next.init({lng: "en", resources: {en: {translation: {}}}});
35
+ gobj_start_up(null, null, null, null, null, null, null);
36
+ gclass_create("C_TEST_NAV_ICON_HOST", [], [["ST_IDLE", []]], {}, 0, [SDATA_END()], {}, 0, 0, 0, 0);
37
+ register_c_yui_nav();
38
+ yuno = gobj_create_yuno("nav_icon_size_yuno", "C_TEST_NAV_ICON_HOST", {});
39
+ });
40
+
41
+ const ITEMS = [
42
+ {id: "topics", name: "topics", route: "/topics", icon: "yi-table", closable: true},
43
+ {id: "graphs", name: "graphs", route: "/graphs", icon: "yi-hexagon-nodes", badge: 2},
44
+ ];
45
+
46
+ /* The container of a new C_YUI_NAV of this layout */
47
+ function nav_container(kw)
48
+ {
49
+ const nav = gobj_create(`nav_icon_${++seq}`, "C_YUI_NAV",
50
+ Object.assign({menu_items: ITEMS}, kw), yuno);
51
+ return gobj_read_attr(nav, "$container");
52
+ }
53
+
54
+ /* The font size each glyph of the items carries in its own style */
55
+ function glyph_sizes($container, selector)
56
+ {
57
+ return $container.querySelectorAll(selector).map(($i) => {
58
+ const m = /font-size:\s*([^;]+)/.exec($i.style.cssText || "");
59
+ return m ? m[1].trim() : "";
60
+ });
61
+ }
62
+
63
+ test("a tab's glyph is the size of a toolbar's", () => {
64
+ const $c = nav_container({layout: "tabs"});
65
+ expect(glyph_sizes($c, "i.yi-table")).toEqual([YUI_TOOLBAR_ICON_SIZE]);
66
+ expect(glyph_sizes($c, "i.yi-hexagon-nodes")).toEqual([YUI_TOOLBAR_ICON_SIZE]);
67
+ });
68
+
69
+ test("the close mark of a tab keeps its own size", () => {
70
+ const $c = nav_container({layout: "tabs"});
71
+ expect(glyph_sizes($c, "i.yi-xmark")).toEqual([""]);
72
+ });
73
+
74
+ test("a menu entry's glyph is the size of a toolbar's", () => {
75
+ const $c = nav_container({layout: "vertical"});
76
+ expect(glyph_sizes($c, "i.yi-table")).toEqual([YUI_TOOLBAR_ICON_SIZE]);
77
+ expect(glyph_sizes($c, "i.yi-hexagon-nodes")).toEqual([YUI_TOOLBAR_ICON_SIZE]);
78
+ });
79
+
80
+ test("the back arrow of a backbar is the size of a toolbar's", () => {
81
+ const $c = nav_container({layout: "backbar", back_route: "/home"});
82
+ expect(glyph_sizes($c, "i.yi-arrow-left")).toEqual([YUI_TOOLBAR_ICON_SIZE]);
83
+ });
84
+
85
+ test("the icon bar keeps its own size", () => {
86
+ const $c = nav_container({layout: "icon-bar"});
87
+ expect(glyph_sizes($c, "i.yi-table")).toEqual([""]);
88
+ });
89
+
90
+ test("the glyph is decoration: the control carries the name", () => {
91
+ const $c = nav_container({layout: "tabs"});
92
+ const $i = $c.querySelector("i.yi-table");
93
+ expect($i.getAttribute("aria-hidden")).toBe("true");
94
+ });
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
@@ -7,6 +7,10 @@
7
7
  * tickCross editor of an app's "validated" opened as a huge
8
8
  * empty box on a phone, gobj-ui 7.26.36).
9
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
+ *
10
14
  * Read as text, as the window layer's invariants are: jsdom applies
11
15
  * no stylesheet.
12
16
  *
@@ -17,6 +21,13 @@ import {describe, test, expect} from "vitest";
17
21
  import {readFileSync} from "node:fs";
18
22
  import {dirname, join} from "node:path";
19
23
  import {fileURLToPath} from "node:url";
24
+ import {install_dom_double} from "../test/dom_double.js";
25
+
26
+ install_dom_double();
27
+
28
+ const {YUI_TOOLBAR_ICON_SIZE} = await import("./yui_toolbar.js");
29
+
30
+ const ICONS = readFileSync(join(dirname(fileURLToPath(import.meta.url)), "yui_icons.css"), "utf8");
20
31
 
21
32
  const CSS = readFileSync(join(dirname(fileURLToPath(import.meta.url)), "tabulator.css"), "utf8")
22
33
  .replace(/\/\*[\s\S]*?\*\//g, "");
@@ -61,3 +72,39 @@ describe("an editor fills its cell only when it is a box to type in", () => {
61
72
  expect(fill.length).toBeGreaterThan(0);
62
73
  });
63
74
  });
75
+
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));
83
+ }
84
+
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
+ });
110
+ });
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: 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");
321
- mask-image: 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");
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: 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");
326
- mask-image: 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");
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: 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");
336
- mask-image: 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");
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: 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");
351
- mask-image: 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");
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
+ });
@@ -40,14 +40,24 @@ import "./yui_toolbar.css"; // Must be in index.js ?
40
40
  * glyph reads as a marker rather than as a second word. The
41
41
  * app BAR is a different band and keeps its own, bigger size
42
42
  * (`.yui-toolbar-item .icon`, 1.35rem on 44px items).
43
+ *
44
+ * It is also the size of the glyphs of the TABS and of the
45
+ * MENU entries (C_YUI_NAV, the topic tabs of
46
+ * C_YUI_TREEDB_TOPICS), and of the paginator of a table on a
47
+ * phone (tabulator.css). Up to 7.32.6 a tab took the 16px of
48
+ * its text, and right under a toolbar its icons read as
49
+ * smaller than the toolbar's. The rows of a tab or a menu
50
+ * entry are 24px of line, so the glyph changes no height.
43
51
  ************************************************************/
44
52
  const YUI_TOOLBAR_ICON_SIZE = "1.25rem";
45
53
 
46
- /* The `<i>` spec of a toolbar glyph, at that one size. */
54
+ /* The `<i>` spec of a toolbar glyph, at that one size. The
55
+ * glyph is decoration: the control around it carries the name. */
47
56
  function yui_toolbar_icon(icon_class, extra_style)
48
57
  {
49
58
  return ['i', {
50
59
  class: icon_class,
60
+ 'aria-hidden': 'true',
51
61
  style: `font-size:${YUI_TOOLBAR_ICON_SIZE}; line-height:1; color:inherit;` +
52
62
  (extra_style || ''),
53
63
  }];