@liberation-data/desk 0.41.0 → 0.42.0

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.
Files changed (44) hide show
  1. package/README.md +58 -5
  2. package/dist/css/controls.css +21 -2
  3. package/dist/css/dock.css +1 -1
  4. package/dist/css/looks.css +50 -4
  5. package/dist/css/tokens.css +1 -0
  6. package/dist/css/windows.css +152 -5
  7. package/dist/desk.css +225 -12
  8. package/dist/react/Desktop.d.ts +12 -3
  9. package/dist/react/Desktop.d.ts.map +1 -1
  10. package/dist/react/Desktop.js +16 -7
  11. package/dist/react/Desktop.js.map +1 -1
  12. package/dist/react/MenuBar.d.ts +7 -0
  13. package/dist/react/MenuBar.d.ts.map +1 -1
  14. package/dist/react/MenuBar.js +15 -0
  15. package/dist/react/MenuBar.js.map +1 -1
  16. package/dist/react/arrange.d.ts +6 -0
  17. package/dist/react/arrange.d.ts.map +1 -1
  18. package/dist/react/arrange.js +21 -0
  19. package/dist/react/arrange.js.map +1 -1
  20. package/dist/react/index.d.ts +3 -1
  21. package/dist/react/index.d.ts.map +1 -1
  22. package/dist/react/index.js +2 -1
  23. package/dist/react/index.js.map +1 -1
  24. package/dist/react/tabs.d.ts +7 -1
  25. package/dist/react/tabs.d.ts.map +1 -1
  26. package/dist/react/tabs.js +13 -8
  27. package/dist/react/tabs.js.map +1 -1
  28. package/dist/react/widgets.d.ts +33 -0
  29. package/dist/react/widgets.d.ts.map +1 -0
  30. package/dist/react/widgets.js +213 -0
  31. package/dist/react/widgets.js.map +1 -0
  32. package/llms.txt +30 -4
  33. package/package.json +1 -1
  34. package/src/css/controls.css +21 -2
  35. package/src/css/dock.css +1 -1
  36. package/src/css/looks.css +50 -4
  37. package/src/css/tokens.css +1 -0
  38. package/src/css/windows.css +152 -5
  39. package/src/react/Desktop.tsx +29 -9
  40. package/src/react/MenuBar.tsx +18 -0
  41. package/src/react/arrange.ts +23 -0
  42. package/src/react/index.ts +3 -1
  43. package/src/react/tabs.tsx +23 -10
  44. package/src/react/widgets.tsx +265 -0
package/README.md CHANGED
@@ -119,8 +119,8 @@ same way.
119
119
  />
