@liberation-data/desk 0.42.0 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/README.md +312 -5
  2. package/dist/core/hosted.d.ts +222 -0
  3. package/dist/core/hosted.d.ts.map +1 -0
  4. package/dist/core/hosted.js +166 -0
  5. package/dist/core/hosted.js.map +1 -0
  6. package/dist/core/index.d.ts +10 -0
  7. package/dist/core/index.d.ts.map +1 -1
  8. package/dist/core/index.js +5 -0
  9. package/dist/core/index.js.map +1 -1
  10. package/dist/core/location.d.ts +8 -1
  11. package/dist/core/location.d.ts.map +1 -1
  12. package/dist/core/location.js +18 -2
  13. package/dist/core/location.js.map +1 -1
  14. package/dist/core/preferences.d.ts +27 -0
  15. package/dist/core/preferences.d.ts.map +1 -0
  16. package/dist/core/preferences.js +121 -0
  17. package/dist/core/preferences.js.map +1 -0
  18. package/dist/core/scheme.d.ts +18 -0
  19. package/dist/core/scheme.d.ts.map +1 -0
  20. package/dist/core/scheme.js +24 -0
  21. package/dist/core/scheme.js.map +1 -0
  22. package/dist/core/theme.d.ts +41 -0
  23. package/dist/core/theme.d.ts.map +1 -0
  24. package/dist/core/theme.js +56 -0
  25. package/dist/core/theme.js.map +1 -0
  26. package/dist/core/themeChange.d.ts +25 -0
  27. package/dist/core/themeChange.d.ts.map +1 -0
  28. package/dist/core/themeChange.js +49 -0
  29. package/dist/core/themeChange.js.map +1 -0
  30. package/dist/core/types.d.ts +6 -0
  31. package/dist/core/types.d.ts.map +1 -1
  32. package/dist/css/apps.css +183 -0
  33. package/dist/css/overlays.css +6 -0
  34. package/dist/css/shell.css +100 -0
  35. package/dist/css/tokens.css +10 -0
  36. package/dist/css/windows.css +21 -0
  37. package/dist/desk.css +220 -0
  38. package/dist/fx/fx.d.ts.map +1 -1
  39. package/dist/fx/fx.js +7 -31
  40. package/dist/fx/fx.js.map +1 -1
  41. package/dist/host/checkChrome.d.ts +20 -0
  42. package/dist/host/checkChrome.d.ts.map +1 -0
  43. package/dist/host/checkChrome.js +219 -0
  44. package/dist/host/checkChrome.js.map +1 -0
  45. package/dist/host/checkTheme.d.ts +35 -0
  46. package/dist/host/checkTheme.d.ts.map +1 -0
  47. package/dist/host/checkTheme.js +128 -0
  48. package/dist/host/checkTheme.js.map +1 -0
  49. package/dist/host/index.d.ts +7 -0
  50. package/dist/host/index.d.ts.map +1 -0
  51. package/dist/host/index.js +8 -0
  52. package/dist/host/index.js.map +1 -0
  53. package/dist/host/router.d.ts +99 -0
  54. package/dist/host/router.d.ts.map +1 -0
  55. package/dist/host/router.js +279 -0
  56. package/dist/host/router.js.map +1 -0
  57. package/dist/react/Desktop.d.ts.map +1 -1
  58. package/dist/react/Desktop.js +13 -2
  59. package/dist/react/Desktop.js.map +1 -1
  60. package/dist/react/Dock.d.ts +26 -2
  61. package/dist/react/Dock.d.ts.map +1 -1
  62. package/dist/react/Dock.js +23 -27
  63. package/dist/react/Dock.js.map +1 -1
  64. package/dist/react/MenuBar.d.ts +1 -1
  65. package/dist/react/MenuBar.d.ts.map +1 -1
  66. package/dist/react/MenuBar.js +36 -6
  67. package/dist/react/MenuBar.js.map +1 -1
  68. package/dist/react/app.d.ts +215 -0
  69. package/dist/react/app.d.ts.map +1 -0
  70. package/dist/react/app.js +192 -0
  71. package/dist/react/app.js.map +1 -0
  72. package/dist/react/appFrame.d.ts +11 -7
  73. package/dist/react/appFrame.d.ts.map +1 -1
  74. package/dist/react/appFrame.js +24 -6
  75. package/dist/react/appFrame.js.map +1 -1
  76. package/dist/react/appPanels.d.ts +25 -0
  77. package/dist/react/appPanels.d.ts.map +1 -0
  78. package/dist/react/appPanels.js +123 -0
  79. package/dist/react/appPanels.js.map +1 -0
  80. package/dist/react/appearance.d.ts +61 -0
  81. package/dist/react/appearance.d.ts.map +1 -0
  82. package/dist/react/appearance.js +119 -0
  83. package/dist/react/appearance.js.map +1 -0
  84. package/dist/react/codeBlock.d.ts.map +1 -1
  85. package/dist/react/codeBlock.js +6 -60
  86. package/dist/react/codeBlock.js.map +1 -1
  87. package/dist/react/context.d.ts +23 -1
  88. package/dist/react/context.d.ts.map +1 -1
  89. package/dist/react/context.js +108 -5
  90. package/dist/react/context.js.map +1 -1
  91. package/dist/react/copy.d.ts +22 -0
  92. package/dist/react/copy.d.ts.map +1 -0
  93. package/dist/react/copy.js +68 -0
  94. package/dist/react/copy.js.map +1 -0
  95. package/dist/react/dockStatus.d.ts +19 -0
  96. package/dist/react/dockStatus.d.ts.map +1 -0
  97. package/dist/react/dockStatus.js +25 -0
  98. package/dist/react/dockStatus.js.map +1 -0
  99. package/dist/react/documentTitle.d.ts.map +1 -1
  100. package/dist/react/documentTitle.js +4 -1
  101. package/dist/react/documentTitle.js.map +1 -1
  102. package/dist/react/frameMenus.d.ts +28 -0
  103. package/dist/react/frameMenus.d.ts.map +1 -0
  104. package/dist/react/frameMenus.js +85 -0
  105. package/dist/react/frameMenus.js.map +1 -0
  106. package/dist/react/hostApp.d.ts +15 -0
  107. package/dist/react/hostApp.d.ts.map +1 -0
  108. package/dist/react/hostApp.js +77 -0
  109. package/dist/react/hostApp.js.map +1 -0
  110. package/dist/react/hostDock.d.ts +25 -0
  111. package/dist/react/hostDock.d.ts.map +1 -0
  112. package/dist/react/hostDock.js +98 -0
  113. package/dist/react/hostDock.js.map +1 -0
  114. package/dist/react/hostMenu.d.ts +2 -36
  115. package/dist/react/hostMenu.d.ts.map +1 -1
  116. package/dist/react/hostMenu.js.map +1 -1
  117. package/dist/react/hosted.d.ts +28 -0
  118. package/dist/react/hosted.d.ts.map +1 -0
  119. package/dist/react/hosted.js +53 -0
  120. package/dist/react/hosted.js.map +1 -0
  121. package/dist/react/index.d.ts +12 -0
  122. package/dist/react/index.d.ts.map +1 -1
  123. package/dist/react/index.js +8 -0
  124. package/dist/react/index.js.map +1 -1
  125. package/dist/react/layers.d.ts.map +1 -1
  126. package/dist/react/layers.js +7 -2
  127. package/dist/react/layers.js.map +1 -1
  128. package/dist/react/overlays.d.ts.map +1 -1
  129. package/dist/react/overlays.js +29 -12
  130. package/dist/react/overlays.js.map +1 -1
  131. package/dist/react/shell.d.ts +16 -1
  132. package/dist/react/shell.d.ts.map +1 -1
  133. package/dist/react/shell.js +19 -3
  134. package/dist/react/shell.js.map +1 -1
  135. package/dist/react/windowMenus.d.ts +19 -0
  136. package/dist/react/windowMenus.d.ts.map +1 -0
  137. package/dist/react/windowMenus.js +88 -0
  138. package/dist/react/windowMenus.js.map +1 -0
  139. package/dist/shell/HostShell.d.ts +53 -0
  140. package/dist/shell/HostShell.d.ts.map +1 -0
  141. package/dist/shell/HostShell.js +116 -0
  142. package/dist/shell/HostShell.js.map +1 -0
  143. package/dist/shell/index.d.ts +7 -0
  144. package/dist/shell/index.d.ts.map +1 -0
  145. package/dist/shell/index.js +9 -0
  146. package/dist/shell/index.js.map +1 -0
  147. package/dist/shell/keys.d.ts +47 -0
  148. package/dist/shell/keys.d.ts.map +1 -0
  149. package/dist/shell/keys.js +68 -0
  150. package/dist/shell/keys.js.map +1 -0
  151. package/dist/shell/motion.d.ts +72 -0
  152. package/dist/shell/motion.d.ts.map +1 -0
  153. package/dist/shell/motion.js +118 -0
  154. package/dist/shell/motion.js.map +1 -0
  155. package/llms.txt +84 -9
  156. package/package.json +10 -1
  157. package/src/core/hosted.ts +351 -0
  158. package/src/core/index.ts +29 -0
  159. package/src/core/location.ts +23 -3
  160. package/src/core/preferences.ts +132 -0
  161. package/src/core/scheme.ts +32 -0
  162. package/src/core/theme.ts +91 -0
  163. package/src/core/themeChange.ts +59 -0
  164. package/src/core/types.ts +6 -0
  165. package/src/css/apps.css +183 -0
  166. package/src/css/overlays.css +6 -0
  167. package/src/css/shell.css +99 -0
  168. package/src/css/tokens.css +10 -0
  169. package/src/css/windows.css +21 -0
  170. package/src/fx/fx.ts +7 -25
  171. package/src/host/checkChrome.ts +257 -0
  172. package/src/host/checkTheme.ts +134 -0
  173. package/src/host/index.ts +10 -0
  174. package/src/host/router.ts +374 -0
  175. package/src/react/Desktop.tsx +21 -3
  176. package/src/react/Dock.tsx +40 -24
  177. package/src/react/MenuBar.tsx +39 -6
  178. package/src/react/app.tsx +354 -0
  179. package/src/react/appFrame.tsx +39 -14
  180. package/src/react/appPanels.tsx +210 -0
  181. package/src/react/appearance.tsx +195 -0
  182. package/src/react/codeBlock.tsx +7 -65
  183. package/src/react/context.tsx +131 -4
  184. package/src/react/copy.ts +81 -0
  185. package/src/react/dockStatus.ts +42 -0
  186. package/src/react/documentTitle.ts +4 -1
  187. package/src/react/frameMenus.ts +100 -0
  188. package/src/react/hostApp.tsx +89 -0
  189. package/src/react/hostDock.tsx +118 -0
  190. package/src/react/hostMenu.ts +3 -38
  191. package/src/react/hosted.tsx +65 -0
  192. package/src/react/index.ts +34 -0
  193. package/src/react/layers.ts +7 -2
  194. package/src/react/overlays.tsx +30 -12
  195. package/src/react/shell.tsx +33 -3
  196. package/src/react/windowMenus.ts +107 -0
  197. package/src/shell/HostShell.tsx +220 -0
  198. package/src/shell/index.ts +11 -0
  199. package/src/shell/keys.ts +101 -0
  200. package/src/shell/motion.ts +163 -0
