@yuneta/gobj-ui 7.23.99 → 7.23.101

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.
@@ -10524,6 +10524,28 @@ function yui_toolbar(attrs = {}, items = []) {
10524
10524
  updateScrollButtons();
10525
10525
  return $toolbar;
10526
10526
  }
10527
+ /************************************************************
10528
+ * Set or reset the PRESSED state of a toggle.
10529
+ *
10530
+ * It lives here, with `yui_toolbar.css`, and not in
10531
+ * `lib_graph.js` where it was born: a pressed toggle is a
10532
+ * TOOLBAR thing, and a stylesheet rides its JS import -- while
10533
+ * the rule sat in the graph's file, an app without a graph got
10534
+ * the class and no paint, which from the outside is a button
10535
+ * that does not work. `lib_graph.js` re-exports it, so every
10536
+ * caller written against that path keeps working.
10537
+ *
10538
+ * Written with `querySelectorAll` and not with `addClasses`
10539
+ * from `lib_graph.js` on purpose: importing that would drag
10540
+ * `lib_graph.css` into every toolbar, which is the same trap
10541
+ * the other way round.
10542
+ ************************************************************/
10543
+ function set_pressed_state($container, selector, set) {
10544
+ if (!$container) return;
10545
+ $container.querySelectorAll(selector).forEach(($el) => {
10546
+ $el.classList.toggle("pressed_state", !!set);
10547
+ });
10548
+ }
10527
10549
  //#endregion
10528
10550
  //#region src/lib_graph.js
10529
10551
  /***********************************************************************
@@ -10595,19 +10617,6 @@ function set_active_state($container, selector, set) {
10595
10617
  if (set) addClasses($container, selector, "color_active_state");
10596
10618
  else removeClasses($container, selector, "color_active_state");
10597
10619
  }
10598
- /************************************************************
10599
- * Set or reset the 'pressed' state of a TOGGLE.
10600
- *
10601
- * Not one of the colours above: each of those names a KIND of
10602
- * action (create, pending, history, destructive), and a toggle
10603
- * is not an action -- it is a state the control is IN. So it
10604
- * looks pressed instead of changing category, which also keeps
10605
- * it out of the way of a neighbour wearing the same hue.
10606
- ************************************************************/
10607
- function set_pressed_state($container, selector, set) {
10608
- if (set) addClasses($container, selector, "pressed_state");
10609
- else removeClasses($container, selector, "pressed_state");
10610
- }
10611
10620
  /**
10612
10621
  * Returns a smart stroke color in `rgba()` format based on:
10613
10622
  * - The given fill color (hex or rgb[a])
@@ -13411,7 +13420,12 @@ function icon_button$1(gobj, icon, event_name, label_key) {
13411
13420
  * aimed — reaching the graph from the tree would mean passing
13412
13421
  * through the text and rebuilding it on the way — so each view gets
13413
13422
  * its own button and says where it goes. apply_view_mode() moves
13414
- * the `is-active` mark.
13423
+ * the `pressed_state` mark -- the library's one way of saying a
13424
+ * toggle is ON, the same the graph toolbars and the treedb legend
13425
+ * use. It used to be `is-active` with a blue fill of its own: a
13426
+ * STATE wearing a palette colour, which is what the palette does
13427
+ * NOT mean (it names kinds of ACTION), and a third spelling of a
13428
+ * thing the library already had a name for.
13415
13429
  ************************************************************/
13416
13430
  function view_mode_switch$1(gobj) {
13417
13431
  return [
@@ -13508,7 +13522,7 @@ function apply_view_mode$1(gobj) {
13508
13522
  if ($el) $el.classList.toggle("is-hidden", mode !== "tree");
13509
13523
  });
13510
13524
  if (priv.$mode_btns) for (let [m, $btn] of priv.$mode_btns) {
13511
- $btn.classList.toggle("is-active", m === mode);
13525
+ $btn.classList.toggle("pressed_state", m === mode);
13512
13526
  $btn.setAttribute("aria-pressed", m === mode ? "true" : "false");
13513
13527
  }
13514
13528
  }
@@ -15815,7 +15829,7 @@ function apply_view_mode(gobj) {
15815
15829
  };