120
120
  ```
121
121
 
122
- `info` puts an (i) at the end of the title bar — at the start on GNOME and Windows, whose end is the controls' — holding what this window is. Every window that has one
123
- keeps it in the same place, so somebody who wonders what they are looking at always knows where to ask;
122
+ `info` puts an (i) on the far edge of the title bar, opposite the controls — at the end on a Mac, at the
123
+ start on GNOME and Windows — holding what this window is. Every window that has one keeps it in the same place, so somebody who wonders what they are looking at always knows where to ask;
124
124
  a window with nothing to explain has none. Explanation only, as with `InfoTip` — a warning belongs in the
125
125
  window itself.
126
126
 
@@ -230,6 +230,56 @@ a menu stays reachable, so something that can no longer open can still be remove
230
230
  A stack can be kept the same way: `dockStack({ …, movable: true, contextMenu })` takes drops, is carried
231
231
  along the dock, and offers its own right-click menu.
232
232
 
233
+ ## Widgets
234
+
235
+ Glances on the desk itself, for state that is always there and is not worth a window: what is loaded, a
236
+ job's progress, a connection. Each opens the window it is about, which says the same in full.
237
+
238
+ ```tsx
239
+ const widgets: Widget[] = [
240
+ {
241
+ id: 'due',
242
+ label: 'Service',
243
+ content: <><Led color="amber" /> 2 jobs due</>,
244
+ onSelect: () => desk.open('service'),
245
+ },
246
+ { id: 'distance', label: 'This fortnight', content: <b>231 km</b>, onSelect: () => desk.open('rides') },
247
+ ]
248
+
249
+ <Desktop title={id => TITLES[id]} renderWindow={renderWindow} widgets={widgets} />
250
+
251
+ // The Window menu: "Widgets in front", a tick for each.
252
+ { id: 'window', label: 'Window', items: () => [
253
+ menuCommand('Arrange', DeskCommands.arrange, { shortcut: 'mod+alt+a' }),
254
+ ...(widgets.length ? [menuSeparator(), ...widgetMenuItems(widgets)] : []),
255
+ ] }
256
+ ```
257
+
258
+ They stack in a corner of the desk, `top-right` unless `widgetCorner` says `top-left`, `bottom-left` or
259
+ `bottom-right`, in the order given, clear of the dock wherever `<Desktop>` does. Each is as tall as its content
260
+ and `--desk-widget-width` (200px) wide; more than the desk is tall scroll. A desk 640px wide or less, or 400px
261
+ tall or less, and the one-window-at-a-time layout, show none.
262
+
263
+ **Behind the windows** is where they are, on the desk surface. `widgetMenuItems(widgets)` gives the Window
264
+ menu a "Widgets in front" header and a checkable item for each (`menuitemcheckbox`); a tick keeps that widget
265
+ in front of the windows, in a frame of the dock's glass around an opaque surface, and nearest the corner, ahead of
266
+ those behind; it is remembered in this browser under `desk.widgets.<id>`.
267
+ `isWidgetInFront(id)`, `setWidgetInFront(id, front)` and `useWidgetsInFront()` read and change the same choice.
268
+ It returns nothing when there are no widgets, so the section goes with them. Window → Arrange leaves the corner of
269
+ the widgets in front to them, taking a column or a strip along the edge, whichever leaves the windows more room,
270
+ and the strip stops where the widgets behind begin, so the windows cover those whole; widgets behind take nothing.
271
+
272
+ With `onSelect` a widget is a button, so its `content` holds no controls of its own; without it, it only
273
+ shows. `label` says what it is: it is read before the content and not drawn, so don't repeat it there; it is
274
+ also the widget's name in the Window menu. A widget behind the windows that a window covers is `inert`, so Tab
275
+ and a screen reader pass it by; one with no window over it, or kept in front, can be reached. Those that can be
276
+ clicked are one tab stop, with the arrow keys along them; Escape goes back to the key window. A widget taken
277
+ away while it has the keyboard hands it to the next one, or to the key window, and so does one a window comes
278
+ over.
279
+
280
+ Nothing is read out as content changes. `announce` is said, politely, when it changes: give it for what
281
+ somebody would want to hear, such as "Backup finished", and not for every percent of the way there.
282
+
233
283
  ## Inside a window: a pane
234
284
 
235
285
  ```tsx
@@ -339,7 +389,9 @@ tab stop whose arrow keys move the selection past disabled options. Its selectio
339
389
  than the track on a dark ground and on a light one, which slides to the option chosen. Tabs look similar and are not the same
340
390
  thing: a segmented control chooses a value and what it governs stays on screen, while tabs switch the view
341
391
  beneath them, which sits in a panel the selected tab names. `actions` puts controls for the whole window,
342
- such as Refresh, at the end of the strip, so a window with tabs needs no header row above them. A toggle is a `switch` for settings that
392
+ such as Refresh, at the end of the strip, so a window with tabs needs no header row above them. A tab that
393
+ can't be chosen yet takes `disabled`, or a string saying why (`disabled: 'Waiting for the aerial photo'`),
394
+ which a screen reader hears and a pointer sees on hover. A toggle is a `switch` for settings that
343
395
  apply at once — a checkbox is for one that waits for Save. A text field always has a label (`labelHidden`
344
396
  keeps it for screen readers), and an `error` marks it invalid and replaces the help text. A choice group
345
397
  is the handful of cards a setup step turns on — an icon, a label, a line of why — with native radios
@@ -751,7 +803,7 @@ it. All three overlays trap focus, give it back on close, and answer Escape topm
751
803
  ## Menu bar
752
804
 