@@ -0,0 +1,91 @@
1
+ import type { Look } from './look.js'
2
+ import { themeChanged, watchThemeChanges } from './themeChange.js'
3
+
4
+ /*
5
+ * A LOOK ONE APP LENDS TO OTHERS.
6
+ *
7
+ * Some apps run inside something else: a framed page on the desk, or a whole Desk app hosted beside
8
+ * others under one menu bar. Either way the person chose one look for the whole thing, so the app
9
+ * inside should wear it, not whatever its author hard-coded.
10
+ *
11
+ * The theme travels as data. Its tokens are custom properties set on the receiving page's root, so
12
+ * CSS that reads them follows with nothing written. Because the theme restyles somebody else's page,
13
+ * it is checked before it is passed on (`checkTheme`): a value that could load something, or hide
14
+ * part of the page behind an image from elsewhere, never crosses.
15
+ */
16
+
17
+ /** A page's palette, as a framed app gets it: which way round it is, and custom properties to set. */
18
+ export interface AppTheme {
19
+ readonly mode: 'light' | 'dark'
20
+ /** Custom properties, named as they will be set: `{ '--desk-accent': '#3478f6' }`. */
21
+ readonly tokens: Readonly<Record<string, string>>
22
+ }
23
+
24
+ /** A font the theme uses, for a page on another origin to load. */
25
+ export interface ThemeFont {
26
+ readonly family: string
27
+ /** A URL on the publisher's own origin, or a `data:` URI. */
28
+ readonly src: string
29
+ readonly weight?: string
30
+ readonly style?: 'normal' | 'italic'
31
+ }
32
+
33
+ /** A whole desk's look: an `AppTheme`, plus the platform chrome, its fonts and its wallpaper. */
34
+ export interface DeskTheme extends AppTheme {
35
+ readonly look: Look
36
+ readonly fonts?: readonly ThemeFont[]
37
+ /** A colour or gradient; or an image: a URL or path on the publisher's origin, or a `data:` image. */
38
+ readonly wallpaper?: string
39
+ }
40
+
41
+ /**
42
+ * A wallpaper that names an image, rather than being a colour or gradient: a `data:` URI, a URL on any
43
+ * scheme with a host (an Electron app's `app://` too), or a path.
44
+ */
45
+ export const isImageRef = (wallpaper: string): boolean => /^(data:|[a-z][\w+.-]*:\/\/|\/)/i.test(wallpaper)
46
+
47
+ /**
48
+ * The part of a theme every hosted app wears whatever else it does: light or dark, and the
49
+ * platform chrome. One desktop light and the next dark would look broken as they slide past each
50
+ * other, so these are not the app's to decline.
51
+ */
52
+ export function applyThemeBasics(theme: Pick<DeskTheme, 'mode' | 'look'>, root: HTMLElement = document.documentElement): void {
53
+ watchThemeChanges(root.ownerDocument)
54
+ root.dataset.theme = theme.mode
55
+ root.dataset.look = theme.look
56
+ root.style.colorScheme = theme.mode
57
+ }
58
+
59
+ const applied = new WeakMap<HTMLElement, { tokens: readonly string[]; fonts: FontFace[] }>()
60
+
61
+ /**
62
+ * Wears a whole theme: the basics, every token on the root, its fonts, and its wallpaper as
63
+ * `--desk-wallpaper`. Tokens a previous theme set and this one does not are removed, so switching
64
+ * back and forth leaves nothing behind. The default way a hosted app takes the theme it is sent.
65
+ * New colours under the same scheme and look still fire `desk-themechange`, for a canvas to repaint.
66
+ */
67
+ export function applyTheme(theme: DeskTheme, root: HTMLElement = document.documentElement): void {
68
+ const was = root.style.cssText
69
+ applyThemeBasics(theme, root)
70
+ const before = applied.get(root)
71
+ for (const name of before?.tokens ?? []) if (!(name in theme.tokens)) root.style.removeProperty(name)
72
+ for (const [name, value] of Object.entries(theme.tokens)) root.style.setProperty(name, value)
73
+ if (theme.wallpaper === undefined) root.style.removeProperty('--desk-wallpaper')
74
+ else root.style.setProperty('--desk-wallpaper', isImageRef(theme.wallpaper) ? `url(${JSON.stringify(theme.wallpaper)})` : theme.wallpaper)
75
+
76
+ const fonts = root.ownerDocument.fonts as FontFaceSet | undefined
77
+ for (const face of before?.fonts ?? []) fonts?.delete(face)
78
+ const faces: FontFace[] = []
79
+ if (fonts && typeof FontFace !== 'undefined') {
80
+ for (const font of theme.fonts ?? []) {
81
+ const face = new FontFace(font.family, `url(${JSON.stringify(font.src)})`, {
82
+ ...(font.weight === undefined ? {} : { weight: font.weight }),
83
+ ...(font.style === undefined ? {} : { style: font.style }),
84
+ })
85
+ fonts.add(face)
86
+ faces.push(face)
87
+ }
88
+ }
89
+ applied.set(root, { tokens: Object.keys(theme.tokens), fonts: faces })
90
+ if (root.style.cssText !== was) themeChanged(root.ownerDocument)
91
+ }
@@ -0,0 +1,59 @@
1
+ import type { Look } from './look.js'
2
+
3
+ /*
4
+ * ONE EVENT FOR EVERY CHANGE TO WHAT IS DRAWN, FOR CODE OUTSIDE REACT.
5
+ *
6
+ * Code that draws its own pixels (a canvas) must repaint when the colours change. Every source of a
7
+ * change ends on the root: a host's theme and the person's choice stamp `data-theme`, a look stamps
8
+ * `data-look`, and with neither the system's scheme shows through the stylesheet's media query. So one
9
+ * watcher of those, not a dispatch from each path, sees them all, and fires only when the scheme or
10
+ * look actually drawn has changed. The one change the root's attributes don't show is a host's theme
11
+ * with new colours under the same scheme and look, so `applyTheme` says so itself (`themeChanged`).
12
+ */
13
+
14
+ /** The event's name, on `document`. */
15
+ export const THEME_CHANGE = 'desk-themechange'
16
+
17
+ /** What a `desk-themechange` carries: the scheme and look now drawn. */
18
+ export interface ThemeChange {
19
+ readonly scheme: 'light' | 'dark'
20
+ readonly look: Look
21
+ }
22
+
23
+ const checks = new WeakMap<Document, (always?: boolean) => void>()
24
+
25
+ /**
26
+ * The scheme and look drawn now, read as the stylesheet reads them: `data-theme` when it is light or dark,
27
+ * else the system's; `data-look`, else `mac`, which is what desk.css draws without one.
28
+ */
29
+ export function drawnTheme(doc: Document = document): ThemeChange {
30
+ const root = doc.documentElement
31
+ const set = root.dataset.theme
32
+ const scheme = set === 'light' || set === 'dark' ? set : globalThis.matchMedia?.('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
33
+ return { scheme, look: (root.dataset.look as Look | undefined) ?? 'mac' }
34
+ }
35
+
36
+ /**
37
+ * Starts firing `desk-themechange` on `doc` whenever the drawn scheme or look changes, once per change.
38
+ * Desk starts it when a desk mounts or a theme is applied; calling it again does nothing.
39
+ */
40
+ export function watchThemeChanges(doc: Document = document): void {
41
+ if (checks.has(doc) || typeof MutationObserver === 'undefined') return
42
+ let last = drawnTheme(doc)
43
+ const check = (always?: boolean) => {
44
+ const now = drawnTheme(doc)
45
+ if (!always && now.scheme === last.scheme && now.look === last.look) return
46
+ last = now
47
+ doc.dispatchEvent(new CustomEvent<ThemeChange>(THEME_CHANGE, { detail: now }))
48
+ }
49
+ checks.set(doc, check)
50
+ new MutationObserver(() => check()).observe(doc.documentElement, { attributes: true, attributeFilter: ['data-theme', 'data-look'] })
51
+ globalThis.matchMedia?.('(prefers-color-scheme: dark)').addEventListener?.('change', () => check())
52
+ }
53
+
54
+ /**
55
+ * Fires `desk-themechange` now, if `doc` is watched, though the scheme and look are unchanged: for new
56
+ * colours the root's attributes don't show. Synchronous, so the observer's later look finds nothing new
57
+ * and a theme that also changed the scheme is still one event.
58
+ */
59
+ export const themeChanged = (doc: Document = document): void => checks.get(doc)?.(true)
package/src/core/types.ts CHANGED
@@ -72,4 +72,10 @@ export interface WindowLimits {
72
72
  readonly minHeight?: number
73
73
  readonly maxWidth?: number
74
74
  readonly maxHeight?: number
75
+ /**
76
+ * As tall as its content, up to `maxHeight`, while it sits centred: a short form is not a tall window with
77
+ * room to spare under it. Taller content scrolls inside it as usual. A window dragged or resized free takes
78
+ * the height it is given.
79
+ */
80
+ readonly fitContent?: boolean
75
81
  }
package/src/css/apps.css CHANGED
@@ -54,3 +54,186 @@
54
54
  border: 0;
55
55
  background: var(--desk-surface);
56
56
  }
