@smwb/ui-styles 2.9.0 → 2.10.1

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
@@ -339,6 +339,27 @@ holds the tab stop (`menuitemcheckbox`, `menuitemradio`, `treeitem`, `spinbutton
339
339
  `scrollbar`) are listed next to the focusable elements. A control the generic list cannot see opts out with
340
340
  `.smwb-appbar__no-drag` or `data-no-drag`.
341
341
 
342
+ #### Overlay layers
343
+
344
+ The surfaces the components portal to `<body>` sit in a z-index scale of Less variables, so an app puts them over its
345
+ own header, sheets and windows from its theme, with no rule on the `.smwb-*` classes:
346
+
347
+ | Variable | Default | Layer |
348
+ | ----------- | ------- | -------------------------------------------------------------------------------------- |
349
+ | `@menuZ` | 1300 | the floating `Menu` (`OverflowMenu`, `SelectField` options, submenus), above the modal |
350
+ | `@tooltipZ` | 1400 | the `Tooltip` tip, above the menu and the dialogs it is raised from |
351
+
352
+ The tip stays above the menu: a hint on a menu item, on a dialog's button or on a docked window's control must not hide
353
+ under them. Keep that order if you change one value. The modal overlay (1001), the chat shell (1002), the floating
354
+ window (`@floatingWindowZ`, 150) and the sheet (100) stay below both. `npm run lint` of this package renders the
355
+ stylesheet and checks the order and that each variable reaches its rule.
356
+
357
+ ```less
358
+ // theme.config: the host's own layers go up to 2000, the menus and tips stay over them
359
+ @menuZ: 2100;
360
+ @tooltipZ: 2200;
361
+ ```
362
+
342
363
  ## License
343
364
 
344
365
  [MIT](./LICENSE)
@@ -4,7 +4,7 @@
4
4
 
5
5
  &--floating {
6
6
  box-shadow: @menuBoxShadow;
7
- z-index: 1300;
7
+ z-index: @menuZ;
8
8
  min-width: 112px;
9
9
  cursor: default;
10
10
  }
@@ -2,16 +2,25 @@
2
2
  border-radius: 4px;
3
3
  background-color: var(--smui-tooltipBg);
4
4
  color: var(--smui-tooltipTextColor);
5
- z-index: 5;
5
+ z-index: @tooltipZ;
6
6
  font-size: 12px;
7
- padding: 0 @tooltipPaddingX;
8
- height: 24px;
7
+ line-height: @tooltipLineHeight;
8
+ padding: @tooltipPaddingY @tooltipPaddingX;
9
+ // A one-line tip is this tall (line + padding) and a longer one grows with its content. A fixed
10
+ // `height` with `overflow: hidden` showed the first line of a tip made of several and cut the rest.
11
+ min-height: @tooltipMinHeight;
12
+ box-sizing: border-box;
9
13
  display: inline-flex;
10
14
  align-items: center;
11
15
  justify-content: center;
12
- overflow: hidden;
13
- white-space: nowrap;
14
16
  min-width: 50px;
17
+ // As wide as its text, up to the window (less the 8px the placement keeps free on each side), and then
18
+ // the text wraps, a long path with no space in it too. `nowrap` ran a long tip off a narrow window
19
+ // and widened the page; `max-content` keeps a tip placed near the edge from wrapping early.
20
+ width: max-content;
21
+ max-width: calc(100vw - @tooltipViewportGap);
22
+ white-space: normal;
23
+ overflow-wrap: anywhere;
15
24
  // The component mounts the tooltip only while it shows — on hover, on click,
16
25
  // or while `open` — so it is visible whenever it is in the DOM. (It used to be
17
26
  // shown by :hover alone, which hid click and manual tooltips.)
@@ -369,6 +369,12 @@
369
369
  @toggleCompactMaxHeight: 28px;
370
370
 
371
371
  @tooltipPaddingX: @smui-space-sm;
372
+ @tooltipPaddingY: @smui-space-xs;
373
+ // Line + vertical padding = the min height, so a one-line tip is 24px.
374
+ @tooltipLineHeight: 16px; // off-grid
375
+ @tooltipMinHeight: @smui-space-6;
376
+ // Free space kept at the window's two sides (the placement shifts a tip 8px in): twice @smui-space-sm.
377
+ @tooltipViewportGap: (@smui-space-sm * 2);
372
378
 
373
379
  @treeViewIndent: 30px; // off-grid
374
380
  @treeViewItemGap: 10px; // off-grid
@@ -559,6 +565,19 @@
559
565
  // stack. Hosts add their stacking index on top, leaving headroom before 200.
560
566
  @floatingWindowZ: 150;
561
567
 
568
+ /*-------------------
569
+ Overlay layers
570
+ --------------------*/
571
+ // z-index of the surfaces the components portal to <body>. A theme overrides them by setting
572
+ // the variable, with no rule on the `.smwb-*` classes; each must stay above whatever the host
573
+ // app stacks under it (its header, sheets, windows, dialogs).
574
+ // A floating Menu (OverflowMenu, SelectField options, submenus) sits above the modal (1001),
575
+ // the chat shell (1002) and every surface that opens it. Off-grid.
576
+ @menuZ: 1300;
577
+ // A Tooltip sits above the menu and the dialogs it is raised from: a hint on a menu item,
578
+ // a dialog's button or a docked window's control must not hide under them. Off-grid.
579
+ @tooltipZ: 1400;
580
+
562
581
  /*-------------------
563
582
  Tooltip
564
583
  --------------------*/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smwb/ui-styles",
3
- "version": "2.9.0",
3
+ "version": "2.10.1",
4
4
  "description": "Framework-agnostic LESS design tokens and component styles (smwb-*) shared by the @smwb UI libraries. Prebuilt aggregate CSS lives in @smwb/ui-css.",
5
5
  "license": "MIT",
6
6
  "sideEffects": [
@@ -19,7 +19,7 @@
19
19
  "./package.json": "./package.json"
20
20
  },
21
21
  "scripts": {
22
- "lint": "node scripts/check-aggregate.mjs && node scripts/check-tokens.mjs && node scripts/check-control-heights.mjs && node scripts/check-typography-case.mjs && node scripts/check-chart-series.mjs && node scripts/check-normalize-specificity.mjs"
22
+ "lint": "node scripts/check-aggregate.mjs && node scripts/check-tokens.mjs && node scripts/check-control-heights.mjs && node scripts/check-typography-case.mjs && node scripts/check-overlay-layers.mjs && node scripts/check-tooltip-grows.mjs && node scripts/check-chart-series.mjs && node scripts/check-normalize-specificity.mjs"
23
23
  },
24
24
  "homepage": "https://sourcecraft.dev/elfenmail/ui",
25
25
  "repository": {