@liberation-data/desk 0.21.1 → 0.22.1

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.
@@ -92,7 +92,7 @@
92
92
  .desk-sheet-title,
93
93
  .desk-alert-title {
94
94
  margin: 0 0 var(--desk-space-1);
95
- font-size: 15px;
95
+ font-size: var(--desk-text-lead);
96
96
  font-weight: 600;
97
97
  }
98
98
 
@@ -100,7 +100,7 @@
100
100
  .desk-alert-message {
101
101
  margin: 0 0 var(--desk-space-3);
102
102
  color: var(--desk-muted);
103
- font-size: 13px;
103
+ font-size: var(--desk-text-body);
104
104
  line-height: 1.5;
105
105
  }
106
106
 
@@ -137,7 +137,7 @@
137
137
  background: var(--desk-surface);
138
138
  box-shadow: var(--desk-shadow-floating);
139
139
  font-family: var(--desk-font);
140
- font-size: 13px;
140
+ font-size: var(--desk-text-body);
141
141
  animation: desk-toast-in .2s var(--desk-ease);
142
142
  }
143
143
 
@@ -190,7 +190,7 @@
190
190
  background: color-mix(in srgb, var(--desk-info) 14%, transparent);
191
191
  color: var(--desk-info);
192
192
  font-family: var(--desk-font);
193
- font-size: 11px;
193
+ font-size: var(--desk-text-caption);
194
194
  font-style: italic;
195
195
  font-weight: 700;
196
196
  line-height: 1;
@@ -210,7 +210,7 @@
210
210
 
211
211
  .desk-infotip-body {
212
212
  max-width: 34ch;
213
- font-size: 12.5px;
213
+ font-size: var(--desk-text-small);
214
214
  line-height: 1.45;
215
215
  color: var(--desk-muted);
216
216
  }
@@ -39,7 +39,7 @@
39
39
  background: none;
40
40
  color: var(--desk-ink);
41
41
  font-family: var(--desk-font);
42
- font-size: 17px;
42
+ font-size: var(--desk-text-title);
43
43
  outline: none;
44
44
  }
45
45
 
@@ -59,7 +59,7 @@
59
59
  .desk-search-group {
60
60
  margin: var(--desk-space-2) 0 2px;
61
61
  padding: 0 var(--desk-space-2);
62
- font-size: 11px;
62
+ font-size: var(--desk-text-caption);
63
63
  font-weight: 700;
64
64
  letter-spacing: .08em;
65
65
  text-transform: uppercase;
@@ -107,13 +107,13 @@
107
107
 
108
108
  .desk-search-title {
109
109
  display: block;
110
- font-size: 13.5px;
110
+ font-size: var(--desk-text-body);
111
111
  font-weight: 500;
112
112
  }
113
113
 
114
114
  .desk-search-subtitle,
115
115
  .desk-search-kind {
116
- font-size: 11.5px;
116
+ font-size: var(--desk-text-caption);
117
117
  color: var(--desk-muted);
118
118
  }
119
119
 
@@ -124,7 +124,7 @@
124
124
  .desk-search-kind {
125
125
  flex: none;
126
126
  font-family: var(--desk-font-mono);
127
- font-size: 10.5px;
127
+ font-size: var(--desk-text-caption);
128
128
  }
129
129
 
130
130
  .desk-search-row[data-active] .desk-search-subtitle,
@@ -137,7 +137,7 @@
137
137
  padding: var(--desk-space-5) var(--desk-space-4);
138
138
  text-align: center;
139
139
  color: var(--desk-muted);
140
- font-size: 13px;
140
+ font-size: var(--desk-text-body);
141
141
  }
142
142
 
143
143
  @media (prefers-reduced-motion: reduce) {
package/src/css/setup.css CHANGED
@@ -18,12 +18,12 @@
18
18
  display: flex;
19
19
  align-items: center;
20
20
  gap: var(--desk-space-2);
21
- font-size: 13px;
21
+ font-size: var(--desk-text-body);
22
22
  }
23
23
 
24
24
  .desk-tour-count {
25
25
  color: var(--desk-muted);
26
- font-size: 11.5px;
26
+ font-size: var(--desk-text-caption);
27
27
  font-variant-numeric: tabular-nums;
28
28
  }
29
29
 
@@ -48,7 +48,7 @@
48
48
 
49
49
  .desk-tour-caption {
50
50
  margin: 0 0 var(--desk-space-2);
51
- font-size: 13.5px;
51
+ font-size: var(--desk-text-body);
52
52
  line-height: 1.45;
53
53
  }
54
54
 
@@ -181,7 +181,7 @@
181
181
 
182
182
  .desk-wizard-title {
183
183
  margin: 0;
184
- font-size: 22px;
184
+ font-size: var(--desk-text-display);
185
185
  font-weight: 700;
186
186
  letter-spacing: -.02em;
187
187
  text-wrap: balance;
@@ -195,7 +195,7 @@
195
195
  margin: 0 0 var(--desk-space-4);
196
196
  max-width: 46ch;
197
197
  color: var(--desk-muted);
198
- font-size: 13.5px;
198
+ font-size: var(--desk-text-body);
199
199
  line-height: 1.5;
200
200
  text-wrap: pretty;
201
201
  }
@@ -213,7 +213,7 @@
213
213
  border-radius: var(--desk-control-radius);
214
214
  background: color-mix(in srgb, var(--desk-bad) 14%, transparent);
215
215
  color: var(--desk-ink);
216
- font-size: 13px;
216
+ font-size: var(--desk-text-body);
217
217
  }
218
218
 
219
219
  .desk-wizard-foot {
@@ -263,7 +263,7 @@
263
263
  }
264
264
 