57
+
58
+ /* ── About and Settings, from what the app declares ── */
59
+
60
+ .desk-about-body {
61
+ display: flex;
62
+ flex-direction: column;
63
+ gap: var(--desk-space-4);
64
+ }
65
+
66
+ .desk-about-brand {
67
+ display: flex;
68
+ flex-direction: column;
69
+ align-items: center;
70
+ gap: var(--desk-space-1);
71
+ text-align: center;
72
+ }
73
+
74
+ .desk-about-icon {
75
+ display: grid;
76
+ place-items: center;
77
+ width: 96px;
78
+ height: 96px;
79
+ margin-bottom: var(--desk-space-2);
80
+ }
81
+
82
+ .desk-about-icon > svg,
83
+ .desk-about-icon > img {
84
+ width: 100%;
85
+ height: 100%;
86
+ }
87
+
88
+ .desk-about-name {
89
+ margin: 0;
90
+ font-size: var(--desk-text-display);
91
+ font-weight: 600;
92
+ }
93
+
94
+ /* A wordmark: as wide as it is drawn, up to the panel, at a heading's height. The name stays, for screen readers. */
95
+ .desk-about-wordmark {
96
+ display: grid;
97
+ place-items: center;
98
+ max-width: 100%;
99
+ height: 40px;
100
+ }
101
+
102
+ .desk-about-wordmark > svg,
103
+ .desk-about-wordmark > img {
104
+ height: 100%;
105
+ width: auto;
106
+ max-width: 100%;
107
+ }
108
+
109
+ .desk-about-name-hidden {
110
+ position: absolute;
111
+ width: 1px;
112
+ height: 1px;
113
+ overflow: hidden;
114
+ clip-path: inset(50%);
115
+ white-space: nowrap;
116
+ }
117
+
118
+ .desk-about-version,
119
+ .desk-about-description {
120
+ margin: 0;
121
+ }
122
+
123
+ .desk-about-links {
124
+ display: flex;
125
+ flex-wrap: wrap;
126
+ justify-content: center;
127
+ gap: var(--desk-space-2) var(--desk-space-4);
128
+ }
129
+
130
+ /* The app's links, and a fact's: one colour for every link on the panel. */
131
+ .desk-about-links a,
132
+ .desk-about-fact-note a {
133
+ color: var(--desk-accent);
134
+ }
135
+
136
+ /* A group's heading takes a line of its own above its links. */
137
+ .desk-about-links-heading {
138
+ flex-basis: 100%;
139
+ margin: 0;
140
+ text-align: center;
141
+ font-weight: 500;
142
+ }
143
+
144
+ /*
145
+ * Name and value in two columns; a note sits under its value. Every section shares one grid, through
146
+ * subgrid, so the names are one column down the whole panel, as wide as the longest of them.
147
+ */
148
+ .desk-about-sections {
149
+ display: grid;
150
+ grid-template-columns: max-content minmax(0, 1fr);
151
+ column-gap: var(--desk-space-3);
152
+ row-gap: var(--desk-space-4);
153
+ }
154
+
155
+ .desk-about-sections > section {
156
+ grid-column: 1 / -1;
157
+ display: grid;
158
+ grid-template-columns: subgrid;
159
+ /* normal: the panel's column gap, so a section's own gap does not shift its values off the column. */
160
+ column-gap: normal;
161
+ row-gap: var(--desk-space-2);
162
+ }
163
+
164
+ .desk-about-sections > section > * {
165
+ grid-column: 1 / -1;
166
+ }
167
+
168
+ .desk-about-facts {
169
+ display: grid;
170
+ grid-template-columns: subgrid;
171
+ column-gap: normal;
172
+ row-gap: var(--desk-space-1);
173
+ margin: 0;
174
+ }
175
+
176
+ /* A browser without subgrid: each section is its own grid, and a floor under the names keeps them close. */
177
+ @supports not (grid-template-columns: subgrid) {
178
+ .desk-about-facts {
179
+ grid-template-columns: max-content minmax(0, 1fr);
180
+ column-gap: var(--desk-space-3);
181
+ }
182
+
183
+ .desk-about-facts dt {
184
+ min-width: 9rem;
185
+ }
186
+ }
187
+
188
+ .desk-about-facts > div {
189
+ display: contents;
190
+ }
191
+
192
+ .desk-about-facts dt {
193
+ color: var(--desk-muted);
194
+ }
195
+
196
+ .desk-about-facts dd {
197
+ margin: 0;
198
+ overflow-wrap: anywhere;
199
+ user-select: text;
200
+ }
201
+
202
+ .desk-about-fact-note {
203
+ display: block;
204
+ }
205
+
206
+ .desk-about-note {
207
+ margin: 0;
208
+ text-align: center;
209
+ }
210
+
211
+ .desk-about-legal {
212
+ margin: 0;
213
+ text-align: center;
214
+ }
215
+
216
+ .desk-about-foot {
217
+ display: flex;
218
+ align-items: center;
219
+ gap: var(--desk-space-3);
220
+ padding: var(--desk-space-3) var(--desk-space-4);
221
+ border-top: 1px solid var(--desk-rule);
222
+ }
223
+
224
+ /* What Copy copies, out of sight: selected in place of the panel where there is no clipboard. */
225
+ .desk-about-copied {
226
+ position: absolute;
227
+ width: 1px;
228
+ height: 1px;
229
+ margin: -1px;
230
+ overflow: hidden;
231
+ clip-path: inset(50%);
232
+ white-space: pre;
233
+ }
234
+
235
+ .desk-settings-page {
236
+ display: flex;
237
+ flex-direction: column;
238
+ gap: var(--desk-space-5);
239
+ }
@@ -20,6 +20,12 @@
20
20
  background: var(--desk-surface);