753
805
  ```tsx
754
- import { MenuBar, menuAction, menuCommand, menuSeparator, windowMenuItems } from '@liberation-data/desk/react'
806
+ import { MenuBar, menuAction, menuCommand, menuSeparator, widgetMenuItems, windowMenuItems } from '@liberation-data/desk/react'
755
807
 
756
808
  <MenuBar
757
809
  leading={<AppMark />}
@@ -760,6 +812,7 @@ import { MenuBar, menuAction, menuCommand, menuSeparator, windowMenuItems } from
760
812
  menuCommand('Settings…', 'app.settings', { shortcut: 'mod+comma' })] },
761
813
  { id: 'window', label: 'Window', items: () => [ // a function: re-read each time it opens
762
814
  menuCommand('Arrange', DeskCommands.arrange),
815
+ ...(widgets.length ? [menuSeparator(), ...widgetMenuItems(widgets)] : []), // "Widgets in front"
763
816
  menuSeparator(),
764
817
  ...windowMenuItems(desk.getState(), desk.focus, titleOf),
765
818
  ] },
@@ -1043,7 +1096,7 @@ npm install
1043
1096
  npm test # vitest
1044
1097
  npm run typecheck
1045
1098
  npm run example # the Garage sample in examples/garage
1046
- npm run size # the gzipped budget: core 16 KiB, react 62, css 20, fx 5
1099
+ npm run size # the gzipped budget: core 16 KiB, react 76, css 22, fx 5
1047
1100
  npm run check # everything CI runs
1048
1101
  npm run check:browser # the generated-app bridge in real Chrome, against a running sample
1049
1102
  npm run build # dist/
@@ -816,7 +816,7 @@
816
816
  transition: background .12s var(--desk-ease), color .12s var(--desk-ease);
817
817
  }
818
818
 
819
- .desk-tab:hover:not(:disabled):not([aria-selected="true"]) {
819
+ .desk-tab:hover:not(:disabled):not([aria-disabled="true"]):not([aria-selected="true"]) {
820
820
  background: color-mix(in srgb, var(--desk-ink) 6%, transparent);
821
821
  color: var(--desk-ink);
822
822
  }
@@ -832,11 +832,30 @@
832
832
  outline-offset: -2px;
833
833
  }
834
834
 
835
- .desk-tab:disabled {
835
+ .desk-tab:disabled,
836
+ .desk-tab[aria-disabled="true"] {
836
837
  opacity: .45;
837
838
  cursor: default;
838
839
  }
839
840
 
841
+ /* An unavailable tab the arrows stop on: the ring is drawn in full, the label stays dimmed. */
842
+ .desk-tab[aria-disabled="true"]:focus-visible {
843
+ opacity: 1;
844
+ color: color-mix(in srgb, var(--desk-muted) 45%, transparent);
845
+ }
846
+
847
+ /* Why a tab is unavailable: read by a screen reader, shown to a pointer as the tab's title. */
848
+ .desk-tab-why {
849
+ position: absolute;
850
+ width: 1px;
851
+ height: 1px;
852
+ margin: -1px;
853
+ padding: 0;
854
+ overflow: hidden;
855
+ clip-path: inset(50%);
856
+ white-space: nowrap;
857
+ }
858
+
840
859
  .desk-tab-badge {
841
860
  min-width: 18px;
842
861
  padding: 0 5px;
package/dist/css/dock.css CHANGED
@@ -221,7 +221,7 @@
221
221
  height: 100%;
222
222
  }
223
223
 
224
- /* A dot for "a window is open", brighter when it has focus. */
224
+ /* A dot for "a window is open", brighter when it has focus: a 4px dot 2px off its tile. */
225
225
  .desk-dock-item[data-running]::after {
226
226
  content: "";
227
227
  position: absolute;
@@ -50,11 +50,20 @@
50
50
  font-size: var(--desk-text-small);
51
51
  }
52
52
 
53
- /* The end of the bar is the controls', so the (i) leads it. */
54
- [data-look="gnome"] .desk-titlebar > .desk-popover-anchor:first-child {
53
+ /*
54
+ * The end of the bar is the controls', so the (i) is at its start, on the far edge (it is first in the
55
+ * document). It takes the spare room after it, and nothing else in the bar reaches for any: an auto
56
+ * margin on both sides of it would centre it in the room, under the heading.
57
+ */
58
+ [data-look="gnome"] .desk-titlebar > .desk-popover-anchor:has(> .desk-window-info) {
59
+ margin-left: 0;
55
60
  margin-right: auto;
56
61
  }
57
62
 
63
+ [data-look="gnome"] .desk-window-actions {
64
+ margin-left: 0;
65
+ }
66
+
58
67
  /*
59
68
  * The middle is the heading's, so the count waits at the end of the bar, before the controls, and
60
69
  * the heading keeps clear of both. A narrow bar keeps the count and lets the track go.
@@ -62,6 +71,7 @@
62
71
  [data-look="gnome"] .desk-window-progress {
63
72
  position: static;
64
73
  transform: none;
74
+ margin-left: 0;
65
75
  }
66
76
 
67
77
  [data-look="gnome"] .desk-titlebar[data-progress] .desk-titlebar-heading {
@@ -139,6 +149,11 @@
139
149
  height: 5px;
140
150
  }
141
151
 
152
+ /* The (i) is first in the document, at the start of the bar: the end is the controls'. */
153
+ [data-look="windows"] .desk-titlebar > .desk-popover-anchor:has(> .desk-window-info) {
154
+ margin-left: 0;
155
+ }
156
+
142
157
  [data-look="windows"] .desk-title {
143
158
  flex: 1 1 auto;
144
159
  font-size: var(--desk-text-small);
@@ -191,7 +206,8 @@
191
206
  * inside them, come out dark too — as the shell's own menus do.
192
207
  */
193
208
  [data-look="gnome"] .desk-menubar,
194
- [data-look="gnome"] .desk-dock {
209
+ [data-look="gnome"] .desk-dock,
210
+ [data-look="gnome"] .desk-widget[data-front] {
195
211
  --desk-ink: #ffffff;
196
212
  --desk-muted: rgb(255 255 255 / 68%);
197
213
  --desk-surface: #2a2a2a;
@@ -226,8 +242,13 @@
226
242
  color: var(--desk-ink);
227
243
  }
228
244
 
229
- [data-look="gnome"] .desk-dock {
245
+ /* A widget kept in front is the dash's material too. */
246
+ [data-look="gnome"] .desk-dock,
247
+ [data-look="gnome"] .desk-widget[data-front] {
230
248
  --desk-dock-glass: rgb(24 24 24 / 86%);
249
+ }
250
+
251
+ [data-look="gnome"] .desk-dock {
231
252
  border-radius: 20px;
232
253
  }
233
254
 
@@ -236,6 +257,31 @@
236
257
  border-radius: 12px;
237
258
  }
238
259
 
260
+ /*
261
+ * The running dot by the glyph, as GNOME's dash has it: its tiles are transparent, so 3px off a tile no one sees is out
262
+ * by the dock's edge. The glyph is 46% of its item, centred (a stack's 72%), so its edge is 27% (14%) in; the 4px dot
263
+ * stands 4px off that, on whichever side the dock is.
264
+ */
265
+ [data-look="gnome"] .desk-dock {
266
+ --desk-dock-dot-glyph: calc(27% - 8px);
267
+ }
268
+
269
+ [data-look="gnome"] .desk-dock .desk-dock-item[data-stack] {
270
+ --desk-dock-dot-glyph: calc(14% - 8px);
271
+ }
272
+
273
+ [data-look="gnome"] .desk-dock[data-side="bottom"] .desk-dock-item[data-running]::after {
274
+ bottom: var(--desk-dock-dot-glyph);
275
+ }
276
+
277
+ [data-look="gnome"] .desk-dock[data-side="left"] .desk-dock-item[data-running]::after {
278
+ left: var(--desk-dock-dot-glyph);
279
+ }
280
+
281
+ [data-look="gnome"] .desk-dock[data-side="right"] .desk-dock-item[data-running]::after {
282
+ right: var(--desk-dock-dot-glyph);
283
+ }
284
+
239
285
  /* No magnification: GNOME's dash lights an item up rather than growing it. */
240
286
  [data-look="gnome"] .desk-dock .desk-dock-item:hover:not(:disabled),
241
287
  [data-look="windows"] .desk-dock .desk-dock-item:hover:not(:disabled) {
@@ -85,6 +85,7 @@
85
85
  --desk-dock-icon: linear-gradient(160deg, #ffffff, #eceff5);
86
86
  --desk-badge: #ef4444;
87
87
  --desk-badge-ink: #ffffff;
88
+ --desk-widget-width: 200px;
88
89
  /* Room the stage leaves at the bottom for something of the app's own. An overlay dock makes its own. */
89
90
  --desk-inset-bottom: 0px;
90
91
  }
@@ -186,16 +186,18 @@
186
186
  color: var(--desk-muted);
187
187
  }
188
188
 
189
- /* The note gives up the spare room; the (i) keeps its place at the end of the bar. */
190
189
  /*
191
- * The (i) is the bar's last word, at its trailing end, with or without a note before it. It sits in its popover's
192
- * anchor, so the anchor is what the bar lays out: a margin on the button inside it would move nothing.
190
+ * The (i) is on the bar's far edge, opposite the controls: here, on a Mac, it is the bar's last word, after
191
+ * the note and the actions. Whatever comes before it takes the spare room, and it follows. It sits in its
192
+ * popover's anchor, so the anchor is what the bar lays out: a margin on the button inside it would move
193
+ * nothing. The other looks put it first, and say so in looks.css.
193
194
  */
194
195
  .desk-titlebar > .desk-popover-anchor:has(> .desk-window-info) {
195
196
  margin-left: auto;
196
197
  }
197
198
 
198
- .desk-window-note ~ .desk-popover-anchor:has(> .desk-window-info) {
199
+ .desk-window-note ~ .desk-popover-anchor:has(> .desk-window-info),
200
+ .desk-window-actions ~ .desk-popover-anchor:has(> .desk-window-info) {
199
201
  margin-left: var(--desk-space-2);
200
202
  }
201
203
 
@@ -244,6 +246,12 @@
244
246
  margin-left: var(--desk-space-3);
245
247
  }
246
248
 
249
+ /* The count has taken the spare room, so what follows it keeps to it rather than splitting the room. */
250
+ .desk-window-progress ~ .desk-window-actions,
251
+ .desk-window-progress ~ .desk-popover-anchor:has(> .desk-window-info) {
252
+ margin-left: var(--desk-space-2);
253
+ }
254
+
247
255
  .desk-titlebar[data-progress] .desk-title,
248
256
  .desk-titlebar[data-progress] .desk-window-note {
249
257
  max-width: none;
@@ -271,7 +279,13 @@
271
279
  .desk-window-progress-fill { transition: none; }
272
280
  }
273
281
 
274
- .desk-popover-anchor:has(> .desk-window-info) + .desk-window-actions,
282
+ /* Narrower still, the count keeps its words and lets the track go, so the bar's far edge stays on the bar. */
283
+ @container (max-width: 400px) {
284
+ .desk-window-progress-track {
285
+ display: none;
286
+ }
287
+ }
288
+
275
289
  .desk-window-note + .desk-window-actions {
276
290
  margin-left: var(--desk-space-1);
277
291
  }
@@ -412,6 +426,139 @@
412
426
  right: var(--desk-padding);
413
427
  }
414
428
 
429
+ /* ── Widgets: glances in a corner of the stage, behind the windows unless the person keeps one in front ── */
430
+
431
+ /* As big as the stage, to ask its size. No z-index, so each widget stands behind or in front on its own. */
432
+ .desk-widgets {
433
+ container: desk-widgets / size;
434
+ position: absolute;
435
+ inset: 0;
436
+ pointer-events: none;
437
+ }
438
+
439
+ /*
440
+ * A margin of padding for the focus ring, which a list that scrolls would clip. Too many for the desk, and it
441
+ * scrolls: it takes the pointer, as a scroller without it is passed over by the wheel, a finger and its scrollbar.
442
+ */
443
+ .desk-widget-list {
444
+ position: absolute;
445
+ pointer-events: auto;
446
+ box-sizing: border-box;
447
+ width: calc(var(--desk-widget-width) + 2 * var(--desk-space-1));
448
+ max-height: calc(100% - 2 * (var(--desk-padding) - var(--desk-space-1)) - var(--desk-inset-bottom));
449
+ padding: var(--desk-space-1);
450
+ display: flex;
451
+ flex-direction: column;
452
+ gap: var(--desk-space-2);
453
+ overflow: hidden auto;
454
+ scrollbar-width: thin;
455
+ }
456
+
457
+ .desk-widgets[data-corner^="top"] > .desk-widget-list {
458
+ top: calc(var(--desk-padding) - var(--desk-space-1));
459
+ }
460
+
461
+ .desk-widgets[data-corner^="bottom"] > .desk-widget-list {
462
+ bottom: calc(var(--desk-padding) - var(--desk-space-1) + var(--desk-inset-bottom));
463
+ }
464
+
465
+ .desk-widgets[data-corner$="left"] > .desk-widget-list {
466
+ left: calc(var(--desk-padding) - var(--desk-space-1));
467
+ }
468
+
469
+ .desk-widgets[data-corner$="right"] > .desk-widget-list {
470
+ right: calc(var(--desk-padding) - var(--desk-space-1));
471
+ }
472
+
473
+ /* Behind: on the desk surface, over what the app draws on an empty desk; windows start at 10. */
474
+ .desk-widget {
475
+ flex: none;
476
+ box-sizing: border-box;
477
+ position: relative;
478
+ z-index: 1;
479
+ min-height: 44px;
480
+ padding: 0;
481
+ border: 1px solid var(--desk-rule);
482
+ border-radius: var(--desk-radius);
483
+ background: var(--desk-surface);
484
+ color: var(--desk-ink);
485
+ font-family: var(--desk-font);
486
+ font-size: var(--desk-text-body);
487
+ text-align: start;
488
+ overflow: clip;
489
+ overflow-wrap: anywhere;
490
+ user-select: none;
491
+ }
492
+
493
+ /* Its words, on an opaque surface. */
494
+ .desk-widget-surface {
495
+ display: block;
496
+ box-sizing: border-box;
497
+ min-height: 42px;
498
+ padding: var(--desk-space-2) var(--desk-space-3);
499
+ }
500
+
501
+ /* In front, by choice: a frame of the dock's glass round that surface, as a stack's panel. No shadow: the list clips it. */
502
+ .desk-widget[data-front] {
503
+ z-index: 800;
504
+ padding: var(--desk-space-1);
505
+ background: var(--desk-dock-glass);
506
+ backdrop-filter: blur(28px) saturate(170%);
507
+ -webkit-backdrop-filter: blur(28px) saturate(170%);
508
+ }
509
+
510
+ .desk-widget[data-front] > .desk-widget-surface {
511
+ /* The frame comes out of the padding: ticking one keeps its size. */
512
+ min-height: calc(42px - 2 * var(--desk-space-1));
513
+ padding: calc(var(--desk-space-2) - var(--desk-space-1)) calc(var(--desk-space-3) - var(--desk-space-1));
514
+ border-radius: max(0px, calc(var(--desk-radius) - var(--desk-space-1)));
515
+ background: var(--desk-surface);
516
+ }
517
+
518
+ button.desk-widget {
519
+ cursor: pointer;
520
+ transition: border-color .12s var(--desk-ease);
521
+ }
522
+
523
+ button.desk-widget:hover {
524
+ border-color: color-mix(in srgb, var(--desk-accent) 45%, var(--desk-rule));
525
+ }
526
+
527
+ .desk-widget:focus-visible {
528
+ outline: 2px solid var(--desk-accent);
529
+ outline-offset: 2px;
530
+ }
531
+
532
+ /* A tour pointing at them moves nothing, and its ring fits in that margin too. */
533
+ .desk-widget-list[data-desk-tour-pointed] {
534
+ position: absolute;
535
+ }
536
+
537
+ .desk-widget[data-desk-tour-pointed] {
538
+ outline-offset: 2px;
539
+ }
540
+
541
+ .desk-widget-unseen {
542
+ position: absolute;
543
+ width: 1px;
544
+ height: 1px;
545
+ overflow: hidden;
546
+ clip-path: inset(50%);
547
+ white-space: nowrap;
548
+ }
549
+
550
+ /* A desk this small belongs to the windows. */
551
+ @container desk-widgets (max-width: 640px) or (max-height: 400px) {
552
+ .desk-widget-list,
553
+ .desk-widgets > .desk-widget-unseen {
554
+ display: none;
555
+ }
556
+ }
557
+
558
+ @media (forced-colors: active) {
559
+ button.desk-widget:hover { border-color: Highlight; }
560
+ }
561
+
415
562
  /* ── The inside of a window: controls that stay, content that scrolls ── */
416
563
 
417
564
  /* Two panels in one window, and the edge between them that moves. */