15816
15830
  for (let [m, $el] of Object.entries(bodies)) if ($el) $el.classList.toggle("is-hidden", m !== mode);
15817
15831
  if (priv.$mode_btns) for (let [m, $btn] of priv.$mode_btns) {
15818
- $btn.classList.toggle("is-active", m === mode);
15832
+ $btn.classList.toggle("pressed_state", m === mode);
15819
15833
  $btn.setAttribute("aria-pressed", m === mode ? "true" : "false");
15820
15834
  }
15821
15835
  }
@@ -16568,7 +16582,7 @@ function machine_view_switch(gobj) {
16568
16582
  return [
16569
16583
  "button",
16570
16584
  {
16571
- class: `button is-small GCLASS_MACHINE_VIEW GCLASS_MACHINE_VIEW_${v.mode.toUpperCase()}` + (on ? " is-active" : ""),
16585
+ class: `button is-small GCLASS_MACHINE_VIEW GCLASS_MACHINE_VIEW_${v.mode.toUpperCase()}` + (on ? " pressed_state" : ""),
16572
16586
  type: "button",
16573
16587
  "aria-pressed": on ? "true" : "false",
16574
16588
  title: (0, i18next.t)(v.key),
@@ -63567,9 +63581,9 @@ function refresh_legend(gobj) {
63567
63581
  if (is_main && state.main_chosen) extras.push([
63568
63582
  "button",
63569
63583
  {
63570
- class: "GRAPH_LEGEND_STAR button pressed_state",
63584
+ class: "GRAPH_LEGEND_STAR button",
63571
63585
  type: "button",
63572
- style: "padding:0 .5rem;",
63586
+ style: "padding:0 .5rem; box-shadow: inset 0 0 0 2px var(--bulma-text, #2e333d);",
63573
63587
  title: (0, i18next.t)("main topic"),
63574
63588
  "data-i18n-title": "main topic",
63575
63589
  "aria-label": (0, i18next.t)("main topic"),
@@ -63578,7 +63592,7 @@ function refresh_legend(gobj) {
63578
63592
  },
63579
63593
  [[
63580
63594
  "span",
63581
- { style: LEGEND_GLYPH_STYLE },
63595
+ { style: LEGEND_STAR_MAIN_STYLE },
63582
63596
  "★"
63583
63597
  ]],
63584
63598
  { click: (evt) => {
@@ -10519,6 +10519,28 @@ function yui_toolbar(attrs = {}, items = []) {
10519
10519
  updateScrollButtons();
10520
10520
  return $toolbar;
10521
10521
  }
10522
+ /************************************************************
10523
+ * Set or reset the PRESSED state of a toggle.
10524
+ *
10525
+ * It lives here, with `yui_toolbar.css`, and not in
10526
+ * `lib_graph.js` where it was born: a pressed toggle is a
10527
+ * TOOLBAR thing, and a stylesheet rides its JS import -- while
10528
+ * the rule sat in the graph's file, an app without a graph got
10529
+ * the class and no paint, which from the outside is a button
10530
+ * that does not work. `lib_graph.js` re-exports it, so every
10531
+ * caller written against that path keeps working.
10532
+ *
10533
+ * Written with `querySelectorAll` and not with `addClasses`
10534
+ * from `lib_graph.js` on purpose: importing that would drag
10535
+ * `lib_graph.css` into every toolbar, which is the same trap
10536
+ * the other way round.
10537
+ ************************************************************/
10538
+ function set_pressed_state($container, selector, set) {
10539
+ if (!$container) return;
10540
+ $container.querySelectorAll(selector).forEach(($el) => {
10541
+ $el.classList.toggle("pressed_state", !!set);
10542
+ });
10543
+ }
10522
10544
  //#endregion
10523
10545
  //#region src/lib_graph.js
10524
10546
  /***********************************************************************
@@ -10590,19 +10612,6 @@ function set_active_state($container, selector, set) {
10590
10612
  if (set) addClasses($container, selector, "color_active_state");
10591
10613
  else removeClasses($container, selector, "color_active_state");
10592
10614
  }
10593
- /************************************************************
10594
- * Set or reset the 'pressed' state of a TOGGLE.
10595
- *
10596
- * Not one of the colours above: each of those names a KIND of
10597
- * action (create, pending, history, destructive), and a toggle
10598
- * is not an action -- it is a state the control is IN. So it
10599
- * looks pressed instead of changing category, which also keeps
10600
- * it out of the way of a neighbour wearing the same hue.
10601
- ************************************************************/
10602
- function set_pressed_state($container, selector, set) {
10603
- if (set) addClasses($container, selector, "pressed_state");
10604
- else removeClasses($container, selector, "pressed_state");
10605
- }
10606
10615
  /**
10607
10616
  * Returns a smart stroke color in `rgba()` format based on:
10608
10617
  * - The given fill color (hex or rgb[a])
@@ -13406,7 +13415,12 @@ function icon_button$1(gobj, icon, event_name, label_key) {
13406
13415
  * aimed — reaching the graph from the tree would mean passing
13407
13416
  * through the text and rebuilding it on the way — so each view gets
13408
13417
  * its own button and says where it goes. apply_view_mode() moves
13409
- * the `is-active` mark.
13418
+ * the `pressed_state` mark -- the library's one way of saying a
13419
+ * toggle is ON, the same the graph toolbars and the treedb legend
13420
+ * use. It used to be `is-active` with a blue fill of its own: a
13421
+ * STATE wearing a palette colour, which is what the palette does
13422
+ * NOT mean (it names kinds of ACTION), and a third spelling of a
13423
+ * thing the library already had a name for.
13410
13424
  ************************************************************/
13411
13425
  function view_mode_switch$1(gobj) {
13412
13426
  return [
@@ -13503,7 +13517,7 @@ function apply_view_mode$1(gobj) {
13503
13517
  if ($el) $el.classList.toggle("is-hidden", mode !== "tree");
13504
13518
  });
13505
13519
  if (priv.$mode_btns) for (let [m, $btn] of priv.$mode_btns) {
13506
- $btn.classList.toggle("is-active", m === mode);
13520
+ $btn.classList.toggle("pressed_state", m === mode);
13507
13521
  $btn.setAttribute("aria-pressed", m === mode ? "true" : "false");
13508
13522
  }
13509
13523
  }
@@ -15810,7 +15824,7 @@ function apply_view_mode(gobj) {
15810
15824
  };
15811
15825
  for (let [m, $el] of Object.entries(bodies)) if ($el) $el.classList.toggle("is-hidden", m !== mode);
15812
15826
  if (priv.$mode_btns) for (let [m, $btn] of priv.$mode_btns) {
15813
- $btn.classList.toggle("is-active", m === mode);
15827
+ $btn.classList.toggle("pressed_state", m === mode);
15814
15828
  $btn.setAttribute("aria-pressed", m === mode ? "true" : "false");
15815
15829
  }
15816
15830
  }
@@ -16563,7 +16577,7 @@ function machine_view_switch(gobj) {
16563
16577
  return [
16564
16578
  "button",
16565
16579
  {
16566
- class: `button is-small GCLASS_MACHINE_VIEW GCLASS_MACHINE_VIEW_${v.mode.toUpperCase()}` + (on ? " is-active" : ""),
16580
+ class: `button is-small GCLASS_MACHINE_VIEW GCLASS_MACHINE_VIEW_${v.mode.toUpperCase()}` + (on ? " pressed_state" : ""),
16567
16581
  type: "button",
16568
16582
  "aria-pressed": on ? "true" : "false",
16569
16583
  title: t(v.key),
@@ -63562,9 +63576,9 @@ function refresh_legend(gobj) {
63562
63576
  if (is_main && state.main_chosen) extras.push([
63563
63577
  "button",
63564
63578
  {
63565
- class: "GRAPH_LEGEND_STAR button pressed_state",
63579
+ class: "GRAPH_LEGEND_STAR button",
63566
63580
  type: "button",
63567
- style: "padding:0 .5rem;",
63581
+ style: "padding:0 .5rem; box-shadow: inset 0 0 0 2px var(--bulma-text, #2e333d);",
63568
63582
  title: t("main topic"),
63569
63583
  "data-i18n-title": "main topic",
63570
63584
  "aria-label": t("main topic"),
@@ -63573,7 +63587,7 @@ function refresh_legend(gobj) {
63573
63587
  },
63574
63588
  [[
63575
63589
  "span",
63576
- { style: LEGEND_GLYPH_STYLE },
63590
+ { style: LEGEND_STAR_MAIN_STYLE },
63577
63591
  "★"
63578
63592
  ]],
63579
63593
  { click: (evt) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.23.99",
3
+ "version": "7.23.101",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -404,7 +404,7 @@ function apply_view_mode(gobj)
404
404
 
405
405
  if(priv.$mode_btns) {
406
406
  for(let [m, $btn] of priv.$mode_btns) {
407
- $btn.classList.toggle('is-active', m === mode);
407
+ $btn.classList.toggle('pressed_state', m === mode);
408
408
  $btn.setAttribute("aria-pressed", (m === mode)? "true": "false");
409
409
  }
410
410
  }
@@ -983,7 +983,7 @@ function machine_view_switch(gobj)
983
983
  let on = (priv.machine_view === v.mode);
984
984
  return ['button', {class: 'button is-small GCLASS_MACHINE_VIEW ' +
985
985
  `GCLASS_MACHINE_VIEW_${v.mode.toUpperCase()}` +
986
- (on? ' is-active': ''),
986
+ (on? ' pressed_state': ''),
987
987
  type: 'button',
988
988
  'aria-pressed': on? 'true': 'false',
989
989
  title: t(v.key), 'data-i18n-title': v.key,
@@ -283,19 +283,14 @@
283
283
  margin-bottom: 0;
284
284
  }
285
285
 
286
- /* Bulma's `.button.is-active` only borrows the :active border, which on a
287
- * three-way switch is not enough to say WHICH view you are looking at.
288
- * Fill it instead — the mark has to survive a glance. */
289
- /* The raw `--bulma-link` on purpose, and not `-on-scheme`: this is a
290
- * FILL. The `-on-scheme` variants exist for a brand colour used as
291
- * INK -- they darken it on a light scheme so text can sit on the
292
- * page -- and a darkened fill under `link-invert` text is a button
293
- * nobody asked for. Ink takes `-on-scheme`; a background takes the
294
- * raw token and pairs it with `-invert`. */
295
- .C_YUI_JSON .JSON_VIEW_MODE.is-active {
296
- background-color: var(--bulma-link, #3273dc);
297
- border-color: var(--bulma-link, #3273dc);
298
- color: var(--bulma-link-invert, #fff);
286
+ /* The current view is marked with `pressed_state` (`yui_toolbar.css`),
287
+ * which is the library's one way of saying a toggle is ON. This switch
288
+ * used to fill itself with `--bulma-link`: right about Bulma's own
289
+ * `is-active` being too weak to say WHICH view you are looking at, and
290
+ * wrong about the answer -- a colour names a kind of ACTION, and this
291
+ * is a STATE. `z-index` is all that is left, so the marked button's
292
+ * border wins over its neighbours' in the `has-addons` group. */
293
+ .C_YUI_JSON .JSON_VIEW_MODE.pressed_state {
299
294
  z-index: 1;
300
295
  }
301
296
 
package/src/c_yui_json.js CHANGED
@@ -442,7 +442,12 @@ function icon_button(gobj, icon, event_name, label_key)
442
442
  * aimed — reaching the graph from the tree would mean passing
443
443
  * through the text and rebuilding it on the way — so each view gets
444
444
  * its own button and says where it goes. apply_view_mode() moves
445
- * the `is-active` mark.
445
+ * the `pressed_state` mark -- the library's one way of saying a
446
+ * toggle is ON, the same the graph toolbars and the treedb legend
447
+ * use. It used to be `is-active` with a blue fill of its own: a
448
+ * STATE wearing a palette colour, which is what the palette does
449
+ * NOT mean (it names kinds of ACTION), and a third spelling of a
450
+ * thing the library already had a name for.
446
451
  ************************************************************/
447
452
  function view_mode_switch(gobj)
448
453
  {
@@ -553,7 +558,7 @@ function apply_view_mode(gobj)
553
558
 
554
559
  if(priv.$mode_btns) {
555
560
  for(let [m, $btn] of priv.$mode_btns) {
556
- $btn.classList.toggle('is-active', m === mode);
561
+ $btn.classList.toggle('pressed_state', m === mode);
557
562
  $btn.setAttribute("aria-pressed", (m === mode)? "true": "false");
558
563
  }
559
564
  }
@@ -2632,22 +2632,22 @@ function refresh_legend(gobj)
2632
2632
  * is a button too: pressing it hands the choice back to the
2633
2633
  * graph (deduced again). On a deduced one it is a mark. */
2634
2634
  if(is_main && state.main_chosen) {
2635
- extras.push(['button', {class: 'GRAPH_LEGEND_STAR button pressed_state',
2636
- type: 'button', style: 'padding:0 .5rem;',
2635
+ /* MARKED, not pressed -- the same distinction the focused
2636
+ * chip makes two constants above, and for the same reason
2637
+ * here: the star IS the gold mark of the main topic, and a
2638
+ * `pressed_state` repaints the ground under it. 7.23.99
2639
+ * made the glyph inherit the pressed ink so it could be
2640
+ * seen at all; that cost the colour, which is what the
2641
+ * star says. The ring inside the border marks the CHOICE
2642
+ * and leaves the gold alone. */
2643
+ extras.push(['button', {class: 'GRAPH_LEGEND_STAR button',
2644
+ type: 'button',
2645
+ style: 'padding:0 .5rem; ' + LEGEND_FOCUSED_STYLE,
2637
2646
  title: t('main topic'), 'data-i18n-title': 'main topic',
2638
2647
  'aria-label': t('main topic'),
2639
2648
  'data-i18n-aria-label': 'main topic',
2640
2649
  'aria-pressed': 'true'},
2641
- /* `LEGEND_GLYPH_STYLE` and not the gold one:
2642
- * `pressed_state` inverts the ground, and an
2643
- * INLINE colour beats the ink it sets with it.
2644
- * The gold then sat on the scheme's own text
2645
- * colour -- 1.06:1 in dark, ~2:1 in light --
2646
- * so the one star the reader CHOSE was the one
2647
- * that could not be seen. `color: inherit`
2648
- * takes the pressed ink, like the crosshair
2649
- * and the `+N` beside it. */
2650
- [['span', {style: LEGEND_GLYPH_STYLE}, '★']], {
2650
+ [['span', {style: LEGEND_STAR_MAIN_STYLE}, '★']], {
2651
2651
  click: (evt) => {
2652
2652
  evt.stopPropagation();
2653
2653
  gobj_send_event(gobj, "EV_LEGEND_TOPIC",
package/src/lib_graph.css CHANGED
@@ -471,12 +471,12 @@
471
471
  user-select: none;
472
472
  }
473
473
 
474
- .button.pressed_state,
475
- .button.pressed_state:hover {
476
- background-color: var(--bulma-text, #2e333d);
477
- color: var(--bulma-background, #ffffff);
478
- border-color: var(--bulma-text, #2e333d);
479
- }
474
+ /* The DOM toolbar's `pressed_state` lives in `yui_toolbar.css` now, and
475
+ * not here: a pressed toggle is a TOOLBAR thing, and while the rule sat
476
+ * in this file it reached an app only if the app mounted a graph -- the
477
+ * stylesheet rides the JS import. yunovatios copied the rule into its
478
+ * own `app.css` under a third name for exactly that reason. The G6
479
+ * plugin toolbar's own item keeps its rule above, where the plugin is. */
480
480
 
481
481
  /*
482
482
  * Touch: the context menu is a LIST OF COMMANDS, and G6 sizes its
package/src/lib_graph.js CHANGED
@@ -13,6 +13,7 @@ import {
13
13
 
14
14
  // import {t} from "i18next";
15
15
  import "./lib_graph.css";
16
+ import {set_pressed_state} from "./yui_toolbar.js";
16
17
 
17
18
  /************************************************************
18
19
  * Add class to elements selected
@@ -110,23 +111,12 @@ function set_active_state($container, selector, set)
110
111
  }
111
112
  }
112
113
 
113
- /************************************************************
114
- * Set or reset the 'pressed' state of a TOGGLE.
115
- *
116
- * Not one of the colours above: each of those names a KIND of
117
- * action (create, pending, history, destructive), and a toggle
118
- * is not an action -- it is a state the control is IN. So it
119
- * looks pressed instead of changing category, which also keeps
120
- * it out of the way of a neighbour wearing the same hue.
121
- ************************************************************/
122
- function set_pressed_state($container, selector, set)
123
- {
124
- if(set) {
125
- addClasses($container, selector, "pressed_state");
126
- } else {
127
- removeClasses($container, selector, "pressed_state");
128
- }
129
- }
114
+ /* `set_pressed_state` moved to `yui_toolbar.js`, with the rule that
115
+ * paints it: a toggle is not one of the colours above -- each of those
116
+ * names a KIND of action (create, pending, history, destructive) and a
117
+ * toggle is a STATE -- and it belongs to a toolbar, not to a graph. It
118
+ * is re-exported below so every caller written against this path keeps
119
+ * working. */
130
120
 
131
121
  /**
132
122
  * Returns a smart stroke color in `rgba()` format based on:
@@ -85,3 +85,28 @@ a.flex-horizontal-section { /* To make flex any <a> */
85
85
  padding-inline-end: 2rem;
86
86
  }
87
87
 
88
+
89
+ /*********************************************************
90
+ * A toggle that is ON looks PRESSED
91
+ *
92
+ * A neutral inverted pill, no hue: the toolbar palette names KINDS of
93
+ * ACTION (create, pending changes, undo/redo, destructive), and a
94
+ * toggle is not an action -- it is a state the control is IN. Without
95
+ * a hue it also survives colour blindness and greyscale.
96
+ *
97
+ * NOT Bulma's `.button.is-active`, which shares its declaration with
98
+ * `.button:active` (the look of a finger down right now) and only
99
+ * shifts the background 10 points of lightness -- 1.27:1 in light,
100
+ * 1.33:1 in dark, against 9.44:1 / 8.46:1 for this one. A hovered
101
+ * button (5 points) lands halfway to it.
102
+ *
103
+ * The `:hover` half is not decoration: without it, hovering a pressed
104
+ * button hands it back to Bulma's `.button:hover` and the toggle
105
+ * appears to switch off under the pointer.
106
+ *********************************************************/
107
+ .button.pressed_state,
108
+ .button.pressed_state:hover {
109
+ background-color: var(--bulma-text, #2e333d);
110
+ color: var(--bulma-background, #ffffff);
111
+ border-color: var(--bulma-text, #2e333d);
112
+ }
@@ -160,4 +160,30 @@ function yui_toolbar(attrs={}, items = [])
160
160
  return $toolbar;
161
161
  }
162
162
 
163
- export {yui_toolbar, yui_toolbar_icon, YUI_TOOLBAR_ICON_SIZE};
163
+ /************************************************************
164
+ * Set or reset the PRESSED state of a toggle.
165
+ *
166
+ * It lives here, with `yui_toolbar.css`, and not in
167
+ * `lib_graph.js` where it was born: a pressed toggle is a
168
+ * TOOLBAR thing, and a stylesheet rides its JS import -- while
169
+ * the rule sat in the graph's file, an app without a graph got
170
+ * the class and no paint, which from the outside is a button
171
+ * that does not work. `lib_graph.js` re-exports it, so every
172
+ * caller written against that path keeps working.
173
+ *
174
+ * Written with `querySelectorAll` and not with `addClasses`
175
+ * from `lib_graph.js` on purpose: importing that would drag
176
+ * `lib_graph.css` into every toolbar, which is the same trap
177
+ * the other way round.
178
+ ************************************************************/
179
+ function set_pressed_state($container, selector, set)
180
+ {
181
+ if(!$container) {
182
+ return;
183
+ }
184
+ $container.querySelectorAll(selector).forEach(($el) => {
185
+ $el.classList.toggle("pressed_state", !!set);
186
+ });
187
+ }
188
+
189
+ export {yui_toolbar, yui_toolbar_icon, YUI_TOOLBAR_ICON_SIZE, set_pressed_state};