21
21
  box-shadow: var(--desk-shadow-floating);
22
22
  animation: desk-menu-in .14s var(--desk-ease);
23
+ overscroll-behavior: contain;
24
+ }
25
+
26
+ /* Focused only so its keys scroll it (see Popover); the open dialog is its own sign of where focus is. */
27
+ .desk-popover:focus {
28
+ outline: none;
23
29
  }
24
30
 
25
31
  /* A sheet belongs to its window: the scrim covers that window and nothing else. */
@@ -0,0 +1,99 @@
1
+ /*
2
+ * The shell of a host running several Desk apps: one dock and one switcher around their views. Not part
3
+ * of desk.css, since no app draws it: the host's page imports `@liberation-data/desk/css/shell.css`
4
+ * after desk.css.
5
+ */
6
+
7
+ .desk-shell {
8
+ position: fixed;
9
+ inset: 0;
10
+ font-family: var(--desk-font);
11
+ color: var(--desk-ink);
12
+ background: var(--desk-ground);
13
+ }
14
+
15
+ .desk-shell-bar {
16
+ display: flex;
17
+ justify-content: center;
18
+ align-items: center;
19
+ padding: var(--desk-space-2) var(--desk-space-3);
20
+ border-bottom: 1px solid var(--desk-rule);
21
+ background: var(--desk-titlebar);
22
+ }
23
+
24
+ .desk-shell-switcher {
25
+ display: flex;
26
+ gap: var(--desk-space-1);
27
+ }
28
+
29
+ .desk-shell-workspace {
30
+ display: inline-flex;
31
+ align-items: center;
32
+ gap: var(--desk-space-2);
33
+ padding: var(--desk-space-1) var(--desk-space-3);
34
+ border: 1px solid transparent;
35
+ border-radius: 999px;
36
+ background: none;
37
+ color: var(--desk-muted);
38
+ font: inherit;
39
+ font-size: var(--desk-text-small);
40
+ cursor: default;
41
+ }
42
+
43
+ .desk-shell-workspace:hover {
44
+ color: var(--desk-ink);
45
+ }
46
+
47
+ .desk-shell-workspace[aria-current="true"] {
48
+ border-color: var(--desk-rule);
49
+ background: var(--desk-surface);
50
+ color: var(--desk-ink);
51
+ }
52
+
53
+ .desk-shell-workspace:focus-visible {
54
+ outline: 2px solid var(--desk-accent);
55
+ outline-offset: 2px;
56
+ }
57
+
58
+ .desk-shell-workspace img,
59
+ .desk-shell-mark {
60
+ width: 14px;
61
+ height: 14px;
62
+ border-radius: 4px;
63
+ flex: none;
64
+ }
65
+
66
+ .desk-shell-mark {
67
+ background: var(--desk-accent);
68
+ }
69
+
70
+ /* Asleep or closed: there, and a visit away, but not running. */
71
+ .desk-shell-workspace:not([data-state="live"]) span {
72
+ opacity: 0.7;
73
+ }
74
+
75
+ .desk-shell-initial {
76
+ display: grid;
77
+ place-items: center;
78
+ width: 100%;
79
+ height: 100%;
80
+ font-weight: 600;
81
+ font-size: var(--desk-text-lead);
82
+ }
83
+
84
+ .desk-shell-dot {
85
+ display: inline-block;
86
+ width: 8px;
87
+ height: 8px;
88
+ border-radius: 50%;
89
+ background: currentcolor;
90
+ }
91
+
92
+ .desk-shell-announce {
93
+ position: absolute;
94
+ width: 1px;
95
+ height: 1px;
96
+ overflow: hidden;
97
+ clip-path: inset(50%);
98
+ white-space: nowrap;
99
+ }
@@ -87,6 +87,12 @@
87
87
  --desk-widget-width: 200px;
