@liberation-data/desk 0.12.0 → 0.15.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 +70 -7
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/look.d.ts +12 -0
- package/dist/core/look.d.ts.map +1 -0
- package/dist/core/look.js +26 -0
- package/dist/core/look.js.map +1 -0
- package/dist/css/controls.css +37 -0
- package/dist/css/dock.css +123 -3
- package/dist/css/looks.css +258 -0
- package/dist/css/tokens.css +8 -1
- package/dist/desk.css +427 -4
- package/dist/fx/fx.d.ts +29 -0
- package/dist/fx/fx.d.ts.map +1 -0
- package/dist/fx/fx.js +119 -0
- package/dist/fx/fx.js.map +1 -0
- package/dist/fx/index.d.ts +7 -0
- package/dist/fx/index.d.ts.map +1 -0
- package/dist/fx/index.js +4 -0
- package/dist/fx/index.js.map +1 -0
- package/dist/fx/measure.d.ts +18 -0
- package/dist/fx/measure.d.ts.map +1 -0
- package/dist/fx/measure.js +37 -0
- package/dist/fx/measure.js.map +1 -0
- package/dist/fx/sounds.d.ts +108 -0
- package/dist/fx/sounds.d.ts.map +1 -0
- package/dist/fx/sounds.js +148 -0
- package/dist/fx/sounds.js.map +1 -0
- package/dist/react/Desktop.d.ts.map +1 -1
- package/dist/react/Desktop.js +44 -9
- package/dist/react/Desktop.js.map +1 -1
- package/dist/react/Dock.d.ts +11 -1
- package/dist/react/Dock.d.ts.map +1 -1
- package/dist/react/Dock.js +4 -3
- package/dist/react/Dock.js.map +1 -1
- package/dist/react/context.d.ts +9 -1
- package/dist/react/context.d.ts.map +1 -1
- package/dist/react/context.js +15 -3
- package/dist/react/context.js.map +1 -1
- package/dist/react/controls.d.ts +11 -1
- package/dist/react/controls.d.ts.map +1 -1
- package/dist/react/controls.js +2 -2
- package/dist/react/controls.js.map +1 -1
- package/dist/react/index.d.ts +4 -2
- 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/shell.d.ts +4 -1
- package/dist/react/shell.d.ts.map +1 -1
- package/dist/react/shell.js +2 -2
- package/dist/react/shell.js.map +1 -1
- package/dist/react/soundsToggle.d.ts +14 -0
- package/dist/react/soundsToggle.d.ts.map +1 -0
- package/dist/react/soundsToggle.js +12 -0
- package/dist/react/soundsToggle.js.map +1 -0
- package/llms.txt +45 -14
- package/package.json +7 -2
- package/src/core/index.ts +2 -0
- package/src/core/look.ts +43 -0
- package/src/css/controls.css +37 -0
- package/src/css/dock.css +123 -3
- package/src/css/looks.css +257 -0
- package/src/css/tokens.css +8 -1
- package/src/fx/fx.ts +145 -0
- package/src/fx/index.ts +6 -0
- package/src/fx/measure.ts +70 -0
- package/src/fx/sounds.ts +213 -0
- package/src/react/Desktop.tsx +97 -29
- package/src/react/Dock.tsx +16 -3
- package/src/react/context.tsx +25 -3
- package/src/react/controls.tsx +12 -2
- package/src/react/index.ts +4 -2
- package/src/react/shell.tsx +5 -2
- package/src/react/soundsToggle.tsx +19 -0
package/src/core/look.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The platform chrome the desk wears: where a window's controls sit and what they look like, how the
|
|
3
|
+
* title bar, dock and menu bar are drawn. Separate from `data-theme`, which is light or dark — the two
|
|
4
|
+
* combine freely.
|
|
5
|
+
*
|
|
6
|
+
* A look is chrome, not brand: it never sets the accent or the ground, which are the app's.
|
|
7
|
+
*
|
|
8
|
+
* It is not the keyboard either. Somebody on a Mac who prefers the GNOME look still presses ⌘, so
|
|
9
|
+
* shortcuts read the device through `isApplePlatform`, never through the look.
|
|
10
|
+
*/
|
|
11
|
+
export type Look = 'mac' | 'gnome' | 'windows'
|
|
12
|
+
|
|
13
|
+
/** What an app asks for: a look, or `auto` for the one that matches the device. */
|
|
14
|
+
export type LookChoice = Look | 'auto'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The look for a device, from its platform string and user agent. A device it does not recognise
|
|
18
|
+
* gets `mac`, which is how desk looked before it had looks.
|
|
19
|
+
*/
|
|
20
|
+
export function lookFor(platform: string, userAgent: string): Look {
|
|
21
|
+
// Android reports a Linux platform, and is not a Linux desktop.
|
|
22
|
+
if (/android/i.test(userAgent)) return 'mac'
|
|
23
|
+
const device = `${platform} ${userAgent}`
|
|
24
|
+
if (/mac|iphone|ipad|ipod|ios/i.test(device)) return 'mac'
|
|
25
|
+
if (/win/i.test(device)) return 'windows'
|
|
26
|
+
if (/linux|cros|chrome os|x11|bsd/i.test(device)) return 'gnome'
|
|
27
|
+
return 'mac'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface NavigatorWithHints {
|
|
31
|
+
readonly platform?: string
|
|
32
|
+
readonly userAgent?: string
|
|
33
|
+
readonly userAgentData?: { readonly platform?: string }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The look for the device this is running on; `mac` where there is no navigator to ask. */
|
|
37
|
+
export function deviceLook(): Look {
|
|
38
|
+
if (typeof navigator === 'undefined') return 'mac'
|
|
39
|
+
const hints = navigator as NavigatorWithHints
|
|
40
|
+
return lookFor(hints.userAgentData?.platform || hints.platform || '', hints.userAgent ?? '')
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const resolveLook = (choice: LookChoice): Look => (choice === 'auto' ? deviceLook() : choice)
|
package/src/css/controls.css
CHANGED
|
@@ -136,6 +136,22 @@
|
|
|
136
136
|
cursor: pointer;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
/*
|
|
140
|
+
* Spanning the row, with every option the same width. The default sizes each option to its label,
|
|
141
|
+
* which is right in a toolbar and wrong when the control is the heading of the thing below it:
|
|
142
|
+
* equal answers should not be different sizes because one of them is a longer word.
|
|
143
|
+
*/
|
|
144
|
+
.desk-segmented[data-width="fill"] {
|
|
145
|
+
display: flex;
|
|
146
|
+
width: 100%;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.desk-segmented[data-width="fill"] .desk-segment {
|
|
150
|
+
flex: 1 1 0;
|
|
151
|
+
min-width: 0;
|
|
152
|
+
justify-content: center;
|
|
153
|
+
}
|
|
154
|
+
|
|
139
155
|
.desk-segmented[data-size="small"] .desk-segment {
|
|
140
156
|
min-height: calc(var(--desk-control-height-small) - 4px);
|
|
141
157
|
padding: 0 var(--desk-space-2);
|
|
@@ -203,12 +219,33 @@
|
|
|
203
219
|
gap: 2px;
|
|
204
220
|
}
|
|
205
221
|
|
|
222
|
+
/*
|
|
223
|
+
* A LABEL AND ITS INPUT ARE ONE THING, and the space around them has to say so. The gap INSIDE a
|
|
224
|
+
* field is 4px; the gap BETWEEN fields has to be clearly larger, or the eye groups a label with
|
|
225
|
+
* the field above it instead of the one below — which is what a label sitting closer to its
|
|
226
|
+
* neighbour than to its own input actually does.
|
|
227
|
+
*
|
|
228
|
+
* `.desk-field` only ever set the inside gap, and said nothing about the outside. Every consumer
|
|
229
|
+
* picked its own: one app's forms came out at 14px, another's at 10px, and anything that forgot
|
|
230
|
+
* got the browser's default of none. Same components, different grouping, and no rule to point at.
|
|
231
|
+
*/
|
|
206
232
|
.desk-field {
|
|
207
233
|
display: flex;
|
|
208
234
|
flex-direction: column;
|
|
209
235
|
gap: var(--desk-space-1);
|
|
210
236
|
}
|
|
211
237
|
|
|
238
|
+
/*
|
|
239
|
+
* The container a stack of fields goes in. Four times the inside gap, which is enough that the
|
|
240
|
+
* pairing is read rather than worked out, and an app that wants tighter or looser sets the token
|
|
241
|
+
* rather than the rule.
|
|
242
|
+
*/
|
|
243
|
+
.desk-fields {
|
|
244
|
+
display: flex;
|
|
245
|
+
flex-direction: column;
|
|
246
|
+
gap: var(--desk-field-gap, var(--desk-space-4));
|
|
247
|
+
}
|
|
248
|
+
|
|
212
249
|
.desk-label {
|
|
213
250
|
font-size: 12px;
|
|
214
251
|
font-weight: 500;
|
package/src/css/dock.css
CHANGED
|
@@ -19,12 +19,56 @@
|
|
|
19
19
|
|
|
20
20
|
.desk-dock[data-placement="overlay"] {
|
|
21
21
|
position: absolute;
|
|
22
|
-
left: 50%;
|
|
23
|
-
bottom: 12px;
|
|
24
22
|
z-index: 1000;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.desk-dock[data-placement="overlay"][data-side="bottom"] {
|
|
26
|
+
left: 50%;
|
|
27
|
+
bottom: var(--desk-dock-offset);
|
|
25
28
|
transform: translateX(-50%);
|
|
26
29
|
}
|
|
27
30
|
|
|
31
|
+
.desk-dock[data-placement="overlay"]:not([data-side="bottom"]) {
|
|
32
|
+
top: 50%;
|
|
33
|
+
transform: translateY(-50%);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.desk-dock[data-placement="overlay"][data-side="left"] {
|
|
37
|
+
left: var(--desk-dock-offset);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.desk-dock[data-placement="overlay"][data-side="right"] {
|
|
41
|
+
right: var(--desk-dock-offset);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* Standing in a column: items top to bottom, and never taller than the room it stands in. */
|
|
45
|
+
.desk-dock:not([data-side="bottom"]) {
|
|
46
|
+
flex-direction: column;
|
|
47
|
+
align-items: center;
|
|
48
|
+
max-width: none;
|
|
49
|
+
max-height: calc(100% - 2 * var(--desk-dock-offset));
|
|
50
|
+
/* The same thickness standing up as lying down, so --desk-dock-room holds on every side. */
|
|
51
|
+
padding: 9px 7px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/*
|
|
55
|
+
* An overlay dock makes its own room. The stage beside it starts where the dock ends — a margin, not
|
|
56
|
+
* padding, because windows are placed from the stage's own corner: padding would keep filled windows
|
|
57
|
+
* clear and still open every free one underneath the dock.
|
|
58
|
+
*/
|
|
59
|
+
:has(> .desk-dock[data-placement="overlay"][data-side="left"]) > .desk-stage {
|
|
60
|
+
margin-left: var(--desk-dock-room);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
:has(> .desk-dock[data-placement="overlay"][data-side="right"]) > .desk-stage {
|
|
64
|
+
margin-right: var(--desk-dock-room);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
:has(> .desk-dock[data-placement="overlay"][data-side="bottom"]) > .desk-stage {
|
|
68
|
+
/* The stage is `height: 100%`, so a margin would push it past its parent rather than shorten it. */
|
|
69
|
+
height: calc(100% - var(--desk-dock-room));
|
|
70
|
+
}
|
|
71
|
+
|
|
28
72
|
.desk-dock-separator {
|
|
29
73
|
flex: none;
|
|
30
74
|
align-self: stretch;
|
|
@@ -33,6 +77,12 @@
|
|
|
33
77
|
background: var(--desk-rule);
|
|
34
78
|
}
|
|
35
79
|
|
|
80
|
+
.desk-dock:not([data-side="bottom"]) .desk-dock-separator {
|
|
81
|
+
width: auto;
|
|
82
|
+
height: 1px;
|
|
83
|
+
margin: 4px 6px;
|
|
84
|
+
}
|
|
85
|
+
|
|
36
86
|
.desk-dock-slot {
|
|
37
87
|
position: relative;
|
|
38
88
|
display: flex;
|
|
@@ -66,11 +116,22 @@
|
|
|
66
116
|
outline-offset: 2px;
|
|
67
117
|
}
|
|
68
118
|
|
|
119
|
+
/* Magnified toward the desk, whichever side that is. */
|
|
69
120
|
@media (hover: hover) and (pointer: fine) {
|
|
70
|
-
.desk-dock-item:hover:not(:disabled) {
|
|
121
|
+
.desk-dock[data-side="bottom"] .desk-dock-item:hover:not(:disabled) {
|
|
71
122
|
transform: translateY(-8px) scale(1.14);
|
|
72
123
|
margin: 0 5px;
|
|
73
124
|
}
|
|
125
|
+
|
|
126
|
+
.desk-dock[data-side="left"] .desk-dock-item:hover:not(:disabled) {
|
|
127
|
+
transform: translateX(8px) scale(1.14);
|
|
128
|
+
margin: 5px 0;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.desk-dock[data-side="right"] .desk-dock-item:hover:not(:disabled) {
|
|
132
|
+
transform: translateX(-8px) scale(1.14);
|
|
133
|
+
margin: 5px 0;
|
|
134
|
+
}
|
|
74
135
|
}
|
|
75
136
|
|
|
76
137
|
.desk-dock-icon {
|
|
@@ -126,6 +187,22 @@
|
|
|
126
187
|
background: var(--desk-muted);
|
|
127
188
|
}
|
|
128
189
|
|
|
190
|
+
/* On a dock at the side the dot sits between the item and the edge of the screen, as it does under a bottom one. */
|
|
191
|
+
.desk-dock:not([data-side="bottom"]) .desk-dock-item[data-running]::after {
|
|
192
|
+
top: 50%;
|
|
193
|
+
bottom: auto;
|
|
194
|
+
margin: -2px 0 0;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.desk-dock[data-side="left"] .desk-dock-item[data-running]::after {
|
|
198
|
+
left: -6px;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.desk-dock[data-side="right"] .desk-dock-item[data-running]::after {
|
|
202
|
+
left: auto;
|
|
203
|
+
right: -6px;
|
|
204
|
+
}
|
|
205
|
+
|
|
129
206
|
.desk-dock-item[data-focused]::after {
|
|
130
207
|
background: var(--desk-accent);
|
|
131
208
|
}
|
|
@@ -173,6 +250,21 @@
|
|
|
173
250
|
transition: opacity .12s;
|
|
174
251
|
}
|
|
175
252
|
|
|
253
|
+
.desk-dock:not([data-side="bottom"]) .desk-dock-tip {
|
|
254
|
+
bottom: auto;
|
|
255
|
+
top: 50%;
|
|
256
|
+
transform: translateY(-50%);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.desk-dock[data-side="left"] .desk-dock-tip {
|
|
260
|
+
left: calc(100% + 14px);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.desk-dock[data-side="right"] .desk-dock-tip {
|
|
264
|
+
left: auto;
|
|
265
|
+
right: calc(100% + 14px);
|
|
266
|
+
}
|
|
267
|
+
|
|
176
268
|
.desk-dock-item:hover .desk-dock-tip,
|
|
177
269
|
.desk-dock-item:focus-visible .desk-dock-tip {
|
|
178
270
|
opacity: 1;
|
|
@@ -210,6 +302,30 @@
|
|
|
210
302
|
}
|
|
211
303
|
}
|
|
212
304
|
|
|
305
|
+
/* Beside a dock at the side, level with the stack it came from, opening toward the desk. */
|
|
306
|
+
.desk-dock:not([data-side="bottom"]) .desk-stack {
|
|
307
|
+
bottom: auto;
|
|
308
|
+
top: 0;
|
|
309
|
+
transform: none;
|
|
310
|
+
animation-name: desk-pop-aside;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.desk-dock[data-side="left"] .desk-stack {
|
|
314
|
+
left: calc(100% + 18px);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
.desk-dock[data-side="right"] .desk-stack {
|
|
318
|
+
left: auto;
|
|
319
|
+
right: calc(100% + 18px);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
@keyframes desk-pop-aside {
|
|
323
|
+
from {
|
|
324
|
+
opacity: 0;
|
|
325
|
+
scale: .98;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
213
329
|
.desk-stack-title {
|
|
214
330
|
margin: 0 0 8px 4px;
|
|
215
331
|
font-size: 11px;
|
|
@@ -275,3 +391,7 @@
|
|
|
275
391
|
.desk-dock-item[data-desk-drop][data-over] {
|
|
276
392
|
box-shadow: -6px 0 0 -2px var(--desk-accent);
|
|
277
393
|
}
|
|
394
|
+
|
|
395
|
+
.desk-dock:not([data-side="bottom"]) .desk-dock-item[data-desk-drop][data-over] {
|
|
396
|
+
box-shadow: 0 -6px 0 -2px var(--desk-accent);
|
|
397
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Looks: the platform chrome, on `data-look` at the root. The rest of desk.css is the Mac look, so
|
|
3
|
+
* this part only says how GNOME and Windows differ from it.
|
|
4
|
+
*
|
|
5
|
+
* A look changes chrome, never brand: nothing here sets --desk-accent or --desk-ground. Selectors
|
|
6
|
+
* carry the look AND the base rule's own specificity, so they win by coming later, not by !important.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/* ── GNOME (Adwaita) ── */
|
|
10
|
+
|
|
11
|
+
[data-look="gnome"] {
|
|
12
|
+
--desk-font: Cantarell, "Adwaita Sans", system-ui, sans-serif;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
* Title and note stacked in the middle of the bar, centred on the bar and not on the space left over,
|
|
17
|
+
* as a GNOME header bar does. The end of the bar keeps room for the controls and a little more.
|
|
18
|
+
*/
|
|
19
|
+
[data-look="gnome"] .desk-titlebar {
|
|
20
|
+
position: relative;
|
|
21
|
+
min-height: 46px;
|
|
22
|
+
padding: 0 11px;
|
|
23
|
+
justify-content: flex-end;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
[data-look="gnome"] .desk-titlebar-heading {
|
|
27
|
+
position: absolute;
|
|
28
|
+
left: 50%;
|
|
29
|
+
transform: translateX(-50%);
|
|
30
|
+
max-width: calc(100% - 2 * 120px);
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
align-items: center;
|
|
34
|
+
text-align: center;
|
|
35
|
+
pointer-events: none;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
[data-look="gnome"] .desk-titlebar-heading > * {
|
|
39
|
+
max-width: 100%;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
[data-look="gnome"] .desk-title {
|
|
43
|
+
font-size: 13.5px;
|
|
44
|
+
font-weight: 700;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
[data-look="gnome"] .desk-window-note {
|
|
48
|
+
margin: 0;
|
|
49
|
+
font-size: 11.5px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
[data-look="gnome"] .desk-window .desk-controls {
|
|
53
|
+
gap: 12px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
[data-look="gnome"] .desk-window .desk-control[data-control] {
|
|
57
|
+
width: 24px;
|
|
58
|
+
height: 24px;
|
|
59
|
+
background: color-mix(in srgb, var(--desk-ink) 10%, transparent);
|
|
60
|
+
color: var(--desk-ink);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
[data-look="gnome"] .desk-window .desk-controls .desk-control[data-control]:hover {
|
|
64
|
+
background: color-mix(in srgb, var(--desk-ink) 16%, transparent);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
[data-look="gnome"] .desk-window .desk-controls .desk-control[data-control]:active {
|
|
68
|
+
background: color-mix(in srgb, var(--desk-ink) 26%, transparent);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* GNOME's marks are always there: symbolic icons, not colours. */
|
|
72
|
+
[data-look="gnome"] .desk-window .desk-control-glyph {
|
|
73
|
+
opacity: 1;
|
|
74
|
+
color: currentColor;
|
|
75
|
+
stroke-width: 1.3;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* The key window is told apart by its shadow and its title, not by an accent border. */
|
|
79
|
+
[data-look="gnome"] .desk-window[data-focused] {
|
|
80
|
+
border-color: var(--desk-rule);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* ── Windows 11 ── */
|
|
84
|
+
|
|
85
|
+
[data-look="windows"] {
|
|
86
|
+
--desk-font: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
|
|
87
|
+
--desk-radius: 8px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* The controls run the full height of the bar, flush to its end. */
|
|
91
|
+
[data-look="windows"] .desk-titlebar {
|
|
92
|
+
min-height: 32px;
|
|
93
|
+
padding: 0 0 0 12px;
|
|
94
|
+
align-items: stretch;
|
|
95
|
+
background: var(--desk-surface);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
[data-look="windows"] .desk-titlebar > * {
|
|
99
|
+
align-self: center;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
[data-look="windows"] .desk-title {
|
|
103
|
+
flex: 1 1 auto;
|
|
104
|
+
font-size: 12px;
|
|
105
|
+
font-weight: 400;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
[data-look="windows"] .desk-titlebar > .desk-controls {
|
|
109
|
+
align-self: stretch;
|
|
110
|
+
margin-left: var(--desk-space-2);
|
|
111
|
+
gap: 0;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
[data-look="windows"] .desk-window .desk-control[data-control] {
|
|
115
|
+
width: 46px;
|
|
116
|
+
height: auto;
|
|
117
|
+
border-radius: 0;
|
|
118
|
+
background: transparent;
|
|
119
|
+
color: var(--desk-ink);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
[data-look="windows"] .desk-window .desk-controls .desk-control[data-control]:hover {
|
|
123
|
+
background: color-mix(in srgb, var(--desk-ink) 8%, transparent);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
[data-look="windows"] .desk-window .desk-controls .desk-control[data-control="close"]:hover {
|
|
127
|
+
background: #c42b1c;
|
|
128
|
+
color: #ffffff;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
[data-look="windows"] .desk-window .desk-control-glyph {
|
|
132
|
+
width: 10px;
|
|
133
|
+
height: 10px;
|
|
134
|
+
opacity: 1;
|
|
135
|
+
color: currentColor;
|
|
136
|
+
stroke-width: 1;
|
|
137
|
+
stroke-linecap: butt;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
[data-look="windows"] .desk-window:not([data-focused]) .desk-control-glyph {
|
|
141
|
+
opacity: .45;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
[data-look="windows"] .desk-control:focus-visible {
|
|
145
|
+
outline-offset: -2px;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/*
|
|
149
|
+
* ── GNOME shell: the top bar and the dash are dark in either theme, and so is what opens from them ──
|
|
150
|
+
* The tokens are redefined on the bar and the dock themselves, so their menus and stacks, which sit
|
|
151
|
+
* inside them, come out dark too — as the shell's own menus do.
|
|
152
|
+
*/
|
|
153
|
+
[data-look="gnome"] .desk-menubar,
|
|
154
|
+
[data-look="gnome"] .desk-dock {
|
|
155
|
+
--desk-ink: #ffffff;
|
|
156
|
+
--desk-muted: rgb(255 255 255 / 68%);
|
|
157
|
+
--desk-surface: #2a2a2a;
|
|
158
|
+
--desk-rule: rgb(255 255 255 / 10%);
|
|
159
|
+
--desk-dock-icon: transparent;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
[data-look="gnome"] .desk-menubar {
|
|
163
|
+
height: 32px;
|
|
164
|
+
--desk-dock-glass: rgb(0 0 0 / 94%);
|
|
165
|
+
border-bottom: 0;
|
|
166
|
+
font-weight: 600;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
[data-look="gnome"] .desk-menubar-title {
|
|
170
|
+
border-radius: 999px;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
[data-look="gnome"] .desk-menu {
|
|
174
|
+
border-radius: 12px;
|
|
175
|
+
padding: 6px;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
[data-look="gnome"] .desk-menu-item {
|
|
179
|
+
border-radius: 6px;
|
|
180
|
+
font-weight: 400;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
[data-look="gnome"] .desk-menu-item[data-active],
|
|
184
|
+
[data-look="windows"] .desk-menu-item[data-active] {
|
|
185
|
+
background: color-mix(in srgb, var(--desk-ink) 10%, transparent);
|
|
186
|
+
color: var(--desk-ink);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
[data-look="gnome"] .desk-dock {
|
|
190
|
+
--desk-dock-glass: rgb(24 24 24 / 86%);
|
|
191
|
+
border-radius: 20px;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
[data-look="gnome"] .desk-dock .desk-dock-item {
|
|
195
|
+
border: 0;
|
|
196
|
+
border-radius: 12px;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/* No magnification: GNOME's dash lights an item up rather than growing it. */
|
|
200
|
+
[data-look="gnome"] .desk-dock .desk-dock-item:hover:not(:disabled),
|
|
201
|
+
[data-look="windows"] .desk-dock .desk-dock-item:hover:not(:disabled) {
|
|
202
|
+
transform: none;
|
|
203
|
+
margin: 0;
|
|
204
|
+
background: color-mix(in srgb, var(--desk-ink) 12%, transparent);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/* ── Windows: a flat bar, taskbar tiles, and a pill that widens for the key window ── */
|
|
208
|
+
|
|
209
|
+
[data-look="windows"] .desk-menubar {
|
|
210
|
+
background: var(--desk-surface);
|
|
211
|
+
backdrop-filter: none;
|
|
212
|
+
-webkit-backdrop-filter: none;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
[data-look="windows"] .desk-menubar-title,
|
|
216
|
+
[data-look="windows"] .desk-menu-item {
|
|
217
|
+
border-radius: 4px;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
[data-look="windows"] .desk-menu {
|
|
221
|
+
border-radius: 8px;
|
|
222
|
+
padding: 4px;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
[data-look="windows"] .desk-dock {
|
|
226
|
+
border-radius: 8px;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
[data-look="windows"] .desk-dock .desk-dock-item {
|
|
230
|
+
border: 0;
|
|
231
|
+
border-radius: 4px;
|
|
232
|
+
background: transparent;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
[data-look="windows"] .desk-dock .desk-dock-item[data-running]::after {
|
|
236
|
+
width: 6px;
|
|
237
|
+
height: 3px;
|
|
238
|
+
margin-left: -3px;
|
|
239
|
+
border-radius: 2px;
|
|
240
|
+
bottom: -4px;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
[data-look="windows"] .desk-dock[data-side="bottom"] .desk-dock-item[data-focused]::after {
|
|
244
|
+
width: 16px;
|
|
245
|
+
margin-left: -8px;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
[data-look="windows"] .desk-dock:not([data-side="bottom"]) .desk-dock-item[data-running]::after {
|
|
249
|
+
width: 3px;
|
|
250
|
+
height: 6px;
|
|
251
|
+
margin: -3px 0 0;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
[data-look="windows"] .desk-dock:not([data-side="bottom"]) .desk-dock-item[data-focused]::after {
|
|
255
|
+
height: 16px;
|
|
256
|
+
margin-top: -8px;
|
|
257
|
+
}
|
package/src/css/tokens.css
CHANGED
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
--desk-mode: #34c47a;
|
|
16
16
|
--desk-info: #34c47a;
|
|
17
17
|
--desk-radius: 12px;
|
|
18
|
+
|
|
19
|
+
/* Between one field and the next. Larger than the 4px inside a field, or the pairing is lost. */
|
|
20
|
+
--desk-field-gap: 16px;
|
|
18
21
|
--desk-gap: 12px;
|
|
19
22
|
--desk-padding: 12px;
|
|
20
23
|
--desk-shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 12px 32px rgb(16 24 40 / 10%);
|
|
@@ -43,11 +46,15 @@
|
|
|
43
46
|
--desk-on-accent: #ffffff;
|
|
44
47
|
--desk-ease: cubic-bezier(.32, .72, 0, 1);
|
|
45
48
|
--desk-dock-size: 48px;
|
|
49
|
+
/* How far an overlay dock stands off the edge of the desk. */
|
|
50
|
+
--desk-dock-offset: 12px;
|
|
51
|
+
/* The room an overlay dock takes from the stage beside it: the offset, the dock, its border and padding. */
|
|
52
|
+
--desk-dock-room: calc(var(--desk-dock-offset) + var(--desk-dock-size) + 16px);
|
|
46
53
|
--desk-dock-glass: rgb(255 255 255 / 72%);
|
|
47
54
|
--desk-dock-icon: linear-gradient(160deg, #ffffff, #eceff5);
|
|
48
55
|
--desk-badge: #ef4444;
|
|
49
56
|
--desk-badge-ink: #ffffff;
|
|
50
|
-
/* Room the stage leaves at the bottom for
|
|
57
|
+
/* Room the stage leaves at the bottom for something of the app's own. An overlay dock makes its own. */
|
|
51
58
|
--desk-inset-bottom: 0px;
|
|
52
59
|
}
|
|
53
60
|
|
package/src/fx/fx.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Sounds for an app on the desk: `attention`, `ready` and `failed`, and any an app adds.
|
|
3
|
+
*
|
|
4
|
+
* WHEN to make one is the app's decision and the hard part; see HIG.md, "Sound". This is the
|
|
5
|
+
* instrument: one audio context, opened on the first press, a repeat of the same sound inside a
|
|
6
|
+
* short window heard once, and a mute this browser remembers.
|
|
7
|
+
*/
|
|
8
|
+
import { SCORES, scored, type BuiltInSound, type Sound } from './sounds.js'
|
|
9
|
+
|
|
10
|
+
export interface FxOptions<Extra extends string> {
|
|
11
|
+
/** Sounds of the app's own, or replacements for the built-ins. */
|
|
12
|
+
readonly sounds?: Readonly<Record<Extra, Sound>>
|
|
13
|
+
/** Where the mute is kept. Two apps on one origin that should not share a switch need two keys. */
|
|
14
|
+
readonly storageKey?: string
|
|
15
|
+
/** A second request for the same sound inside this many milliseconds is the same event. */
|
|
16
|
+
readonly coalesceMs?: number
|
|
17
|
+
/** Master gain over every sound. */
|
|
18
|
+
readonly volume?: number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface Fx<Name extends string> {
|
|
22
|
+
/** Plays now if it can; whether it did. Silent when muted, repeated, or before any press. */
|
|
23
|
+
play(name: Name, nowMs?: number): boolean
|
|
24
|
+
/**
|
|
25
|
+
* Opens audio on the first press. A browser refuses sound on a page nobody has touched, and a
|
|
26
|
+
* sound arrives unasked, long after the last click: the press has to be taken while it happens.
|
|
27
|
+
* Returns a teardown.
|
|
28
|
+
*/
|
|
29
|
+
unlock(): () => void
|
|
30
|
+
muted(): boolean
|
|
31
|
+
setMuted(muted: boolean): void
|
|
32
|
+
/** Told when the mute changes, here or in another tab. */
|
|
33
|
+
subscribe(listener: () => void): () => void
|
|
34
|
+
/** Schedules a sound into any context, an offline one included, for measuring. */
|
|
35
|
+
render(ctx: BaseAudioContext, name: Name, out: AudioNode): void
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type Ctor = typeof AudioContext
|
|
39
|
+
|
|
40
|
+
function audioContextClass(): Ctor | null {
|
|
41
|
+
if (typeof window === 'undefined') return null
|
|
42
|
+
return window.AudioContext ?? (window as { webkitAudioContext?: Ctor }).webkitAudioContext ?? null
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function createFx<Extra extends string = never>(
|
|
46
|
+
options: FxOptions<Extra> = {},
|
|
47
|
+
): Fx<BuiltInSound | Extra> {
|
|
48
|
+
type Name = BuiltInSound | Extra
|
|
49
|
+
const { storageKey = 'desk-fx-muted', coalesceMs = 1500, volume = 0.8 } = options
|
|
50
|
+
const builtIn = Object.fromEntries(Object.entries(SCORES).map(([name, score]) => [name, scored(score)]))
|
|
51
|
+
const sounds = { ...builtIn, ...options.sounds } as Record<Name, Sound>
|
|
52
|
+
const lastPlayed = new Map<string, number>()
|
|
53
|
+
const listeners = new Set<() => void>()
|
|
54
|
+
let audio: AudioContext | null = null
|
|
55
|
+
|
|
56
|
+
const context = (): AudioContext | null => {
|
|
57
|
+
if (audio) return audio
|
|
58
|
+
const Class = audioContextClass()
|
|
59
|
+
if (!Class) return null
|
|
60
|
+
try {
|
|
61
|
+
audio = new Class()
|
|
62
|
+
} catch {
|
|
63
|
+
return null
|
|
64
|
+
}
|
|
65
|
+
return audio
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const muted = (): boolean => {
|
|
69
|
+
try {
|
|
70
|
+
return localStorage.getItem(storageKey) === 'yes'
|
|
71
|
+
} catch {
|
|
72
|
+
return false
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const render = (ctx: BaseAudioContext, name: Name, out: AudioNode): void => {
|
|
77
|
+
const master = ctx.createGain()
|
|
78
|
+
const at = ctx.currentTime + 0.01
|
|
79
|
+
master.gain.setValueAtTime(volume, at)
|
|
80
|
+
master.connect(out)
|
|
81
|
+
sounds[name](ctx, master, at)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
play(name, nowMs = Date.now()) {
|
|
86
|
+
if (muted()) return false
|
|
87
|
+
const previous = lastPlayed.get(name)
|
|
88
|
+
if (previous !== undefined && nowMs - previous < coalesceMs) return false
|
|
89
|
+
const ctx = context()
|
|
90
|
+
// Never resumed from here: outside a press the promise may never settle, and a sound that
|
|
91
|
+
// lands a click late belongs to the wrong moment.
|
|
92
|
+
if (!ctx || ctx.state !== 'running') return false
|
|
93
|
+
lastPlayed.set(name, nowMs)
|
|
94
|
+
try {
|
|
95
|
+
render(ctx, name, ctx.destination)
|
|
96
|
+
return true
|
|
97
|
+
} catch {
|
|
98
|
+
return false
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
unlock() {
|
|
103
|
+
if (typeof window === 'undefined') return () => undefined
|
|
104
|
+
const stop = (): void => {
|
|
105
|
+
window.removeEventListener('pointerdown', open)
|
|
106
|
+
window.removeEventListener('keydown', open)
|
|
107
|
+
}
|
|
108
|
+
function open(): void {
|
|
109
|
+
stop()
|
|
110
|
+
const ctx = context()
|
|
111
|
+
// Inside the handler, where the browser is willing to listen.
|
|
112
|
+
if (ctx && ctx.state !== 'running') void ctx.resume().catch(() => undefined)
|
|
113
|
+
}
|
|
114
|
+
window.addEventListener('pointerdown', open)
|
|
115
|
+
window.addEventListener('keydown', open)
|
|
116
|
+
return stop
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
muted,
|
|
120
|
+
|
|
121
|
+
setMuted(next) {
|
|
122
|
+
try {
|
|
123
|
+
if (next) localStorage.setItem(storageKey, 'yes')
|
|
124
|
+
else localStorage.removeItem(storageKey)
|
|
125
|
+
} catch {
|
|
126
|
+
// Blocked site data: sounds stay on, which is the default.
|
|
127
|
+
}
|
|
128
|
+
listeners.forEach((listener) => listener())
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
subscribe(listener) {
|
|
132
|
+
listeners.add(listener)
|
|
133
|
+
const fromAnotherTab = (event: StorageEvent): void => {
|
|
134
|
+
if (event.key === storageKey) listener()
|
|
135
|
+
}
|
|
136
|
+
if (typeof window !== 'undefined') window.addEventListener('storage', fromAnotherTab)
|
|
137
|
+
return () => {
|
|
138
|
+
listeners.delete(listener)
|
|
139
|
+
if (typeof window !== 'undefined') window.removeEventListener('storage', fromAnotherTab)
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
render,
|
|
144
|
+
}
|
|
145
|
+
}
|