265
265
  .desk-wizard-step-name {
266
- font-size: 11.5px;
266
+ font-size: var(--desk-text-small);
267
267
  color: var(--desk-muted);
268
268
  }
269
269
 
@@ -152,7 +152,7 @@
152
152
  overflow: hidden;
153
153
  text-overflow: ellipsis;
154
154
  white-space: nowrap;
155
- font-size: 13px;
155
+ font-size: var(--desk-text-body);
156
156
  font-weight: 600;
157
157
  }
158
158
 
@@ -169,7 +169,7 @@
169
169
  overflow: hidden;
170
170
  text-overflow: ellipsis;
171
171
  white-space: nowrap;
172
- font-size: 11.5px;
172
+ font-size: var(--desk-text-small);
173
173
  color: var(--desk-muted);
174
174
  }
175
175
 
@@ -205,7 +205,7 @@
205
205
  display: flex;
206
206
  align-items: center;
207
207
  gap: var(--desk-space-2);
208
- font-size: 11.5px;
208
+ font-size: var(--desk-text-small);
209
209
  font-variant-numeric: tabular-nums;
210
210
  color: var(--desk-muted);
211
211
  pointer-events: none;
@@ -288,7 +288,7 @@
288
288
  padding: var(--desk-space-4);
289
289
  text-align: center;
290
290
  color: var(--desk-muted);
291
- font-size: 13px;
291
+ font-size: var(--desk-text-body);
292
292
  }
293
293
 
294
294
  .desk-window-status b {
@@ -298,7 +298,7 @@
298
298
 
299
299
  .desk-window-status-detail {
300
300
  max-width: 40ch;
301
- font-size: 12px;
301
+ font-size: var(--desk-text-small);
302
302
  }
303
303
 
304
304
  /* Edges a window resizes from. Inside the window, so nothing clips them. */
@@ -1,4 +1,4 @@
1
- import { useEffect, useId, useRef, useState } from 'react'
1
+ import { useEffect, useId, useLayoutEffect, useRef, useState } from 'react'
2
2
  import type { KeyboardEvent, ReactNode } from 'react'
3
3
  import { focusedId, instancesOf, isMinimized, windowType } from '../core/desk.js'
4
4
  import type { DeskState, WindowId } from '../core/types.js'
@@ -247,6 +247,26 @@ function stackBadge(items: readonly DockItem[]): ReactNode | null {
247
247
  return (numbers as number[]).reduce((total, n) => total + n, 0)
248
248
  }
249
249
 
250
+ const VIEW_MARGIN = 12
251
+
252
+ /**
253
+ * How far a panel must move to sit VIEW_MARGIN inside the viewport, as a CSS `translate`. Measured
254
+ * from its centre and untransformed size, so the opening animation's scale does not skew it.
255
+ */
256
+ function fitInView(el: HTMLElement): string {
257
+ const rect = el.getBoundingClientRect()
258
+ if (rect.width === 0) return ''
259
+ const shift = (centre: number, size: number, room: number) => {
260
+ const start = centre - size / 2
261
+ const over = start + size - (room - VIEW_MARGIN)
262
+ // Too big to fit is left to max-height: never push its start off screen to make room for its end.
263
+ return over > 0 ? -Math.min(over, Math.max(0, start - VIEW_MARGIN)) : Math.max(0, VIEW_MARGIN - start)
264
+ }
265
+ const x = shift(rect.left + rect.width / 2, el.offsetWidth, window.innerWidth)
266
+ const y = shift(rect.top + rect.height / 2, el.offsetHeight, window.innerHeight)
267
+ return x === 0 && y === 0 ? '' : `${x}px ${y}px`
268
+ }
269
+
250
270
  function StackButton({ stack, tabIndex, open, setOpenStack }: StackButtonProps) {
251
271
  const desk = useDesk()
252
272
  const state = useDeskState()
@@ -267,6 +287,11 @@ function StackButton({ stack, tabIndex, open, setOpenStack }: StackButtonProps)
267
287
  return () => document.removeEventListener('pointerdown', onPointerDown)
268
288
  }, [open, setOpenStack])
269
289
 
290
+ // Anchored to its slot, a stack from a low item would open past the bottom of the screen.
291
+ useLayoutEffect(() => {
292
+ if (open && panel.current) panel.current.style.translate = fitInView(panel.current)
293
+ }, [open])
294
+
270
295
  const close = () => {
271
296
  onOpenChange(false)
272
297
  button.current?.focus()
@@ -339,7 +339,7 @@ export function MenuBar({ menus, status = [], leading, trailing, label = 'Menu b
339
339
  >
340
340
  <span className="desk-menu-check" aria-hidden="true">{resolved.checked ? '✓' : ''}</span>
341
341
  <span className="desk-menu-label">{item.label}</span>
342
- {item.detail && <span className="desk-menu-detail">{item.detail}</span>}
342
+ {item.detail && <span className="desk-menu-detail" title={item.detail}>{item.detail}</span>}
343
343
  {item.shortcut && <kbd className="desk-menu-shortcut">{formatShortcut(item.shortcut, apple)}</kbd>}
344
344
  </div>
345
345
  )
@@ -184,7 +184,7 @@ export function useContextMenu({ items, label, disabled }: ContextMenuOptions):
184
184
  >
185
185
  <span className="desk-menu-check" aria-hidden="true">{resolved.checked ? '✓' : ''}</span>
186
186
  <span className="desk-menu-label">{item.label}</span>
187
- {item.detail && <span className="desk-menu-detail">{item.detail}</span>}
187
+ {item.detail && <span className="desk-menu-detail" title={item.detail}>{item.detail}</span>}
188
188
  {item.shortcut && <kbd className="desk-menu-shortcut">{formatShortcut(item.shortcut, apple)}</kbd>}
189
189
  </div>
190
190
  )