@yuneta/gobj-ui 7.26.29 → 7.26.31

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
@@ -78,6 +78,15 @@ Published as `@yuneta/gobj-ui`. Built on top of [`@yuneta/gobj-js`](https://gith
78
78
  > maximize/restore + close. The self-contained **"shade"** fallback (roll up to
79
79
  > the title bar in place) and its `is-shaded` CSS are **removed**; an app that
80
80
  > relied on shading needs to register a manager.
81
+ >
82
+ > **Where a window lives (7.26.31):** a `C_YUI_WINDOW` whose host names no
83
+ > `$parent` mounts in the **overlay layer of the shell** -- above the content,
84
+ > below the toolbar's dropdowns, the dialogs and the toasts -- and on
85
+ > `document.body` only when there is no shell. It used to be the body always,
86
+ > and since `.yui-shell` is `position: fixed` (a stacking context of its own)
87
+ > a window at z-index 11 covered the WHOLE shell, modal layer included: the
88
+ > confirmation of a window's own close opened under it, out of reach. A
89
+ > `$parent` the host names still wins.
81
90
 
82
91
  ## Two maintained lines
83
92
 
@@ -3152,45 +3161,79 @@ at 38%, which is the whole graph and worth nothing.
3152
3161
  > `ResizeObserver`, and its canvas keeps its birth size for the life of the
3153
3162
  > window while everything resizes around it (fixed in 7.23.31).
3154
3163
 
3155
- ### Toolbar badge — a count pinned to an item's icon
3164
+ ### Badges — a count on a toolbar item or a menu entry
3156
3165
 
3157
3166
  ```js
3158
- /* app_config.json — seeds the FIRST paint only */
3159
- { "id": "alarms", "icon": "yi-triangle-exclamation", "align": "end",
3160
- "aria_label": "alarms", "badge": 0,
3161
- "action": {"type": "navigate", "route": "/alarms"} }
3167
+ /* app_config.json — a toolbar item and a menu entry; the fields seed the
3168
+ * FIRST paint only */
3169
+ "toolbar": {"items": [
3170
+ { "id": "bell", "icon": "yi-triangle-exclamation", "align": "end",
3171
+ "aria_label": "alarms", "badge": 0,
3172
+ "action": {"type": "navigate", "route": "/alarms"} }
3173
+ ]},
3174
+ "menu": {"primary": {"items": [
3175
+ { "id": "alarms", "name": "alarms", "icon": "yi-triangle-exclamation", "route": "/alarms",
3176
+ "badge": 0, "badge_tone": "warning",
3177
+ "target": {"stage": "main", "gclass": "C_ALARMS"} }
3178
+ ]}}
3162
3179
 
3163
3180
  /* the interface that matters: a count is a RUNTIME fact */
3164
- yui_shell_set_toolbar_item_badge(shell, "alarms", 3);
3165
- yui_shell_set_toolbar_item_badge(shell, "alarms", 0); // clears it
3181
+ yui_shell_set_toolbar_item_badge(shell, "bell", 3);
3182
+ yui_shell_set_nav_item_badge(shell, "alarms", 3);
3183
+ yui_shell_set_nav_item_badge(shell, "alarms", 3, "danger"); // with a tone
3184
+ yui_shell_set_nav_item_badge(shell, "alarms", 0); // clears it
3166
3185
  ```
3167
3186
 
3168
3187
  An icon-only toolbar button is a link; the badge is what makes it a
3169
3188
  **signal**. Without a number, an alarm bell cannot say whether anything needs
3170
- you — which is the reason to look at it at all.
3189
+ you — which is the reason to look at it at all. The same goes for the menu
3190
+ entry that leads to the alarms.
3171
3191
 
3172
- Rules baked in, all for the same reason (a badge that lies costs more than no
3173
- badge):
3192
+ Rules baked in, the same for both (`src/yui_badge.js` draws and paints them),
3193
+ all for the same reason (a badge that lies costs more than no badge):
3174
3194
 
3175
3195
  - **`0`, `""`, `null` and `false` all clear it.** A badge reading "0" is worse
3176
3196
  than none: it draws the eye to say nothing.
3177
- - **Over 99 renders `99+`.** The toolbar is a fixed-width row and a four-digit
3178
- pill pushes its neighbours off a phone screen.
3197
+ - **Over 99 renders `99+`.** The toolbar and an icon bar are fixed-width rows
3198
+ and a four-digit pill pushes its neighbours off a phone screen.
3179
3199
  - **A string passes through** for the states that are not counts (`"!"`, `"…"`).
3180
- - **Unknown item id is a silent no-op**, so an app whose toolbar has no such
3181
- item does not log an error on every tick of whatever feeds the number.
3200
+ - **A tone, optional:** `"danger"` (the default look), `"warning"`, `"info"`,
3201
+ `"success"`, `"primary"` or `"link"` — Bulma's `is-<tone>` on the badge, to
3202
+ say HOW BAD the count is (the alarms coloured by the worst state among
3203
+ them). A fill: the raw Bulma token under its `-invert` ink, the same pair in
3204
+ both themes. **An unknown tone is logged** (`log_error`) and drawn with the
3205
+ default look. Each call states the WHOLE badge: a call without a tone draws
3206
+ the default look, so a call with three arguments works as it always did.
3207
+ - **Unknown item id is a silent no-op**, so an app whose toolbar or menu has no
3208
+ such item does not log an error on every tick of whatever feeds the number.
3182
3209
  - Writing the **same** value again touches no DOM: the badge is a
3183
3210
  `role="status"` live region, and rewriting it would have a screen reader
3184
3211
  announce the same number on every tick.
3185
3212
 
3186
- `role="status"` and not `aria-hidden`, deliberately: the button carries an
3187
- explicit `aria-label`, and an explicit label **replaces** an element's content
3188
- for a screen reader — a badge inside it would otherwise be silent. As its own
3189
- live region it is both read and announced when it changes.
3190
-
3191
- > `C_YUI_NAV` items do **not** have this. Its item contract listed `badge` for a
3192
- > long time and nothing ever rendered it; the claim is gone. Implement it there
3193
- > the day a menu entry needs one.
3213
+ `role="status"` and not `aria-hidden`, deliberately: the button or link
3214
+ carries an explicit `aria-label`, and an explicit label **replaces** an
3215
+ element's content for a screen reader — a badge inside it would otherwise be
3216
+ silent. As its own live region it is both read and announced when it changes.
3217
+
3218
+ **The menu entry's badge reaches every instance of the id.** A menu hosted by
3219
+ two zones (a rail on desktop, an icon bar on a phone) draws the same entry
3220
+ twice, and a drawer may repeat it: one `yui_shell_set_nav_item_badge()` call
3221
+ paints them all (it sends `EV_SET_ITEM_BADGE` to every `C_YUI_NAV` of the
3222
+ shell). And the value is KEPT — by each nav, in its `badges` attr, and by the
3223
+ shell, for the navs it creates later — so a rebuild draws it again: a
3224
+ `yui_shell_set_submenu()` with new item objects, a `submenu.index` landing
3225
+ mounted after the call. Once the call has spoken for an id, its value wins
3226
+ over the `badge` of any item with that id. It covers the entries of
3227
+ `app_config.json`'s menus and submenus and the items given to
3228
+ `yui_shell_set_submenu()`; the nodes of a `C_YUI_NODE` tree are not menu
3229
+ items, and carry none.
3230
+
3231
+ Where it sits: on the corner of the icon where the entry is an icon over its
3232
+ label (`icon-bar`, `cards`, a stacked item) or an icon alone; after the label
3233
+ elsewhere (`vertical`, `drawer`, `submenu`, `tabs`, an `accordion` head or
3234
+ leaf). A `breadcrumb` draws none, deliberately: a crumb names a step of the way
3235
+ in, and the count belongs to the entry that leads there. Logical class
3236
+ `NAV_ITEM_BADGE` (`TOOLBAR_ITEM_BADGE` in the toolbar), look `yui-badge`.
3194
3237
 
3195
3238
  ### Toasts — `yui_shell_show_info` / `_warning` / `_error`
3196
3239