@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/dist/css/tokens.css
CHANGED
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
--desk-mode: #34c47a;
|
|
17
17
|
--desk-info: #34c47a;
|
|
18
18
|
--desk-radius: 12px;
|
|
19
|
+
|
|
20
|
+
/* Between one field and the next. Larger than the 4px inside a field, or the pairing is lost. */
|
|
21
|
+
--desk-field-gap: 16px;
|
|
19
22
|
--desk-gap: 12px;
|
|
20
23
|
--desk-padding: 12px;
|
|
21
24
|
--desk-shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 12px 32px rgb(16 24 40 / 10%);
|
|
@@ -44,11 +47,15 @@
|
|
|
44
47
|
--desk-on-accent: #ffffff;
|
|
45
48
|
--desk-ease: cubic-bezier(.32, .72, 0, 1);
|
|
46
49
|
--desk-dock-size: 48px;
|
|
50
|
+
/* How far an overlay dock stands off the edge of the desk. */
|
|
51
|
+
--desk-dock-offset: 12px;
|
|
52
|
+
/* The room an overlay dock takes from the stage beside it: the offset, the dock, its border and padding. */
|
|
53
|
+
--desk-dock-room: calc(var(--desk-dock-offset) + var(--desk-dock-size) + 16px);
|
|
47
54
|
--desk-dock-glass: rgb(255 255 255 / 72%);
|
|
48
55
|
--desk-dock-icon: linear-gradient(160deg, #ffffff, #eceff5);
|
|
49
56
|
--desk-badge: #ef4444;
|
|
50
57
|
--desk-badge-ink: #ffffff;
|
|
51
|
-
/* Room the stage leaves at the bottom for
|
|
58
|
+
/* Room the stage leaves at the bottom for something of the app's own. An overlay dock makes its own. */
|
|
52
59
|
--desk-inset-bottom: 0px;
|
|
53
60
|
}
|
|
54
61
|
|
package/dist/desk.css
CHANGED
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
--desk-mode: #34c47a;
|
|
17
17
|
--desk-info: #34c47a;
|
|
18
18
|
--desk-radius: 12px;
|
|
19
|
+
|
|
20
|
+
/* Between one field and the next. Larger than the 4px inside a field, or the pairing is lost. */
|
|
21
|
+
--desk-field-gap: 16px;
|
|
19
22
|
--desk-gap: 12px;
|
|
20
23
|
--desk-padding: 12px;
|
|
21
24
|
--desk-shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 12px 32px rgb(16 24 40 / 10%);
|
|
@@ -44,11 +47,15 @@
|
|
|
44
47
|
--desk-on-accent: #ffffff;
|
|
45
48
|
--desk-ease: cubic-bezier(.32, .72, 0, 1);
|
|
46
49
|
--desk-dock-size: 48px;
|
|
50
|
+
/* How far an overlay dock stands off the edge of the desk. */
|
|
51
|
+
--desk-dock-offset: 12px;
|
|
52
|
+
/* The room an overlay dock takes from the stage beside it: the offset, the dock, its border and padding. */
|
|
53
|
+
--desk-dock-room: calc(var(--desk-dock-offset) + var(--desk-dock-size) + 16px);
|
|
47
54
|
--desk-dock-glass: rgb(255 255 255 / 72%);
|
|
48
55
|
--desk-dock-icon: linear-gradient(160deg, #ffffff, #eceff5);
|
|
49
56
|
--desk-badge: #ef4444;
|
|
50
57
|
--desk-badge-ink: #ffffff;
|
|
51
|
-
/* Room the stage leaves at the bottom for
|
|
58
|
+
/* Room the stage leaves at the bottom for something of the app's own. An overlay dock makes its own. */
|
|
52
59
|
--desk-inset-bottom: 0px;
|
|
53
60
|
}
|
|
54
61
|
|
|
@@ -465,12 +472,56 @@
|
|
|
465
472
|
|
|
466
473
|
.desk-dock[data-placement="overlay"] {
|
|
467
474
|
position: absolute;
|
|
468
|
-
left: 50%;
|
|
469
|
-
bottom: 12px;
|
|
470
475
|
z-index: 1000;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
.desk-dock[data-placement="overlay"][data-side="bottom"] {
|
|
479
|
+
left: 50%;
|
|
480
|
+
bottom: var(--desk-dock-offset);
|
|
471
481
|
transform: translateX(-50%);
|
|
472
482
|
}
|
|
473
483
|
|
|
484
|
+
.desk-dock[data-placement="overlay"]:not([data-side="bottom"]) {
|
|
485
|
+
top: 50%;
|
|
486
|
+
transform: translateY(-50%);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
.desk-dock[data-placement="overlay"][data-side="left"] {
|
|
490
|
+
left: var(--desk-dock-offset);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.desk-dock[data-placement="overlay"][data-side="right"] {
|
|
494
|
+
right: var(--desk-dock-offset);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/* Standing in a column: items top to bottom, and never taller than the room it stands in. */
|
|
498
|
+
.desk-dock:not([data-side="bottom"]) {
|
|
499
|
+
flex-direction: column;
|
|
500
|
+
align-items: center;
|
|
501
|
+
max-width: none;
|
|
502
|
+
max-height: calc(100% - 2 * var(--desk-dock-offset));
|
|
503
|
+
/* The same thickness standing up as lying down, so --desk-dock-room holds on every side. */
|
|
504
|
+
padding: 9px 7px;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
/*
|
|
508
|
+
* An overlay dock makes its own room. The stage beside it starts where the dock ends — a margin, not
|
|
509
|
+
* padding, because windows are placed from the stage's own corner: padding would keep filled windows
|
|
510
|
+
* clear and still open every free one underneath the dock.
|
|
511
|
+
*/
|
|
512
|
+
:has(> .desk-dock[data-placement="overlay"][data-side="left"]) > .desk-stage {
|
|
513
|
+
margin-left: var(--desk-dock-room);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
:has(> .desk-dock[data-placement="overlay"][data-side="right"]) > .desk-stage {
|
|
517
|
+
margin-right: var(--desk-dock-room);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
:has(> .desk-dock[data-placement="overlay"][data-side="bottom"]) > .desk-stage {
|
|
521
|
+
/* The stage is `height: 100%`, so a margin would push it past its parent rather than shorten it. */
|
|
522
|
+
height: calc(100% - var(--desk-dock-room));
|
|
523
|
+
}
|
|
524
|
+
|
|
474
525
|
.desk-dock-separator {
|
|
475
526
|
flex: none;
|
|
476
527
|
align-self: stretch;
|
|
@@ -479,6 +530,12 @@
|
|
|
479
530
|
background: var(--desk-rule);
|
|
480
531
|
}
|
|
481
532
|
|
|
533
|
+
.desk-dock:not([data-side="bottom"]) .desk-dock-separator {
|
|
534
|
+
width: auto;
|
|
535
|
+
height: 1px;
|
|
536
|
+
margin: 4px 6px;
|
|
537
|
+
}
|
|
538
|
+
|
|
482
539
|
.desk-dock-slot {
|
|
483
540
|
position: relative;
|
|
484
541
|
display: flex;
|
|
@@ -512,11 +569,22 @@
|
|
|
512
569
|
outline-offset: 2px;
|
|
513
570
|
}
|
|
514
571
|
|
|
572
|
+
/* Magnified toward the desk, whichever side that is. */
|
|
515
573
|
@media (hover: hover) and (pointer: fine) {
|
|
516
|
-
.desk-dock-item:hover:not(:disabled) {
|
|
574
|
+
.desk-dock[data-side="bottom"] .desk-dock-item:hover:not(:disabled) {
|
|
517
575
|
transform: translateY(-8px) scale(1.14);
|
|
518
576
|
margin: 0 5px;
|
|
519
577
|
}
|
|
578
|
+
|
|
579
|
+
.desk-dock[data-side="left"] .desk-dock-item:hover:not(:disabled) {
|
|
580
|
+
transform: translateX(8px) scale(1.14);
|
|
581
|
+
margin: 5px 0;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
.desk-dock[data-side="right"] .desk-dock-item:hover:not(:disabled) {
|
|
585
|
+
transform: translateX(-8px) scale(1.14);
|
|
586
|
+
margin: 5px 0;
|
|
587
|
+
}
|
|
520
588
|
}
|
|
521
589
|
|
|
522
590
|
.desk-dock-icon {
|
|
@@ -572,6 +640,22 @@
|
|
|
572
640
|
background: var(--desk-muted);
|
|
573
641
|
}
|
|
574
642
|
|
|
643
|
+
/* 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. */
|
|
644
|
+
.desk-dock:not([data-side="bottom"]) .desk-dock-item[data-running]::after {
|
|
645
|
+
top: 50%;
|
|
646
|
+
bottom: auto;
|
|
647
|
+
margin: -2px 0 0;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
.desk-dock[data-side="left"] .desk-dock-item[data-running]::after {
|
|
651
|
+
left: -6px;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
.desk-dock[data-side="right"] .desk-dock-item[data-running]::after {
|
|
655
|
+
left: auto;
|
|
656
|
+
right: -6px;
|
|
657
|
+
}
|
|
658
|
+
|
|
575
659
|
.desk-dock-item[data-focused]::after {
|
|
576
660
|
background: var(--desk-accent);
|
|
577
661
|
}
|
|
@@ -619,6 +703,21 @@
|
|
|
619
703
|
transition: opacity .12s;
|
|
620
704
|
}
|
|
621
705
|
|
|
706
|
+
.desk-dock:not([data-side="bottom"]) .desk-dock-tip {
|
|
707
|
+
bottom: auto;
|
|
708
|
+
top: 50%;
|
|
709
|
+
transform: translateY(-50%);
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
.desk-dock[data-side="left"] .desk-dock-tip {
|
|
713
|
+
left: calc(100% + 14px);
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
.desk-dock[data-side="right"] .desk-dock-tip {
|
|
717
|
+
left: auto;
|
|
718
|
+
right: calc(100% + 14px);
|
|
719
|
+
}
|
|
720
|
+
|
|
622
721
|
.desk-dock-item:hover .desk-dock-tip,
|
|
623
722
|
.desk-dock-item:focus-visible .desk-dock-tip {
|
|
624
723
|
opacity: 1;
|
|
@@ -656,6 +755,30 @@
|
|
|
656
755
|
}
|
|
657
756
|
}
|
|
658
757
|
|
|
758
|
+
/* Beside a dock at the side, level with the stack it came from, opening toward the desk. */
|
|
759
|
+
.desk-dock:not([data-side="bottom"]) .desk-stack {
|
|
760
|
+
bottom: auto;
|
|
761
|
+
top: 0;
|
|
762
|
+
transform: none;
|
|
763
|
+
animation-name: desk-pop-aside;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
.desk-dock[data-side="left"] .desk-stack {
|
|
767
|
+
left: calc(100% + 18px);
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
.desk-dock[data-side="right"] .desk-stack {
|
|
771
|
+
left: auto;
|
|
772
|
+
right: calc(100% + 18px);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
@keyframes desk-pop-aside {
|
|
776
|
+
from {
|
|
777
|
+
opacity: 0;
|
|
778
|
+
scale: .98;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
659
782
|
.desk-stack-title {
|
|
660
783
|
margin: 0 0 8px 4px;
|
|
661
784
|
font-size: 11px;
|
|
@@ -722,6 +845,10 @@
|
|
|
722
845
|
box-shadow: -6px 0 0 -2px var(--desk-accent);
|
|
723
846
|
}
|
|
724
847
|
|
|
848
|
+
.desk-dock:not([data-side="bottom"]) .desk-dock-item[data-desk-drop][data-over] {
|
|
849
|
+
box-shadow: 0 -6px 0 -2px var(--desk-accent);
|
|
850
|
+
}
|
|
851
|
+
|
|
725
852
|
/* @liberation-data/desk — menus.css */
|
|
726
853
|
/* ── Menu bar ── */
|
|
727
854
|
|
|
@@ -1066,6 +1193,22 @@
|
|
|
1066
1193
|
cursor: pointer;
|
|
1067
1194
|
}
|
|
1068
1195
|
|
|
1196
|
+
/*
|
|
1197
|
+
* Spanning the row, with every option the same width. The default sizes each option to its label,
|
|
1198
|
+
* which is right in a toolbar and wrong when the control is the heading of the thing below it:
|
|
1199
|
+
* equal answers should not be different sizes because one of them is a longer word.
|
|
1200
|
+
*/
|
|
1201
|
+
.desk-segmented[data-width="fill"] {
|
|
1202
|
+
display: flex;
|
|
1203
|
+
width: 100%;
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
.desk-segmented[data-width="fill"] .desk-segment {
|
|
1207
|
+
flex: 1 1 0;
|
|
1208
|
+
min-width: 0;
|
|
1209
|
+
justify-content: center;
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1069
1212
|
.desk-segmented[data-size="small"] .desk-segment {
|
|
1070
1213
|
min-height: calc(var(--desk-control-height-small) - 4px);
|
|
1071
1214
|
padding: 0 var(--desk-space-2);
|
|
@@ -1133,12 +1276,33 @@
|
|
|
1133
1276
|
gap: 2px;
|
|
1134
1277
|
}
|
|
1135
1278
|
|
|
1279
|
+
/*
|
|
1280
|
+
* A LABEL AND ITS INPUT ARE ONE THING, and the space around them has to say so. The gap INSIDE a
|
|
1281
|
+
* field is 4px; the gap BETWEEN fields has to be clearly larger, or the eye groups a label with
|
|
1282
|
+
* the field above it instead of the one below — which is what a label sitting closer to its
|
|
1283
|
+
* neighbour than to its own input actually does.
|
|
1284
|
+
*
|
|
1285
|
+
* `.desk-field` only ever set the inside gap, and said nothing about the outside. Every consumer
|
|
1286
|
+
* picked its own: one app's forms came out at 14px, another's at 10px, and anything that forgot
|
|
1287
|
+
* got the browser's default of none. Same components, different grouping, and no rule to point at.
|
|
1288
|
+
*/
|
|
1136
1289
|
.desk-field {
|
|
1137
1290
|
display: flex;
|
|
1138
1291
|
flex-direction: column;
|
|
1139
1292
|
gap: var(--desk-space-1);
|
|
1140
1293
|
}
|
|
1141
1294
|
|
|
1295
|
+
/*
|
|
1296
|
+
* The container a stack of fields goes in. Four times the inside gap, which is enough that the
|
|
1297
|
+
* pairing is read rather than worked out, and an app that wants tighter or looser sets the token
|
|
1298
|
+
* rather than the rule.
|
|
1299
|
+
*/
|
|
1300
|
+
.desk-fields {
|
|
1301
|
+
display: flex;
|
|
1302
|
+
flex-direction: column;
|
|
1303
|
+
gap: var(--desk-field-gap, var(--desk-space-4));
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1142
1306
|
.desk-label {
|
|
1143
1307
|
font-size: 12px;
|
|
1144
1308
|
font-weight: 500;
|
|
@@ -2968,3 +3132,262 @@
|
|
|
2968
3132
|
border: 0;
|
|
2969
3133
|
background: var(--desk-surface);
|
|
2970
3134
|
}
|
|
3135
|
+
|
|
3136
|
+
/* @liberation-data/desk — looks.css */
|
|
3137
|
+
/*
|
|
3138
|
+
* Looks: the platform chrome, on `data-look` at the root. The rest of desk.css is the Mac look, so
|
|
3139
|
+
* this part only says how GNOME and Windows differ from it.
|
|
3140
|
+
*
|
|
3141
|
+
* A look changes chrome, never brand: nothing here sets --desk-accent or --desk-ground. Selectors
|
|
3142
|
+
* carry the look AND the base rule's own specificity, so they win by coming later, not by !important.
|
|
3143
|
+
*/
|
|
3144
|
+
|
|
3145
|
+
/* ── GNOME (Adwaita) ── */
|
|
3146
|
+
|
|
3147
|
+
[data-look="gnome"] {
|
|
3148
|
+
--desk-font: Cantarell, "Adwaita Sans", system-ui, sans-serif;
|
|
3149
|
+
}
|
|
3150
|
+
|
|
3151
|
+
/*
|
|
3152
|
+
* Title and note stacked in the middle of the bar, centred on the bar and not on the space left over,
|
|
3153
|
+
* as a GNOME header bar does. The end of the bar keeps room for the controls and a little more.
|
|
3154
|
+
*/
|
|
3155
|
+
[data-look="gnome"] .desk-titlebar {
|
|
3156
|
+
position: relative;
|
|
3157
|
+
min-height: 46px;
|
|
3158
|
+
padding: 0 11px;
|
|
3159
|
+
justify-content: flex-end;
|
|
3160
|
+
}
|
|
3161
|
+
|
|
3162
|
+
[data-look="gnome"] .desk-titlebar-heading {
|
|
3163
|
+
position: absolute;
|
|
3164
|
+
left: 50%;
|
|
3165
|
+
transform: translateX(-50%);
|
|
3166
|
+
max-width: calc(100% - 2 * 120px);
|
|
3167
|
+
display: flex;
|
|
3168
|
+
flex-direction: column;
|
|
3169
|
+
align-items: center;
|
|
3170
|
+
text-align: center;
|
|
3171
|
+
pointer-events: none;
|
|
3172
|
+
}
|
|
3173
|
+
|
|
3174
|
+
[data-look="gnome"] .desk-titlebar-heading > * {
|
|
3175
|
+
max-width: 100%;
|
|
3176
|
+
}
|
|
3177
|
+
|
|
3178
|
+
[data-look="gnome"] .desk-title {
|
|
3179
|
+
font-size: 13.5px;
|
|
3180
|
+
font-weight: 700;
|
|
3181
|
+
}
|
|
3182
|
+
|
|
3183
|
+
[data-look="gnome"] .desk-window-note {
|
|
3184
|
+
margin: 0;
|
|
3185
|
+
font-size: 11.5px;
|
|
3186
|
+
}
|
|
3187
|
+
|
|
3188
|
+
[data-look="gnome"] .desk-window .desk-controls {
|
|
3189
|
+
gap: 12px;
|
|
3190
|
+
}
|
|
3191
|
+
|
|
3192
|
+
[data-look="gnome"] .desk-window .desk-control[data-control] {
|
|
3193
|
+
width: 24px;
|
|
3194
|
+
height: 24px;
|
|
3195
|
+
background: color-mix(in srgb, var(--desk-ink) 10%, transparent);
|
|
3196
|
+
color: var(--desk-ink);
|
|
3197
|
+
}
|
|
3198
|
+
|
|
3199
|
+
[data-look="gnome"] .desk-window .desk-controls .desk-control[data-control]:hover {
|
|
3200
|
+
background: color-mix(in srgb, var(--desk-ink) 16%, transparent);
|
|
3201
|
+
}
|
|
3202
|
+
|
|
3203
|
+
[data-look="gnome"] .desk-window .desk-controls .desk-control[data-control]:active {
|
|
3204
|
+
background: color-mix(in srgb, var(--desk-ink) 26%, transparent);
|
|
3205
|
+
}
|
|
3206
|
+
|
|
3207
|
+
/* GNOME's marks are always there: symbolic icons, not colours. */
|
|
3208
|
+
[data-look="gnome"] .desk-window .desk-control-glyph {
|
|
3209
|
+
opacity: 1;
|
|
3210
|
+
color: currentColor;
|
|
3211
|
+
stroke-width: 1.3;
|
|
3212
|
+
}
|
|
3213
|
+
|
|
3214
|
+
/* The key window is told apart by its shadow and its title, not by an accent border. */
|
|
3215
|
+
[data-look="gnome"] .desk-window[data-focused] {
|
|
3216
|
+
border-color: var(--desk-rule);
|
|
3217
|
+
}
|
|
3218
|
+
|
|
3219
|
+
/* ── Windows 11 ── */
|
|
3220
|
+
|
|
3221
|
+
[data-look="windows"] {
|
|
3222
|
+
--desk-font: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
|
|
3223
|
+
--desk-radius: 8px;
|
|
3224
|
+
}
|
|
3225
|
+
|
|
3226
|
+
/* The controls run the full height of the bar, flush to its end. */
|
|
3227
|
+
[data-look="windows"] .desk-titlebar {
|
|
3228
|
+
min-height: 32px;
|
|
3229
|
+
padding: 0 0 0 12px;
|
|
3230
|
+
align-items: stretch;
|
|
3231
|
+
background: var(--desk-surface);
|
|
3232
|
+
}
|
|
3233
|
+
|
|
3234
|
+
[data-look="windows"] .desk-titlebar > * {
|
|
3235
|
+
align-self: center;
|
|
3236
|
+
}
|
|
3237
|
+
|
|
3238
|
+
[data-look="windows"] .desk-title {
|
|
3239
|
+
flex: 1 1 auto;
|
|
3240
|
+
font-size: 12px;
|
|
3241
|
+
font-weight: 400;
|
|
3242
|
+
}
|
|
3243
|
+
|
|
3244
|
+
[data-look="windows"] .desk-titlebar > .desk-controls {
|
|
3245
|
+
align-self: stretch;
|
|
3246
|
+
margin-left: var(--desk-space-2);
|
|
3247
|
+
gap: 0;
|
|
3248
|
+
}
|
|
3249
|
+
|
|
3250
|
+
[data-look="windows"] .desk-window .desk-control[data-control] {
|
|
3251
|
+
width: 46px;
|
|
3252
|
+
height: auto;
|
|
3253
|
+
border-radius: 0;
|
|
3254
|
+
background: transparent;
|
|
3255
|
+
color: var(--desk-ink);
|
|
3256
|
+
}
|
|
3257
|
+
|
|
3258
|
+
[data-look="windows"] .desk-window .desk-controls .desk-control[data-control]:hover {
|
|
3259
|
+
background: color-mix(in srgb, var(--desk-ink) 8%, transparent);
|
|
3260
|
+
}
|
|
3261
|
+
|
|
3262
|
+
[data-look="windows"] .desk-window .desk-controls .desk-control[data-control="close"]:hover {
|
|
3263
|
+
background: #c42b1c;
|
|
3264
|
+
color: #ffffff;
|
|
3265
|
+
}
|
|
3266
|
+
|
|
3267
|
+
[data-look="windows"] .desk-window .desk-control-glyph {
|
|
3268
|
+
width: 10px;
|
|
3269
|
+
height: 10px;
|
|
3270
|
+
opacity: 1;
|
|
3271
|
+
color: currentColor;
|
|
3272
|
+
stroke-width: 1;
|
|
3273
|
+
stroke-linecap: butt;
|
|
3274
|
+
}
|
|
3275
|
+
|
|
3276
|
+
[data-look="windows"] .desk-window:not([data-focused]) .desk-control-glyph {
|
|
3277
|
+
opacity: .45;
|
|
3278
|
+
}
|
|
3279
|
+
|
|
3280
|
+
[data-look="windows"] .desk-control:focus-visible {
|
|
3281
|
+
outline-offset: -2px;
|
|
3282
|
+
}
|
|
3283
|
+
|
|
3284
|
+
/*
|
|
3285
|
+
* ── GNOME shell: the top bar and the dash are dark in either theme, and so is what opens from them ──
|
|
3286
|
+
* The tokens are redefined on the bar and the dock themselves, so their menus and stacks, which sit
|
|
3287
|
+
* inside them, come out dark too — as the shell's own menus do.
|
|
3288
|
+
*/
|
|
3289
|
+
[data-look="gnome"] .desk-menubar,
|
|
3290
|
+
[data-look="gnome"] .desk-dock {
|
|
3291
|
+
--desk-ink: #ffffff;
|
|
3292
|
+
--desk-muted: rgb(255 255 255 / 68%);
|
|
3293
|
+
--desk-surface: #2a2a2a;
|
|
3294
|
+
--desk-rule: rgb(255 255 255 / 10%);
|
|
3295
|
+
--desk-dock-icon: transparent;
|
|
3296
|
+
}
|
|
3297
|
+
|
|
3298
|
+
[data-look="gnome"] .desk-menubar {
|
|
3299
|
+
height: 32px;
|
|
3300
|
+
--desk-dock-glass: rgb(0 0 0 / 94%);
|
|
3301
|
+
border-bottom: 0;
|
|
3302
|
+
font-weight: 600;
|
|
3303
|
+
}
|
|
3304
|
+
|
|
3305
|
+
[data-look="gnome"] .desk-menubar-title {
|
|
3306
|
+
border-radius: 999px;
|
|
3307
|
+
}
|
|
3308
|
+
|
|
3309
|
+
[data-look="gnome"] .desk-menu {
|
|
3310
|
+
border-radius: 12px;
|
|
3311
|
+
padding: 6px;
|
|
3312
|
+
}
|
|
3313
|
+
|
|
3314
|
+
[data-look="gnome"] .desk-menu-item {
|
|
3315
|
+
border-radius: 6px;
|
|
3316
|
+
font-weight: 400;
|
|
3317
|
+
}
|
|
3318
|
+
|
|
3319
|
+
[data-look="gnome"] .desk-menu-item[data-active],
|
|
3320
|
+
[data-look="windows"] .desk-menu-item[data-active] {
|
|
3321
|
+
background: color-mix(in srgb, var(--desk-ink) 10%, transparent);
|
|
3322
|
+
color: var(--desk-ink);
|
|
3323
|
+
}
|
|
3324
|
+
|
|
3325
|
+
[data-look="gnome"] .desk-dock {
|
|
3326
|
+
--desk-dock-glass: rgb(24 24 24 / 86%);
|
|
3327
|
+
border-radius: 20px;
|
|
3328
|
+
}
|
|
3329
|
+
|
|
3330
|
+
[data-look="gnome"] .desk-dock .desk-dock-item {
|
|
3331
|
+
border: 0;
|
|
3332
|
+
border-radius: 12px;
|
|
3333
|
+
}
|
|
3334
|
+
|
|
3335
|
+
/* No magnification: GNOME's dash lights an item up rather than growing it. */
|
|
3336
|
+
[data-look="gnome"] .desk-dock .desk-dock-item:hover:not(:disabled),
|
|
3337
|
+
[data-look="windows"] .desk-dock .desk-dock-item:hover:not(:disabled) {
|
|
3338
|
+
transform: none;
|
|
3339
|
+
margin: 0;
|
|
3340
|
+
background: color-mix(in srgb, var(--desk-ink) 12%, transparent);
|
|
3341
|
+
}
|
|
3342
|
+
|
|
3343
|
+
/* ── Windows: a flat bar, taskbar tiles, and a pill that widens for the key window ── */
|
|
3344
|
+
|
|
3345
|
+
[data-look="windows"] .desk-menubar {
|
|
3346
|
+
background: var(--desk-surface);
|
|
3347
|
+
backdrop-filter: none;
|
|
3348
|
+
-webkit-backdrop-filter: none;
|
|
3349
|
+
}
|
|
3350
|
+
|
|
3351
|
+
[data-look="windows"] .desk-menubar-title,
|
|
3352
|
+
[data-look="windows"] .desk-menu-item {
|
|
3353
|
+
border-radius: 4px;
|
|
3354
|
+
}
|
|
3355
|
+
|
|
3356
|
+
[data-look="windows"] .desk-menu {
|
|
3357
|
+
border-radius: 8px;
|
|
3358
|
+
padding: 4px;
|
|
3359
|
+
}
|
|
3360
|
+
|
|
3361
|
+
[data-look="windows"] .desk-dock {
|
|
3362
|
+
border-radius: 8px;
|
|
3363
|
+
}
|
|
3364
|
+
|
|
3365
|
+
[data-look="windows"] .desk-dock .desk-dock-item {
|
|
3366
|
+
border: 0;
|
|
3367
|
+
border-radius: 4px;
|
|
3368
|
+
background: transparent;
|
|
3369
|
+
}
|
|
3370
|
+
|
|
3371
|
+
[data-look="windows"] .desk-dock .desk-dock-item[data-running]::after {
|
|
3372
|
+
width: 6px;
|
|
3373
|
+
height: 3px;
|
|
3374
|
+
margin-left: -3px;
|
|
3375
|
+
border-radius: 2px;
|
|
3376
|
+
bottom: -4px;
|
|
3377
|
+
}
|
|
3378
|
+
|
|
3379
|
+
[data-look="windows"] .desk-dock[data-side="bottom"] .desk-dock-item[data-focused]::after {
|
|
3380
|
+
width: 16px;
|
|
3381
|
+
margin-left: -8px;
|
|
3382
|
+
}
|
|
3383
|
+
|
|
3384
|
+
[data-look="windows"] .desk-dock:not([data-side="bottom"]) .desk-dock-item[data-running]::after {
|
|
3385
|
+
width: 3px;
|
|
3386
|
+
height: 6px;
|
|
3387
|
+
margin: -3px 0 0;
|
|
3388
|
+
}
|
|
3389
|
+
|
|
3390
|
+
[data-look="windows"] .desk-dock:not([data-side="bottom"]) .desk-dock-item[data-focused]::after {
|
|
3391
|
+
height: 16px;
|
|
3392
|
+
margin-top: -8px;
|
|
3393
|
+
}
|
package/dist/fx/fx.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type BuiltInSound, type Sound } from './sounds.js';
|
|
2
|
+
export interface FxOptions<Extra extends string> {
|
|
3
|
+
/** Sounds of the app's own, or replacements for the built-ins. */
|
|
4
|
+
readonly sounds?: Readonly<Record<Extra, Sound>>;
|
|
5
|
+
/** Where the mute is kept. Two apps on one origin that should not share a switch need two keys. */
|
|
6
|
+
readonly storageKey?: string;
|
|
7
|
+
/** A second request for the same sound inside this many milliseconds is the same event. */
|
|
8
|
+
readonly coalesceMs?: number;
|
|
9
|
+
/** Master gain over every sound. */
|
|
10
|
+
readonly volume?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface Fx<Name extends string> {
|
|
13
|
+
/** Plays now if it can; whether it did. Silent when muted, repeated, or before any press. */
|
|
14
|
+
play(name: Name, nowMs?: number): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Opens audio on the first press. A browser refuses sound on a page nobody has touched, and a
|
|
17
|
+
* sound arrives unasked, long after the last click: the press has to be taken while it happens.
|
|
18
|
+
* Returns a teardown.
|
|
19
|
+
*/
|
|
20
|
+
unlock(): () => void;
|
|
21
|
+
muted(): boolean;
|
|
22
|
+
setMuted(muted: boolean): void;
|
|
23
|
+
/** Told when the mute changes, here or in another tab. */
|
|
24
|
+
subscribe(listener: () => void): () => void;
|
|
25
|
+
/** Schedules a sound into any context, an offline one included, for measuring. */
|
|
26
|
+
render(ctx: BaseAudioContext, name: Name, out: AudioNode): void;
|
|
27
|
+
}
|
|
28
|
+
export declare function createFx<Extra extends string = never>(options?: FxOptions<Extra>): Fx<BuiltInSound | Extra>;
|
|
29
|
+
//# sourceMappingURL=fx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fx.d.ts","sourceRoot":"","sources":["../../src/fx/fx.ts"],"names":[],"mappings":"AAOA,OAAO,EAAkB,KAAK,YAAY,EAAE,KAAK,KAAK,EAAE,MAAM,aAAa,CAAA;AAE3E,MAAM,WAAW,SAAS,CAAC,KAAK,SAAS,MAAM;IAC7C,kEAAkE;IAClE,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA;IAChD,mGAAmG;IACnG,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,2FAA2F;IAC3F,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,oCAAoC;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,EAAE,CAAC,IAAI,SAAS,MAAM;IACrC,6FAA6F;IAC7F,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACzC;;;;OAIG;IACH,MAAM,IAAI,MAAM,IAAI,CAAA;IACpB,KAAK,IAAI,OAAO,CAAA;IAChB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAA;IAC9B,0DAA0D;IAC1D,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAA;IAC3C,kFAAkF;IAClF,MAAM,CAAC,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,GAAG,IAAI,CAAA;CAChE;AASD,wBAAgB,QAAQ,CAAC,KAAK,SAAS,MAAM,GAAG,KAAK,EACnD,OAAO,GAAE,SAAS,CAAC,KAAK,CAAM,GAC7B,EAAE,CAAC,YAAY,GAAG,KAAK,CAAC,CAkG1B"}
|
package/dist/fx/fx.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
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 } from './sounds.js';
|
|
9
|
+
function audioContextClass() {
|
|
10
|
+
if (typeof window === 'undefined')
|
|
11
|
+
return null;
|
|
12
|
+
return window.AudioContext ?? window.webkitAudioContext ?? null;
|
|
13
|
+
}
|
|
14
|
+
export function createFx(options = {}) {
|
|
15
|
+
const { storageKey = 'desk-fx-muted', coalesceMs = 1500, volume = 0.8 } = options;
|
|
16
|
+
const builtIn = Object.fromEntries(Object.entries(SCORES).map(([name, score]) => [name, scored(score)]));
|
|
17
|
+
const sounds = { ...builtIn, ...options.sounds };
|
|
18
|
+
const lastPlayed = new Map();
|
|
19
|
+
const listeners = new Set();
|
|
20
|
+
let audio = null;
|
|
21
|
+
const context = () => {
|
|
22
|
+
if (audio)
|
|
23
|
+
return audio;
|
|
24
|
+
const Class = audioContextClass();
|
|
25
|
+
if (!Class)
|
|
26
|
+
return null;
|
|
27
|
+
try {
|
|
28
|
+
audio = new Class();
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return audio;
|
|
34
|
+
};
|
|
35
|
+
const muted = () => {
|
|
36
|
+
try {
|
|
37
|
+
return localStorage.getItem(storageKey) === 'yes';
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const render = (ctx, name, out) => {
|
|
44
|
+
const master = ctx.createGain();
|
|
45
|
+
const at = ctx.currentTime + 0.01;
|
|
46
|
+
master.gain.setValueAtTime(volume, at);
|
|
47
|
+
master.connect(out);
|
|
48
|
+
sounds[name](ctx, master, at);
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
play(name, nowMs = Date.now()) {
|
|
52
|
+
if (muted())
|
|
53
|
+
return false;
|
|
54
|
+
const previous = lastPlayed.get(name);
|
|
55
|
+
if (previous !== undefined && nowMs - previous < coalesceMs)
|
|
56
|
+
return false;
|
|
57
|
+
const ctx = context();
|
|
58
|
+
// Never resumed from here: outside a press the promise may never settle, and a sound that
|
|
59
|
+
// lands a click late belongs to the wrong moment.
|
|
60
|
+
if (!ctx || ctx.state !== 'running')
|
|
61
|
+
return false;
|
|
62
|
+
lastPlayed.set(name, nowMs);
|
|
63
|
+
try {
|
|
64
|
+
render(ctx, name, ctx.destination);
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
unlock() {
|
|
72
|
+
if (typeof window === 'undefined')
|
|
73
|
+
return () => undefined;
|
|
74
|
+
const stop = () => {
|
|
75
|
+
window.removeEventListener('pointerdown', open);
|
|
76
|
+
window.removeEventListener('keydown', open);
|
|
77
|
+
};
|
|
78
|
+
function open() {
|
|
79
|
+
stop();
|
|
80
|
+
const ctx = context();
|
|
81
|
+
// Inside the handler, where the browser is willing to listen.
|
|
82
|
+
if (ctx && ctx.state !== 'running')
|
|
83
|
+
void ctx.resume().catch(() => undefined);
|
|
84
|
+
}
|
|
85
|
+
window.addEventListener('pointerdown', open);
|
|
86
|
+
window.addEventListener('keydown', open);
|
|
87
|
+
return stop;
|
|
88
|
+
},
|
|
89
|
+
muted,
|
|
90
|
+
setMuted(next) {
|
|
91
|
+
try {
|
|
92
|
+
if (next)
|
|
93
|
+
localStorage.setItem(storageKey, 'yes');
|
|
94
|
+
else
|
|
95
|
+
localStorage.removeItem(storageKey);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// Blocked site data: sounds stay on, which is the default.
|
|
99
|
+
}
|
|
100
|
+
listeners.forEach((listener) => listener());
|
|
101
|
+
},
|
|
102
|
+
subscribe(listener) {
|
|
103
|
+
listeners.add(listener);
|
|
104
|
+
const fromAnotherTab = (event) => {
|
|
105
|
+
if (event.key === storageKey)
|
|
106
|
+
listener();
|
|
107
|
+
};
|
|
108
|
+
if (typeof window !== 'undefined')
|
|
109
|
+
window.addEventListener('storage', fromAnotherTab);
|
|
110
|
+
return () => {
|
|
111
|
+
listeners.delete(listener);
|
|
112
|
+
if (typeof window !== 'undefined')
|
|
113
|
+
window.removeEventListener('storage', fromAnotherTab);
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
render,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=fx.js.map
|