88
88
  /* Room the stage leaves at the bottom for something of the app's own. An overlay dock makes its own. */
89
89
  --desk-inset-bottom: 0px;
90
+ /* An overview of workspaces: tiles over a radial haze from fog to its far edge, in the theme's own
91
+ colours. The ground with a trace of the accent, moved toward mid grey so it reads as haze rather
92
+ than as the desktop; the far edge darker; the tiles' shadow a tint, not a box-shadow. */
93
+ --desk-overview-fog: color-mix(in oklab, color-mix(in oklab, var(--desk-ground) 82%, var(--desk-accent) 18%) 88%, #808080);
94
+ --desk-overview-fog-far: color-mix(in oklab, var(--desk-overview-fog) 92%, #000);
95
+ --desk-overview-shadow: rgb(0 0 0 / 0.28);
90
96
  }
91
97
 
92
98
  @media (prefers-color-scheme: dark) {
@@ -118,6 +124,8 @@
118
124
  --desk-code-keyword: #d2a8ff;
119
125
  --desk-code-number: #ffab70;
120
126
  --desk-code-key: #7cc4ff;
127
+ --desk-overview-fog-far: color-mix(in oklab, var(--desk-overview-fog) 90%, #000);
128
+ --desk-overview-shadow: rgb(0 0 0 / 0.55);
121
129
  }
122
130
  }
123
131
 
@@ -149,4 +157,6 @@
149
157
  --desk-code-keyword: #d2a8ff;
150
158
  --desk-code-number: #ffab70;
151
159
  --desk-code-key: #7cc4ff;
160
+ --desk-overview-fog-far: color-mix(in oklab, var(--desk-overview-fog) 90%, #000);
161
+ --desk-overview-shadow: rgb(0 0 0 / 0.55);
152
162
  }
@@ -746,6 +746,27 @@ button.desk-widget:hover {
746
746
  overflow: hidden;
747
747
  }
748
748
 
749
+ /*
750
+ * A centred window that fits its content (`fitContent`) is as tall as what is in it, up to its max-height.
751
+ * Its height comes from its content rather than the content from its height, so a pane in it is not 100% of
752
+ * anything: it takes its own height and gives way, with the middle scrolling, once the window is at its cap.
753
+ */
754
+ .desk-window[data-fit] {
755
+ height: fit-content;
756
+ }
757
+
758
+ .desk-window[data-fit] > .desk-body {
759
+ flex: 0 1 auto;
760
+ display: flex;
761
+ flex-direction: column;
762
+ }
763
+
764
+ .desk-window[data-fit] > .desk-body > * {
765
+ flex: 0 1 auto;
766
+ height: auto;
767
+ min-height: 0;
768
+ }
769
+
749
770
  .desk-toolbar {
750
771
  display: flex;
751
772
  align-items: center;
package/src/fx/fx.ts CHANGED
@@ -3,8 +3,9 @@
3
3
  *
4
4
  * WHEN to make one is the app's decision and the hard part; see HIG.md, "Sound". This is the
5
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.
6
+ * short window heard once, and a mute the preference store remembers (this browser's localStorage unless the app gives its own).
7
7
  */
8
+ import { getPreference, setPreference, subscribePreferences } from '../core/preferences.js'
8
9
  import { SCORES, scored, type BuiltInSound, type Sound } from './sounds.js'
9
10
 
10
11
  export interface FxOptions<Extra extends string> {
@@ -50,7 +51,6 @@ export function createFx<Extra extends string = never>(
50
51
  const builtIn = Object.fromEntries(Object.entries(SCORES).map(([name, score]) => [name, scored(score)]))
51
52
  const sounds = { ...builtIn, ...options.sounds } as Record<Name, Sound>
52
53
  const lastPlayed = new Map<string, number>()
53
- const listeners = new Set<() => void>()
54
54
  let audio: AudioContext | null = null
55
55
 
56
56
  const context = (): AudioContext | null => {
@@ -65,13 +65,7 @@ export function createFx<Extra extends string = never>(
65
65
  return audio
66
66
  }
67
67
 
68
- const muted = (): boolean => {
69
- try {
70
- return localStorage.getItem(storageKey) === 'yes'
71
- } catch {
72
- return false
73
- }
74
- }
68
+ const muted = (): boolean => getPreference(storageKey) === 'yes'
75
69
 
76
70
  const render = (ctx: BaseAudioContext, name: Name, out: AudioNode): void => {
77
71
  const master = ctx.createGain()
@@ -119,25 +113,13 @@ export function createFx<Extra extends string = never>(
119
113
  muted,
120
114
 
121
115
  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())
116
+ setPreference(storageKey, next ? 'yes' : null)
129
117
  },
130
118
 
131
119
  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
- }
120
+ return subscribePreferences(key => {
121
+ if (key === null || key === storageKey) listener()
122
+ })
141
123
  },
142
124
 
143
125
  render,