@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.
- package/README.md +58 -5
- package/dist/css/controls.css +21 -2
- package/dist/css/dock.css +1 -1
- package/dist/css/looks.css +50 -4
- package/dist/css/tokens.css +1 -0
- package/dist/css/windows.css +152 -5
- package/dist/desk.css +225 -12
- package/dist/react/Desktop.d.ts +12 -3
- package/dist/react/Desktop.d.ts.map +1 -1
- package/dist/react/Desktop.js +16 -7
- package/dist/react/Desktop.js.map +1 -1
- package/dist/react/MenuBar.d.ts +7 -0
- package/dist/react/MenuBar.d.ts.map +1 -1
- package/dist/react/MenuBar.js +15 -0
- package/dist/react/MenuBar.js.map +1 -1
- package/dist/react/arrange.d.ts +6 -0
- package/dist/react/arrange.d.ts.map +1 -1
- package/dist/react/arrange.js +21 -0
- package/dist/react/arrange.js.map +1 -1
- package/dist/react/index.d.ts +3 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +2 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/tabs.d.ts +7 -1
- package/dist/react/tabs.d.ts.map +1 -1
- package/dist/react/tabs.js +13 -8
- package/dist/react/tabs.js.map +1 -1
- package/dist/react/widgets.d.ts +33 -0
- package/dist/react/widgets.d.ts.map +1 -0
- package/dist/react/widgets.js +213 -0
- package/dist/react/widgets.js.map +1 -0
- package/llms.txt +30 -4
- package/package.json +1 -1
- package/src/css/controls.css +21 -2
- package/src/css/dock.css +1 -1
- package/src/css/looks.css +50 -4
- package/src/css/tokens.css +1 -0
- package/src/css/windows.css +152 -5
- package/src/react/Desktop.tsx +29 -9
- package/src/react/MenuBar.tsx +18 -0
- package/src/react/arrange.ts +23 -0
- package/src/react/index.ts +3 -1
- package/src/react/tabs.tsx +23 -10
- package/src/react/widgets.tsx +265 -0
package/llms.txt
CHANGED
|
@@ -268,7 +268,7 @@ useWindowInfo(info: ReactNode): boolean // this view's (i) in place
|
|
|
268
268
|
renderWindow={(id) => ReactNode} // memoised: chrome re-renders, content does not
|
|
269
269
|
title={(id) => ReactNode}
|
|
270
270
|
note?={(id) => ReactNode} // quiet text in the title bar: what this window is looking at
|
|
271
|
-
info?={(id) => ReactNode} // an (i)
|
|
271
|
+
info?={(id) => ReactNode} // an (i) on the bar's far edge from the controls (end on mac, start on gnome/windows): what this window IS
|
|
272
272
|
limits?={(id) => ({ maxWidth?, maxHeight?, minWidth?, minHeight? } | null)} // a window with a natural
|
|
273
273
|
// size is never stretched past it; filled, it centres
|
|
274
274
|
actions?={(id) => ReactNode} // window-wide controls in the title bar
|
|
@@ -276,10 +276,35 @@ useWindowInfo(info: ReactNode): boolean // this view's (i) in place
|
|
|
276
276
|
failed?={(id, error, reload) => ReactNode} // inside a window that could not open
|
|
277
277
|
empty?={ReactNode}
|
|
278
278
|
layout?={'auto' | 'desktop' | 'fullscreen'} // auto: touch screens get one window at a time
|
|
279
|
+
widgets?={Widget[]} // glances in a corner of the desk, behind the windows unless kept in front
|
|
280
|
+
widgetCorner?={'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'} // default top-right
|
|
279
281
|
className?={string}
|
|
280
282
|
/>
|
|
281
283
|
```
|
|
282
284
|
|
|
285
|
+
### Widgets
|
|
286
|
+
|
|
287
|
+
```ts
|
|
288
|
+
interface Widget { id: string; label: string; content: ReactNode; onSelect?: () => void; announce?: string }
|
|
289
|
+
widgetMenuItems(widgets): MenuItem[] // [] for none; else header "Widgets in front" + a checkable item each
|
|
290
|
+
isWidgetInFront(id): boolean
|
|
291
|
+
setWidgetInFront(id, front: boolean): void // remembered in localStorage under `desk.widgets.<id>`
|
|
292
|
+
useWidgetsInFront(): (id) => boolean // re-renders when a tick changes, here or in another tab
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
`<Desktop widgets>` stacks them in order, in one corner, clear of the dock and of each other, **behind the
|
|
296
|
+
windows**. Only the person brings one in front: put `...(widgets.length ? [menuSeparator(), ...widgetMenuItems(widgets)] : [])`
|
|
297
|
+
in the Window menu; a tick keeps that widget in front (a dock-glass frame round an opaque surface; those in front stand nearest the
|
|
298
|
+
corner, ahead of those behind, in DOM order too), and Arrange then lays the windows out
|
|
299
|
+
around its corner (a column or a strip, whichever leaves more room). Widgets behind take no room from Arrange.
|
|
300
|
+
A widget behind that a window covers is `inert`: out of Tab order and the accessibility tree. `onSelect` makes one
|
|
301
|
+
a button (so no controls in `content`) and should open the window it is about; without it, it only shows. `label`
|
|
302
|
+
is read before the content and not drawn (don't repeat it in the content), and names it in the menu. Content
|
|
303
|
+
changes are not announced; `announce` is said politely when it changes. The buttons within reach are one tab stop
|
|
304
|
+
(Up/Down, Home/End; Escape to the key window). Not shown in the fullscreen layout, or when the stage is at most
|
|
305
|
+
640px wide or 400px tall, so never the only place something is said. Width: `--desk-widget-width`. Too many for
|
|
306
|
+
the height scroll.
|
|
307
|
+
|
|
283
308
|
### Loading and failing, per window
|
|
284
309
|
|
|
285
310
|
```tsx
|
|
@@ -350,6 +375,7 @@ menuCommand(label, command, { shortcut?, checked?, detail?, args? })
|
|
|
350
375
|
menuAction(label, onSelect, { disabled?, shortcut?, checked?, detail? })
|
|
351
376
|
menuSeparator(); menuHeader(label)
|
|
352
377
|
windowMenuItems(state, focus, title): MenuItem[]
|
|
378
|
+
widgetMenuItems(widgets): MenuItem[] // "Widgets in front" + a checkable item per widget; [] for none (see Widgets)
|
|
353
379
|
|
|
354
380
|
const { target, menu, open } = useContextMenu({ label, items: () => MenuItem[], disabled? })
|
|
355
381
|
// spread `target` (onContextMenu, onKeyDown) on the element; render `menu` anywhere (portal).
|
|
@@ -449,7 +475,7 @@ SearchCommand = 'desk.search' // a menu item can open i
|
|
|
449
475
|
// on dark it is the surface lightened and tinted 14% with the accent;
|
|
450
476
|
// --desk-segment-thumb replaces its fill
|
|
451
477
|
// track is 32px tall (26 small), 4 more than a button
|
|
452
|
-
<Tabs tabs={{value,label,badge?,disabled
|
|
478
|
+
<Tabs tabs={{value,label,badge?,disabled?: true | "why"}[]} value onChange label actions?>{selected view}</Tabs>
|
|
453
479
|
// switches the view below; a segmented control chooses
|
|
454
480
|
<Toggle checked onChange label? description? disabled? aria-label? /> // applies at once
|
|
455
481
|
<Checkbox checked indeterminate? onChange label? description? disabled? /> // waits for Save
|
|
@@ -598,7 +624,7 @@ Every value reads a `--desk-*` token; redefine tokens, never override selectors.
|
|
|
598
624
|
`--desk-ok|warn|bad`, `--desk-on-accent`. Spacing `--desk-space-1..7` = 4, 8, 12, 16, 24, 32, 48 px. Also
|
|
599
625
|
`--desk-radius`, `--desk-control-height`, `--desk-control-radius`, `--desk-font`, `--desk-font-mono`,
|
|
600
626
|
`--desk-ease`, `--desk-dock-size`, `--desk-dock-glass`, `--desk-dock-offset`, `--desk-dock-room`,
|
|
601
|
-
`--desk-inset-bottom`, `--desk-wizard-height`, `--desk-field-gap`. Code colours (`CodeBlock`, on `--desk-page`):
|
|
627
|
+
`--desk-widget-width`, `--desk-inset-bottom`, `--desk-wizard-height`, `--desk-field-gap`. Code colours (`CodeBlock`, on `--desk-page`):
|
|
602
628
|
`--desk-code-comment|string|keyword|number|key`, 4.5:1 in light and dark.
|
|
603
629
|
|
|
604
630
|
Light and dark follow `prefers-color-scheme`; `data-theme="light" | "dark"` on the root wins. The look is
|
|
@@ -644,7 +670,7 @@ in the accessibility tree.
|
|
|
644
670
|
- A `DeskProvider` already carries an event bus; `BusProvider` is only for supplying or sharing one.
|
|
645
671
|
- `renderWindow` must be stable (module scope or `useCallback`) for the memoisation to hold.
|
|
646
672
|
- `parse`/`syncWithLocation` warn once when no `isKnown` is given: unknown ids from a URL are then trusted.
|
|
647
|
-
- `npm run size` enforces a gzipped budget: core 16 KiB, react
|
|
673
|
+
- `npm run size` enforces a gzipped budget: core 16 KiB, react 76 KiB, css 24 KiB, fx 5 KiB.
|
|
648
674
|
- `fx.play` never resumes audio itself: outside a press a browser's resume may never settle. Call
|
|
649
675
|
`fx.unlock()` at startup, or nothing sounds until a press after the sound was due.
|
|
650
676
|
- The package is ESM only, with `"sideEffects": ["**/*.css"]`.
|
package/package.json
CHANGED
package/src/css/controls.css
CHANGED
|
@@ -815,7 +815,7 @@
|
|
|
815
815
|
transition: background .12s var(--desk-ease), color .12s var(--desk-ease);
|
|
816
816
|
}
|
|
817
817
|
|
|
818
|
-
.desk-tab:hover:not(:disabled):not([aria-selected="true"]) {
|
|
818
|
+
.desk-tab:hover:not(:disabled):not([aria-disabled="true"]):not([aria-selected="true"]) {
|
|
819
819
|
background: color-mix(in srgb, var(--desk-ink) 6%, transparent);
|
|
820
820
|
color: var(--desk-ink);
|
|
821
821
|
}
|
|
@@ -831,11 +831,30 @@
|
|
|
831
831
|
outline-offset: -2px;
|
|
832
832
|
}
|
|
833
833
|
|
|
834
|
-
.desk-tab:disabled
|
|
834
|
+
.desk-tab:disabled,
|
|
835
|
+
.desk-tab[aria-disabled="true"] {
|
|
835
836
|
opacity: .45;
|
|
836
837
|
cursor: default;
|
|
837
838
|
}
|
|
838
839
|
|
|
840
|
+
/* An unavailable tab the arrows stop on: the ring is drawn in full, the label stays dimmed. */
|
|
841
|
+
.desk-tab[aria-disabled="true"]:focus-visible {
|
|
842
|
+
opacity: 1;
|
|
843
|
+
color: color-mix(in srgb, var(--desk-muted) 45%, transparent);
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
/* Why a tab is unavailable: read by a screen reader, shown to a pointer as the tab's title. */
|
|
847
|
+
.desk-tab-why {
|
|
848
|
+
position: absolute;
|
|
849
|
+
width: 1px;
|
|
850
|
+
height: 1px;
|
|
851
|
+
margin: -1px;
|
|
852
|
+
padding: 0;
|
|
853
|
+
overflow: hidden;
|
|
854
|
+
clip-path: inset(50%);
|
|
855
|
+
white-space: nowrap;
|
|
856
|
+
}
|
|
857
|
+
|
|
839
858
|
.desk-tab-badge {
|
|
840
859
|
min-width: 18px;
|
|
841
860
|
padding: 0 5px;
|
package/src/css/dock.css
CHANGED
|
@@ -220,7 +220,7 @@
|
|
|
220
220
|
height: 100%;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
/* A dot for "a window is open", brighter when it has focus. */
|
|
223
|
+
/* A dot for "a window is open", brighter when it has focus: a 4px dot 2px off its tile. */
|
|
224
224
|
.desk-dock-item[data-running]::after {
|
|
225
225
|
content: "";
|
|
226
226
|
position: absolute;
|
package/src/css/looks.css
CHANGED
|
@@ -49,11 +49,20 @@
|
|
|
49
49
|
font-size: var(--desk-text-small);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
/*
|
|
53
|
-
|
|
52
|
+
/*
|
|
53
|
+
* The end of the bar is the controls', so the (i) is at its start, on the far edge (it is first in the
|
|
54
|
+
* document). It takes the spare room after it, and nothing else in the bar reaches for any: an auto
|
|
55
|
+
* margin on both sides of it would centre it in the room, under the heading.
|
|
56
|
+
*/
|
|
57
|
+
[data-look="gnome"] .desk-titlebar > .desk-popover-anchor:has(> .desk-window-info) {
|
|
58
|
+
margin-left: 0;
|
|
54
59
|
margin-right: auto;
|
|
55
60
|
}
|
|
56
61
|
|
|
62
|
+
[data-look="gnome"] .desk-window-actions {
|
|
63
|
+
margin-left: 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
57
66
|
/*
|
|
58
67
|
* The middle is the heading's, so the count waits at the end of the bar, before the controls, and
|
|
59
68
|
* the heading keeps clear of both. A narrow bar keeps the count and lets the track go.
|
|
@@ -61,6 +70,7 @@
|
|
|
61
70
|
[data-look="gnome"] .desk-window-progress {
|
|
62
71
|
position: static;
|
|
63
72
|
transform: none;
|
|
73
|
+
margin-left: 0;
|
|
64
74
|
}
|
|
65
75
|
|
|
66
76
|
[data-look="gnome"] .desk-titlebar[data-progress] .desk-titlebar-heading {
|
|
@@ -138,6 +148,11 @@
|
|
|
138
148
|
height: 5px;
|
|
139
149
|
}
|
|
140
150
|
|
|
151
|
+
/* The (i) is first in the document, at the start of the bar: the end is the controls'. */
|
|
152
|
+
[data-look="windows"] .desk-titlebar > .desk-popover-anchor:has(> .desk-window-info) {
|
|
153
|
+
margin-left: 0;
|
|
154
|
+
}
|
|
155
|
+
|
|
141
156
|
[data-look="windows"] .desk-title {
|
|
142
157
|
flex: 1 1 auto;
|
|
143
158
|
font-size: var(--desk-text-small);
|
|
@@ -190,7 +205,8 @@
|
|
|
190
205
|
* inside them, come out dark too — as the shell's own menus do.
|
|
191
206
|
*/
|
|
192
207
|
[data-look="gnome"] .desk-menubar,
|
|
193
|
-
[data-look="gnome"] .desk-dock
|
|
208
|
+
[data-look="gnome"] .desk-dock,
|
|
209
|
+
[data-look="gnome"] .desk-widget[data-front] {
|
|
194
210
|
--desk-ink: #ffffff;
|
|
195
211
|
--desk-muted: rgb(255 255 255 / 68%);
|
|
196
212
|
--desk-surface: #2a2a2a;
|
|
@@ -225,8 +241,13 @@
|
|
|
225
241
|
color: var(--desk-ink);
|
|
226
242
|
}
|
|
227
243
|
|
|
228
|
-
|
|
244
|
+
/* A widget kept in front is the dash's material too. */
|
|
245
|
+
[data-look="gnome"] .desk-dock,
|
|
246
|
+
[data-look="gnome"] .desk-widget[data-front] {
|
|
229
247
|
--desk-dock-glass: rgb(24 24 24 / 86%);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
[data-look="gnome"] .desk-dock {
|
|
230
251
|
border-radius: 20px;
|
|
231
252
|
}
|
|
232
253
|
|
|
@@ -235,6 +256,31 @@
|
|
|
235
256
|
border-radius: 12px;
|
|
236
257
|
}
|
|
237
258
|
|
|
259
|
+
/*
|
|
260
|
+
* 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
|
|
261
|
+
* 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
|
|
262
|
+
* stands 4px off that, on whichever side the dock is.
|
|
263
|
+
*/
|
|
264
|
+
[data-look="gnome"] .desk-dock {
|
|
265
|
+
--desk-dock-dot-glyph: calc(27% - 8px);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
[data-look="gnome"] .desk-dock .desk-dock-item[data-stack] {
|
|
269
|
+
--desk-dock-dot-glyph: calc(14% - 8px);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
[data-look="gnome"] .desk-dock[data-side="bottom"] .desk-dock-item[data-running]::after {
|
|
273
|
+
bottom: var(--desk-dock-dot-glyph);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
[data-look="gnome"] .desk-dock[data-side="left"] .desk-dock-item[data-running]::after {
|
|
277
|
+
left: var(--desk-dock-dot-glyph);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
[data-look="gnome"] .desk-dock[data-side="right"] .desk-dock-item[data-running]::after {
|
|
281
|
+
right: var(--desk-dock-dot-glyph);
|
|
282
|
+
}
|
|
283
|
+
|
|
238
284
|
/* No magnification: GNOME's dash lights an item up rather than growing it. */
|
|
239
285
|
[data-look="gnome"] .desk-dock .desk-dock-item:hover:not(:disabled),
|
|
240
286
|
[data-look="windows"] .desk-dock .desk-dock-item:hover:not(:disabled) {
|
package/src/css/tokens.css
CHANGED
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
--desk-dock-icon: linear-gradient(160deg, #ffffff, #eceff5);
|
|
85
85
|
--desk-badge: #ef4444;
|
|
86
86
|
--desk-badge-ink: #ffffff;
|
|
87
|
+
--desk-widget-width: 200px;
|
|
87
88
|
/* Room the stage leaves at the bottom for something of the app's own. An overlay dock makes its own. */
|
|
88
89
|
--desk-inset-bottom: 0px;
|
|
89
90
|
}
|
package/src/css/windows.css
CHANGED
|
@@ -185,16 +185,18 @@
|
|
|
185
185
|
color: var(--desk-muted);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
/* The note gives up the spare room; the (i) keeps its place at the end of the bar. */
|
|
189
188
|
/*
|
|
190
|
-
* The (i) is the bar's
|
|
191
|
-
*
|
|
189
|
+
* The (i) is on the bar's far edge, opposite the controls: here, on a Mac, it is the bar's last word, after
|
|
190
|
+
* the note and the actions. Whatever comes before it takes the spare room, and it follows. It sits in its
|
|
191
|
+
* popover's anchor, so the anchor is what the bar lays out: a margin on the button inside it would move
|
|
192
|
+
* nothing. The other looks put it first, and say so in looks.css.
|
|
192
193
|
*/
|
|
193
194
|
.desk-titlebar > .desk-popover-anchor:has(> .desk-window-info) {
|
|
194
195
|
margin-left: auto;
|
|
195
196
|
}
|
|
196
197
|
|
|
197
|
-
.desk-window-note ~ .desk-popover-anchor:has(> .desk-window-info)
|
|
198
|
+
.desk-window-note ~ .desk-popover-anchor:has(> .desk-window-info),
|
|
199
|
+
.desk-window-actions ~ .desk-popover-anchor:has(> .desk-window-info) {
|
|
198
200
|
margin-left: var(--desk-space-2);
|
|
199
201
|
}
|
|
200
202
|
|
|
@@ -243,6 +245,12 @@
|
|
|
243
245
|
margin-left: var(--desk-space-3);
|
|
244
246
|
}
|
|
245
247
|
|
|
248
|
+
/* The count has taken the spare room, so what follows it keeps to it rather than splitting the room. */
|
|
249
|
+
.desk-window-progress ~ .desk-window-actions,
|
|
250
|
+
.desk-window-progress ~ .desk-popover-anchor:has(> .desk-window-info) {
|
|
251
|
+
margin-left: var(--desk-space-2);
|
|
252
|
+
}
|
|
253
|
+
|
|
246
254
|
.desk-titlebar[data-progress] .desk-title,
|
|
247
255
|
.desk-titlebar[data-progress] .desk-window-note {
|
|
248
256
|
max-width: none;
|
|
@@ -270,7 +278,13 @@
|
|
|
270
278
|
.desk-window-progress-fill { transition: none; }
|
|
271
279
|
}
|
|
272
280
|
|
|
273
|
-
|
|
281
|
+
/* Narrower still, the count keeps its words and lets the track go, so the bar's far edge stays on the bar. */
|
|
282
|
+
@container (max-width: 400px) {
|
|
283
|
+
.desk-window-progress-track {
|
|
284
|
+
display: none;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
274
288
|
.desk-window-note + .desk-window-actions {
|
|
275
289
|
margin-left: var(--desk-space-1);
|
|
276
290
|
}
|
|
@@ -411,6 +425,139 @@
|
|
|
411
425
|
right: var(--desk-padding);
|
|
412
426
|
}
|
|
413
427
|
|
|
428
|
+
/* ── Widgets: glances in a corner of the stage, behind the windows unless the person keeps one in front ── */
|
|
429
|
+
|
|
430
|
+
/* As big as the stage, to ask its size. No z-index, so each widget stands behind or in front on its own. */
|
|
431
|
+
.desk-widgets {
|
|
432
|
+
container: desk-widgets / size;
|
|
433
|
+
position: absolute;
|
|
434
|
+
inset: 0;
|
|
435
|
+
pointer-events: none;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/*
|
|
439
|
+
* A margin of padding for the focus ring, which a list that scrolls would clip. Too many for the desk, and it
|
|
440
|
+
* scrolls: it takes the pointer, as a scroller without it is passed over by the wheel, a finger and its scrollbar.
|
|
441
|
+
*/
|
|
442
|
+
.desk-widget-list {
|
|
443
|
+
position: absolute;
|
|
444
|
+
pointer-events: auto;
|
|
445
|
+
box-sizing: border-box;
|
|
446
|
+
width: calc(var(--desk-widget-width) + 2 * var(--desk-space-1));
|
|
447
|
+
max-height: calc(100% - 2 * (var(--desk-padding) - var(--desk-space-1)) - var(--desk-inset-bottom));
|
|
448
|
+
padding: var(--desk-space-1);
|
|
449
|
+
display: flex;
|
|
450
|
+
flex-direction: column;
|
|
451
|
+
gap: var(--desk-space-2);
|
|
452
|
+
overflow: hidden auto;
|
|
453
|
+
scrollbar-width: thin;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
.desk-widgets[data-corner^="top"] > .desk-widget-list {
|
|
457
|
+
top: calc(var(--desk-padding) - var(--desk-space-1));
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
.desk-widgets[data-corner^="bottom"] > .desk-widget-list {
|
|
461
|
+
bottom: calc(var(--desk-padding) - var(--desk-space-1) + var(--desk-inset-bottom));
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
.desk-widgets[data-corner$="left"] > .desk-widget-list {
|
|
465
|
+
left: calc(var(--desk-padding) - var(--desk-space-1));
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
.desk-widgets[data-corner$="right"] > .desk-widget-list {
|
|
469
|
+
right: calc(var(--desk-padding) - var(--desk-space-1));
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/* Behind: on the desk surface, over what the app draws on an empty desk; windows start at 10. */
|
|
473
|
+
.desk-widget {
|
|
474
|
+
flex: none;
|
|
475
|
+
box-sizing: border-box;
|
|
476
|
+
position: relative;
|
|
477
|
+
z-index: 1;
|
|
478
|
+
min-height: 44px;
|
|
479
|
+
padding: 0;
|
|
480
|
+
border: 1px solid var(--desk-rule);
|
|
481
|
+
border-radius: var(--desk-radius);
|
|
482
|
+
background: var(--desk-surface);
|
|
483
|
+
color: var(--desk-ink);
|
|
484
|
+
font-family: var(--desk-font);
|
|
485
|
+
font-size: var(--desk-text-body);
|
|
486
|
+
text-align: start;
|
|
487
|
+
overflow: clip;
|
|
488
|
+
overflow-wrap: anywhere;
|
|
489
|
+
user-select: none;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/* Its words, on an opaque surface. */
|
|
493
|
+
.desk-widget-surface {
|
|
494
|
+
display: block;
|
|
495
|
+
box-sizing: border-box;
|
|
496
|
+
min-height: 42px;
|
|
497
|
+
padding: var(--desk-space-2) var(--desk-space-3);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/* 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. */
|
|
501
|
+
.desk-widget[data-front] {
|
|
502
|
+
z-index: 800;
|
|
503
|
+
padding: var(--desk-space-1);
|
|
504
|
+
background: var(--desk-dock-glass);
|
|
505
|
+
backdrop-filter: blur(28px) saturate(170%);
|
|
506
|
+
-webkit-backdrop-filter: blur(28px) saturate(170%);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
.desk-widget[data-front] > .desk-widget-surface {
|
|
510
|
+
/* The frame comes out of the padding: ticking one keeps its size. */
|
|
511
|
+
min-height: calc(42px - 2 * var(--desk-space-1));
|
|
512
|
+
padding: calc(var(--desk-space-2) - var(--desk-space-1)) calc(var(--desk-space-3) - var(--desk-space-1));
|
|
513
|
+
border-radius: max(0px, calc(var(--desk-radius) - var(--desk-space-1)));
|
|
514
|
+
background: var(--desk-surface);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
button.desk-widget {
|
|
518
|
+
cursor: pointer;
|
|
519
|
+
transition: border-color .12s var(--desk-ease);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
button.desk-widget:hover {
|
|
523
|
+
border-color: color-mix(in srgb, var(--desk-accent) 45%, var(--desk-rule));
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
.desk-widget:focus-visible {
|
|
527
|
+
outline: 2px solid var(--desk-accent);
|
|
528
|
+
outline-offset: 2px;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/* A tour pointing at them moves nothing, and its ring fits in that margin too. */
|
|
532
|
+
.desk-widget-list[data-desk-tour-pointed] {
|
|
533
|
+
position: absolute;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
.desk-widget[data-desk-tour-pointed] {
|
|
537
|
+
outline-offset: 2px;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
.desk-widget-unseen {
|
|
541
|
+
position: absolute;
|
|
542
|
+
width: 1px;
|
|
543
|
+
height: 1px;
|
|
544
|
+
overflow: hidden;
|
|
545
|
+
clip-path: inset(50%);
|
|
546
|
+
white-space: nowrap;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/* A desk this small belongs to the windows. */
|
|
550
|
+
@container desk-widgets (max-width: 640px) or (max-height: 400px) {
|
|
551
|
+
.desk-widget-list,
|
|
552
|
+
.desk-widgets > .desk-widget-unseen {
|
|
553
|
+
display: none;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
@media (forced-colors: active) {
|
|
558
|
+
button.desk-widget:hover { border-color: Highlight; }
|
|
559
|
+
}
|
|
560
|
+
|
|
414
561
|
/* ── The inside of a window: controls that stay, content that scrolls ── */
|
|
415
562
|
|
|
416
563
|
/* Two panels in one window, and the edge between them that moves. */
|
package/src/react/Desktop.tsx
CHANGED
|
@@ -5,7 +5,9 @@ import { focusedId, isMinimized, onDesk } from '../core/desk.js'
|
|
|
5
5
|
import type { Desk } from '../core/desk.js'
|
|
6
6
|
import type { Look } from '../core/look.js'
|
|
7
7
|
import type { DeskWindow, Frame, WindowId, WindowLimits } from '../core/types.js'
|
|
8
|
-
import {
|
|
8
|
+
import { Widgets, widgetsKeptClear } from './widgets.js'
|
|
9
|
+
import type { Widget, WidgetCorner } from './widgets.js'
|
|
10
|
+
import { arrangement, areaAround } from './arrange.js'
|
|
9
11
|
import { InfoTip } from './infoTip.js'
|
|
10
12
|
import { useDesk, useDeskState, useLook, WindowContext } from './context.js'
|
|
11
13
|
import { WindowBoundary } from './windowBoundary.js'
|
|
@@ -32,8 +34,8 @@ export interface DesktopProps {
|
|
|
32
34
|
*/
|
|
33
35
|
readonly limits?: (id: WindowId) => WindowLimits | null
|
|
34
36
|
/**
|
|
35
|
-
* What this window is, behind an (i)
|
|
36
|
-
* so a person who wonders what they are looking at always knows where to ask. Explanation only: a
|
|
37
|
+
* What this window is, behind an (i) on the far edge of its title bar, opposite the controls — the
|
|
38
|
+
* same place in every window, so a person who wonders what they are looking at always knows where to ask. Explanation only: a
|
|
37
39
|
* warning, or anything that changes what someone is about to do, belongs in the window itself.
|
|
38
40
|
*/
|
|
39
41
|
readonly info?: (id: WindowId) => ReactNode
|
|
@@ -50,9 +52,19 @@ export interface DesktopProps {
|
|
|
50
52
|
* window at a time; anything with a pointer gets the layered `desktop`.
|
|
51
53
|
*/
|
|
52
54
|
readonly layout?: DeskLayout | 'auto'
|
|
55
|
+
/**
|
|
56
|
+
* Glances stacked in a corner of the desk, clear of the dock: behind the windows, unless the person keeps
|
|
57
|
+
* one in front from the Window menu (`widgetMenuItems`). Not shown in the fullscreen layout, or on a desk
|
|
58
|
+
* too small to spare the room.
|
|
59
|
+
*/
|
|
60
|
+
readonly widgets?: readonly Widget[]
|
|
61
|
+
/** The corner they stand in: `top-right` unless said. Keep it clear in the app's default layout. */
|
|
62
|
+
readonly widgetCorner?: WidgetCorner
|
|
53
63
|
readonly className?: string
|
|
54
64
|
}
|
|
55
65
|
|
|
66
|
+
const NO_WIDGETS: readonly Widget[] = []
|
|
67
|
+
|
|
56
68
|
/** Touch-first: a coarse pointer that cannot hover. A tablet with a trackpad reports otherwise. */
|
|
57
69
|
const TOUCH = '(pointer: coarse) and (hover: none)'
|
|
58
70
|
|
|
@@ -94,7 +106,7 @@ const halfFrame = (stage: HTMLElement, side: 'start' | 'end'): Frame => {
|
|
|
94
106
|
return { x: side === 'start' ? area.x : area.x + width + area.gap, y: area.y, width, height: area.height }
|
|
95
107
|
}
|
|
96
108
|
|
|
97
|
-
export function Desktop({ renderWindow, title, note, info, actions, limits, empty, loading, failed, layout = 'auto', className }: DesktopProps) {
|
|
109
|
+
export function Desktop({ renderWindow, title, note, info, actions, limits, empty, loading, failed, layout = 'auto', widgets = NO_WIDGETS, widgetCorner = 'top-right', className }: DesktopProps) {
|
|
98
110
|
const desk = useDesk()
|
|
99
111
|
const state = useDeskState()
|
|
100
112
|
const stage = useRef<HTMLDivElement>(null)
|
|
@@ -189,6 +201,8 @@ export function Desktop({ renderWindow, title, note, info, actions, limits, empt
|
|
|
189
201
|
data-layout={mode}
|
|
190
202
|
{...{ [STAGE_ATTRIBUTE]: '' }}
|
|
191
203
|
>
|
|
204
|
+
{/* Still there with none to draw, so one taken away while it had the keyboard can hand it on. */}
|
|
205
|
+
<Widgets widgets={mode === 'desktop' ? widgets : NO_WIDGETS} corner={widgetCorner} />
|
|
192
206
|
{onDesk(state).length === 0 && empty}
|
|
193
207
|
{state.windows.map(window => (
|
|
194
208
|
<WindowView
|
|
@@ -328,7 +342,10 @@ function arrangeNow(desk: Desk, element: HTMLElement) {
|
|
|
328
342
|
const windows = onDesk(state)
|
|
329
343
|
const stack = state.stack.filter(id => !isMinimized(state, id))
|
|
330
344
|
const [focused, previous] = [stack.at(-1), stack.at(-2)]
|
|
331
|
-
|
|
345
|
+
// Widgets kept in front have their corner; the windows are laid out in the rest.
|
|
346
|
+
const area = arrangementArea(element)
|
|
347
|
+
const clear = widgetsKeptClear(element, area.gap)
|
|
348
|
+
if (windows.length === 1 && !clear) {
|
|
332
349
|
if (focused) desk.fill(focused)
|
|
333
350
|
return
|
|
334
351
|
}
|
|
@@ -336,7 +353,7 @@ function arrangeNow(desk: Desk, element: HTMLElement) {
|
|
|
336
353
|
windows.map(w => w.id),
|
|
337
354
|
focused ?? null,
|
|
338
355
|
previous ?? null,
|
|
339
|
-
|
|
356
|
+
clear ? areaAround(area, clear) : area,
|
|
340
357
|
{ minWidth: MIN_WIDTH, minHeight: MIN_HEIGHT },
|
|
341
358
|
)
|
|
342
359
|
desk.placeAll(frames)
|
|
@@ -490,7 +507,11 @@ function WindowView({ window, layout, hidden, minimized, depth, focused, title,
|
|
|
490
507
|
)
|
|
491
508
|
const windowNote = note != null && note !== false && <p className="desk-window-note">{note}</p>
|
|
492
509
|
|
|
493
|
-
|
|
510
|
+
/*
|
|
511
|
+
* The (i) is on the bar's far edge, opposite the controls: last on a Mac bar, whose start is the
|
|
512
|
+
* controls', and first on the others, whose end is. It is put there in the document, not moved there
|
|
513
|
+
* by CSS, so Tab reaches it where it is seen, and it is in the same corner of every window of a look.
|
|
514
|
+
*/
|
|
494
515
|
const windowInfo = info != null && info !== false && (
|
|
495
516
|
<InfoTip
|
|
496
517
|
className="desk-window-info"
|
|
@@ -547,9 +568,8 @@ function WindowView({ window, layout, hidden, minimized, depth, focused, title,
|
|
|
547
568
|
{windowNote}
|
|
548
569
|
</>
|
|
549
570
|
)}
|
|
550
|
-
{look === 'mac' && windowInfo}
|
|
551
571
|
{actions && <div className="desk-window-actions">{actions}</div>}
|
|
552
|
-
{look
|
|
572
|
+
{look === 'mac' ? windowInfo : controls}
|
|
553
573
|
</header>
|
|
554
574
|
<div className="desk-body">{children}</div>
|
|
555
575
|
{layout === 'desktop' && (
|
package/src/react/MenuBar.tsx
CHANGED
|
@@ -9,6 +9,8 @@ import type { Desk } from '../core/desk.js'
|
|
|
9
9
|
import type { DeskState, WindowId } from '../core/types.js'
|
|
10
10
|
import { useDesk, useDeskState } from './context.js'
|
|
11
11
|
import { hasModKey, hostMenuModel, sameHostModel } from './hostMenu.js'
|
|
12
|
+
import { isWidgetInFront, setWidgetInFront, useWidgetsInFront } from './widgets.js'
|
|
13
|
+
import type { Widget } from './widgets.js'
|
|
12
14
|
import type { HostMenu, MenuHost } from './hostMenu.js'
|
|
13
15
|
|
|
14
16
|
/*
|
|
@@ -77,6 +79,21 @@ export function windowMenuItems(state: DeskState, focus: (id: WindowId) => void,
|
|
|
77
79
|
)
|
|
78
80
|
}
|
|
79
81
|
|
|
82
|
+
/**
|
|
83
|
+
* "Widgets in front", and an item for each widget, ticked while it is kept in front of the windows: the
|
|
84
|
+
* section a Window menu carries, after a separator. Nothing at all when the app has no widgets, so the
|
|
85
|
+
* section is not there either. Choosing one brings it in front or sends it back, and that is remembered.
|
|
86
|
+
*/
|
|
87
|
+
export function widgetMenuItems(widgets: readonly Widget[]): MenuItem[] {
|
|
88
|
+
if (!widgets.length) return []
|
|
89
|
+
return [
|
|
90
|
+
menuHeader('Widgets in front'),
|
|
91
|
+
...widgets.map(({ id, label }) =>
|
|
92
|
+
menuAction(label, () => setWidgetInFront(id, !isWidgetInFront(id)), { checked: () => isWidgetInFront(id) }),
|
|
93
|
+
),
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
|
|
80
97
|
export interface MenuBarProps {
|
|
81
98
|
/** Menus on the leading side, in order. The first is conventionally the app's own. */
|
|
82
99
|
readonly menus: readonly Menu[]
|
|
@@ -182,6 +199,7 @@ export function MenuBar(props: MenuBarProps) {
|
|
|
182
199
|
function HostedMenuBar({ menus, status = [], host, shortcuts = true }: MenuBarProps & { readonly host: MenuHost }) {
|
|
183
200
|
const desk = useDesk()
|
|
184
201
|
useDeskState() // a menu that lists the open windows changes when they do
|
|
202
|
+
useWidgetsInFront() // and one that ticks the widgets in front, when one is ticked
|
|
185
203
|
const apple = useMemo(isApplePlatform, [])
|
|
186
204
|
const model = hostMenuModel(menus, status, command => canPerform(desk, command))
|
|
187
205
|
|
package/src/react/arrange.ts
CHANGED
|
@@ -80,3 +80,26 @@ export function arrangement(
|
|
|
80
80
|
),
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The area without a rectangle in one of its corners, such as the one widgets kept in front stand in, so
|
|
86
|
+
* windows laid out in it tile around them. Windows are rectangles, so the corner takes a whole column or a
|
|
87
|
+
* whole row with it: whichever leaves more room. A rectangle that misses the area leaves it as it is.
|
|
88
|
+
*/
|
|
89
|
+
export function areaAround(area: Area, clear: Frame): Area {
|
|
90
|
+
const right = area.x + area.width
|
|
91
|
+
const bottom = area.y + area.height
|
|
92
|
+
const left = Math.max(area.x, clear.x)
|
|
93
|
+
const top = Math.max(area.y, clear.y)
|
|
94
|
+
const end = Math.min(right, clear.x + clear.width)
|
|
95
|
+
const foot = Math.min(bottom, clear.y + clear.height)
|
|
96
|
+
if (end <= left || foot <= top) return area
|
|
97
|
+
// A rectangle in a corner touches two sides; the room left beside it, and above or below it.
|
|
98
|
+
const column =
|
|
99
|
+
left > area.x ? { ...area, width: left - area.x }
|
|
100
|
+
: { ...area, x: end, width: right - end }
|
|
101
|
+
const row =
|
|
102
|
+
top > area.y ? { ...area, height: top - area.y }
|
|
103
|
+
: { ...area, y: foot, height: bottom - foot }
|
|
104
|
+
return column.width * column.height >= row.width * row.height ? column : row
|
|
105
|
+
}
|
package/src/react/index.ts
CHANGED
|
@@ -17,6 +17,8 @@ export { DeskProvider, useDesk, useDeskState, useLook, useWindowId, useWindowRou
|
|
|
17
17
|
export type { DeskProviderProps } from './context.js'
|
|
18
18
|
export { useCanPerform, useCommand, usePerform, useShortcuts } from './commands.js'
|
|
19
19
|
export type { UseCommandOptions } from './commands.js'
|
|
20
|
+
export { isWidgetInFront, setWidgetInFront, useWidgetsInFront } from './widgets.js'
|
|
21
|
+
export type { Widget, WidgetCorner } from './widgets.js'
|
|
20
22
|
export { Desktop } from './Desktop.js'
|
|
21
23
|
export type { DeskLayout, DesktopProps } from './Desktop.js'
|
|
22
24
|
export { useService, useServiceValue } from './services.js'
|
|
@@ -87,7 +89,7 @@ export { Composer, Thread } from './conversation.js'
|
|
|
87
89
|
export type { ComposerProps, Message, ThreadProps } from './conversation.js'
|
|
88
90
|
export { Alert, Popover, Sheet, ToastProvider, useToast } from './overlays.js'
|
|
89
91
|
export type { AlertProps, PopoverProps, PopoverTriggerProps, SheetProps, Toast, ToastInput } from './overlays.js'
|
|
90
|
-
export { MenuBar, menuAction, menuCommand, menuHeader, menuSeparator, windowMenuItems } from './MenuBar.js'
|
|
92
|
+
export { MenuBar, menuAction, menuCommand, menuHeader, menuSeparator, widgetMenuItems, windowMenuItems } from './MenuBar.js'
|
|
91
93
|
export { useContextMenu } from './contextMenu.js'
|
|
92
94
|
export type { ContextMenuOptions, ContextMenuResult, ContextMenuTargetProps } from './contextMenu.js'
|
|
93
95
|
export type { Menu, MenuBarProps, MenuItem } from './MenuBar.js'
|