gooee 0.42.0 → 0.47.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 (46) hide show
  1. package/package.json +1 -1
  2. package/src/components/Alert/Alert.module.css +2 -2
  3. package/src/components/AnimatedNumber/AnimatedNumber.module.css +3 -3
  4. package/src/components/Badge/Badge.module.css +2 -2
  5. package/src/components/Button/Button.module.css +4 -4
  6. package/src/components/Card/Card.module.css +7 -5
  7. package/src/components/CodeBlock/CodeBlock.module.css +4 -2
  8. package/src/components/CopyButton/CopyButton.module.css +1 -1
  9. package/src/components/Dial/Dial.module.css +4 -3
  10. package/src/components/Dial/Dial.tsx +32 -1
  11. package/src/components/Dialog/Dialog.module.css +10 -4
  12. package/src/components/DropdownMenu/DropdownMenu.module.css +1 -1
  13. package/src/components/FormField/FormField.module.css +23 -3
  14. package/src/components/HoldToConfirm/HoldToConfirm.module.css +37 -52
  15. package/src/components/HoldToConfirm/HoldToConfirm.tsx +146 -60
  16. package/src/components/Input/Input.module.css +6 -4
  17. package/src/components/InputGroup/InputGroup.module.css +3 -0
  18. package/src/components/Kbd/Kbd.module.css +2 -2
  19. package/src/components/LivePill/LivePill.module.css +213 -31
  20. package/src/components/LivePill/LivePill.tsx +45 -14
  21. package/src/components/MorphButton/MorphButton.module.css +8 -4
  22. package/src/components/NumberInput/NumberInput.module.css +9 -5
  23. package/src/components/Pagination/Pagination.module.css +1 -0
  24. package/src/components/PickerWheel/PickerWheel.module.css +1 -1
  25. package/src/components/Popover/Popover.module.css +12 -4
  26. package/src/components/Prose/Prose.module.css +5 -3
  27. package/src/components/RulerScrubber/RulerScrubber.module.css +2 -2
  28. package/src/components/SegmentedControl/SegmentedControl.module.css +5 -5
  29. package/src/components/Select/Select.module.css +6 -4
  30. package/src/components/Sheet/Sheet.module.css +12 -5
  31. package/src/components/Skeleton/Skeleton.module.css +1 -1
  32. package/src/components/SplitFlap/SplitFlap.module.css +1 -1
  33. package/src/components/SwipeDeck/SwipeDeck.module.css +1 -1
  34. package/src/components/Switch/Switch.module.css +7 -5
  35. package/src/components/Table/Table.module.css +8 -6
  36. package/src/components/Tabs/Tabs.module.css +34 -33
  37. package/src/components/Tabs/Tabs.tsx +64 -21
  38. package/src/components/Textarea/Textarea.module.css +5 -3
  39. package/src/components/ThemeToggle/ThemeToggle.module.css +6 -15
  40. package/src/components/ThemeToggle/ThemeToggle.tsx +108 -9
  41. package/src/components/Toast/Toast.module.css +8 -5
  42. package/src/components/Toggle/Toggle.module.css +4 -4
  43. package/src/internal/icons.tsx +7 -0
  44. package/src/internal/motion.ts +1 -1
  45. package/src/internal/themeReveal.ts +63 -0
  46. package/src/tokens.css +49 -15
@@ -2,21 +2,23 @@
2
2
 
3
3
  import { useEffect, useId, useLayoutEffect, useRef, useState, type KeyboardEvent, type MouseEvent, type PointerEvent, type ReactNode } from 'react'
4
4
  import { cx } from '../../internal/cx'
5
- import { CheckIcon } from '../../internal/icons'
5
+ import { CheckIcon, XIcon } from '../../internal/icons'
6
6
  import { bezier } from '../../internal/feel'
7
7
  import { morphCurve, prefersReducedMotion, readMotionMs } from '../../internal/motion'
8
+ import { frames, layer, morphEase, motionFor } from '../../internal/liquidMatter'
9
+ import { body, boxPath, lerp, loopsPath, pincher, seg, trace, type Box } from '../../internal/liquidPath'
8
10
  import styles from './HoldToConfirm.module.css'
9
11
 
10
12
  export type HoldToConfirmProps = {
11
13
  /** The action, as the button's label, such as "Delete workspace". */
12
14
  children: ReactNode
13
- /** Called once the hold runs to the end, or Confirm is pressed in the confirm step. */
15
+ /** Called once the hold runs to the end, or the button is pressed again in the confirm step. */
14
16
  onConfirm: () => void
15
17
  /** Called when a hold is let go early, or the confirm step is cancelled. */
16
18
  onCancel?: () => void
17
- /** The confirm step's button, such as "Delete". Keep it short. */
19
+ /** The action as a verb for the confirm step's line, such as "Delete": "Press it again to delete, or Cancel." */
18
20
  confirmLabel?: string
19
- /** The confirm step's way back. */
21
+ /** The name of the round cancel button that buds out beside it in the confirm step. */
20
22
  cancelLabel?: string
21
23
  /** Shown in place of the label once it is done, such as "Workspace deleted". */
22
24
  doneLabel?: ReactNode
@@ -40,6 +42,72 @@ const HINT_AFTER = 300
40
42
  const LEAVE = 16
41
43
  // How long the done state shows before the button can be used again.
42
44
  const DONE_FOR = 2400
45
+ // A click this soon after the step opens is the rest of a double-click, not a choice.
46
+ const GUARD = 500
47
+
48
+ /**
49
+ * The cancel drop buds out of the button's right edge, its neck stretches and breaks, and it grows into
50
+ * the round cancel button (`in`), or flows back into the button (`out`). The button keeps its own look:
51
+ * the drawing is cut out where it is. Returns a stop, or null when motion is reduced.
52
+ */
53
+ function bud(row: HTMLElement, shell: HTMLElement, x: HTMLElement, way: 'in' | 'out') {
54
+ const ms = motionFor(way === 'in' ? 'morph' : 'morph-out')
55
+ if (!ms) return null
56
+ const box = (el: HTMLElement): Box => {
57
+ const r = el.getBoundingClientRect(),
58
+ o = row.getBoundingClientRect()
59
+ return { cx: r.left - o.left + r.width / 2, cy: r.top - o.top + r.height / 2, hw: r.width / 2, hh: r.height / 2, r: r.height / 2 }
60
+ }
61
+ const O = box(shell)
62
+ const look = getComputedStyle(x)
63
+ const line = parseFloat(look.getPropertyValue('--gooee-line-thick')) || 1.5
64
+ const T = box(x)
65
+ const T2: Box = { ...T, hw: T.hw - line / 2, hh: T.hh - line / 2, r: T.r - line / 2 }
66
+ const { svg, paths } = layer(row, styles.bud, null)
67
+ const path = paths[0]
68
+ path.style.fill = look.backgroundColor
69
+ path.style.stroke = look.getPropertyValue('--gooee-color-border-strong')
70
+ path.style.strokeWidth = `${line}px`
71
+ const clip = svg.appendChild(document.createElementNS('http://www.w3.org/2000/svg', 'clipPath'))
72
+ clip.id = `gooee-hold-${Math.random().toString(36).slice(2)}`
73
+ const hole = clip.appendChild(document.createElementNS('http://www.w3.org/2000/svg', 'path'))
74
+ hole.setAttribute('clip-rule', 'evenodd')
75
+ hole.setAttribute('d', `M-4000 -4000H4000V4000H-4000Z${boxPath({ ...O, hw: O.hw + 0.5, hh: O.hh + 0.5, r: O.r + 0.5 })}`)
76
+ path.setAttribute('clip-path', `url(#${clip.id})`)
77
+ const e = morphEase()
78
+ const pin = pincher(e, motionFor('fast'))
79
+ const edge = O.cx + O.hw - O.hh
80
+ const r0 = O.hh * 0.45
81
+ x.style.opacity = '0'
82
+ const stop = frames(
83
+ ms,
84
+ (k, now) => {
85
+ const u = way === 'in' ? k : 1 - k
86
+ const f = e(u)
87
+ const r = lerp(r0, T2.hh, e(seg(u, 0.25, 1)))
88
+ const D: Box = { cx: lerp(O.cx + O.hw - r0, T2.cx, f), cy: O.cy, hw: r, hh: r, r }
89
+ const p = pin(body(O, [edge, O.cy]), body(D), now)
90
+ path.setAttribute(
91
+ 'd',
92
+ loopsPath(
93
+ trace(p.sdf, [
94
+ [edge, O.cy, 0, 1],
95
+ [D.cx, D.cy, 0, 1],
96
+ ]),
97
+ ),
98
+ )
99
+ },
100
+ () => {
101
+ svg.remove()
102
+ x.style.opacity = ''
103
+ },
104
+ )
105
+ return () => {
106
+ stop()
107
+ svg.remove()
108
+ x.style.opacity = ''
109
+ }
110
+ }
43
111
 
44
112
  // The pill's outline as one closed path that starts on the bottom edge at x and runs left first. The
45
113
  // line is drawn at both ends of the path at once, so it burns out both ways from x and meets opposite.
@@ -76,11 +144,12 @@ export function HoldToConfirm({
76
144
  const rootRef = useRef<HTMLDivElement>(null)
77
145
  const shellRef = useRef<HTMLDivElement>(null)
78
146
  const mainRef = useRef<HTMLButtonElement>(null)
79
- const stepRef = useRef<HTMLDivElement>(null)
147
+ const rowRef = useRef<HTMLDivElement>(null)
148
+ const stepAt = useRef(0)
80
149
  const cancelRef = useRef<HTMLButtonElement>(null)
81
150
  const runRef = useRef<SVGPathElement>(null)
82
151
  const [phase, setPhase] = useState<Phase>('idle')
83
- const [size, setSize] = useState({ w: 0, h: 0, step: 0, stepH: 0, room: 0, inset: 1 })
152
+ const [size, setSize] = useState({ w: 0, h: 0, inset: 1 })
84
153
  const [path, setPath] = useState('')
85
154
  const [keep, setKeep] = useState(false)
86
155
  const [said, setSaid] = useState('')
@@ -97,20 +166,17 @@ export function HoldToConfirm({
97
166
  useLayoutEffect(() => {
98
167
  const root = rootRef.current
99
168
  const main = mainRef.current
100
- const step = stepRef.current
101
- if (!root || !main || !step) return
169
+ if (!root || !main) return
102
170
  const measure = () => {
103
171
  const w = main.offsetWidth
104
172
  const h = main.offsetHeight
105
173
  const inset = parseFloat(getComputedStyle(root).getPropertyValue('--gooee-hold-stroke')) / 2 || 1
106
- setSize({ w, h, step: step.offsetWidth, stepH: step.offsetHeight, room: root.clientWidth, inset })
174
+ setSize({ w, h, inset })
107
175
  setPath(outline(w, h, inset, w / 2))
108
176
  }
109
177
  measure()
110
178
  const ro = new ResizeObserver(measure)
111
179
  ro.observe(main)
112
- ro.observe(step)
113
- ro.observe(root)
114
180
  return () => ro.disconnect()
115
181
  }, [])
116
182
 
@@ -172,6 +238,7 @@ export function HoldToConfirm({
172
238
  tapTimer.current = 0
173
239
  cancelAnimationFrame(raf.current)
174
240
  paint(0)
241
+ stepAt.current = performance.now()
175
242
  setPhase('step')
176
243
  }
177
244
 
@@ -192,6 +259,19 @@ export function HoldToConfirm({
192
259
  return () => window.clearTimeout(t)
193
260
  }, [phase])
194
261
 
262
+ // The cancel drop buds out when the step opens and flows back when it closes, either way.
263
+ const wasOpen = useRef(false)
264
+ useLayoutEffect(() => {
265
+ const isOpen = phase === 'step'
266
+ if (isOpen === wasOpen.current) return
267
+ wasOpen.current = isOpen
268
+ const row = rowRef.current,
269
+ shell = shellRef.current,
270
+ x = cancelRef.current
271
+ if (!row || !shell || !x) return
272
+ return bud(row, shell, x, isOpen ? 'in' : 'out') ?? undefined
273
+ }, [phase])
274
+
195
275
  useEffect(
196
276
  () => () => {
197
277
  cancelAnimationFrame(raf.current)
@@ -242,6 +322,11 @@ export function HoldToConfirm({
242
322
  // Held Enter or Space works like a held finger, from the middle of the button. One press opens the
243
323
  // confirm step, since holding a key is hard for many people.
244
324
  const onKeyDown = (e: KeyboardEvent<HTMLButtonElement>) => {
325
+ if (phaseRef.current === 'step') {
326
+ // In the step the button confirms with its own click; Escape steps back.
327
+ if (e.key === 'Escape') closeStep()
328
+ return
329
+ }
245
330
  if (e.key !== 'Enter' && e.key !== ' ') return
246
331
  e.preventDefault()
247
332
  if (e.repeat || disabled || phaseRef.current !== 'idle' || press.current) return
@@ -249,79 +334,80 @@ export function HoldToConfirm({
249
334
  }
250
335
 
251
336
  const onKeyUp = (e: KeyboardEvent<HTMLButtonElement>) => {
252
- if (e.key !== 'Enter' && e.key !== ' ') return
337
+ if (phaseRef.current === 'step' || (e.key !== 'Enter' && e.key !== ' ')) return
253
338
  e.preventDefault()
254
339
  if (press.current?.key === e.key) letGo(true)
255
340
  }
256
341
 
257
342
  // A screen reader or voice control sends a click with no press: it opens the confirm step.
258
343
  const onClick = (e: MouseEvent<HTMLButtonElement>) => {
344
+ // In the step, pressing the button again confirms it, unless it is the second half of a double-click.
345
+ if (phaseRef.current === 'step') {
346
+ if (e.detail === 0 || performance.now() - stepAt.current > GUARD) finish()
347
+ return
348
+ }
259
349
  if (disabled || phaseRef.current !== 'idle' || press.current) return
260
350
  if (e.detail === 0 || tapTimer.current) openStep()
261
351
  }
262
352
 
263
- const onStepKey = (e: KeyboardEvent<HTMLDivElement>) => {
353
+ const onCancelKey = (e: KeyboardEvent<HTMLButtonElement>) => {
264
354
  if (e.key !== 'Escape') return
265
355
  e.stopPropagation()
266
356
  closeStep()
267
357
  }
268
358
 
269
- // No room beside the label, as on a phone: the step opens under it and the pill grows into a card.
270
- const stack = size.room > 0 && size.w + size.step > size.room
271
359
  const open = phase === 'step'
272
- const shellW = open ? (stack ? Math.max(size.w, size.step) : size.w + size.step) : size.w
273
- const shellH = open && stack ? size.h + size.stepH : size.h
274
- const line = open ? (stepHint ?? `Choose ${cancelLabel} or ${confirmLabel}.`) : phase === 'done' ? '' : keep ? 'Keep holding' : hint
360
+ const line = open ? (stepHint ?? `Press it again to ${confirmLabel.toLowerCase()}, or ${cancelLabel}.`) : phase === 'done' ? '' : keep ? 'Keep holding' : hint
275
361
 
276
362
  return (
277
363
  <div ref={rootRef} className={cx(styles.root, className)}>
278
- <div
279
- ref={shellRef}
280
- className={styles.shell}
281
- data-phase={phase}
282
- data-stack={stack || undefined}
283
- data-disabled={disabled || undefined}
284
- style={{ width: shellW || undefined, height: shellH || undefined }}
285
- >
364
+ <div ref={rowRef} className={styles.row}>
365
+ <div ref={shellRef} className={styles.shell} data-phase={phase} data-disabled={disabled || undefined}>
366
+ <button
367
+ ref={mainRef}
368
+ type="button"
369
+ className={styles.main}
370
+ aria-describedby={`${id}-hint`}
371
+ aria-expanded={open}
372
+ aria-controls={`${id}-step`}
373
+ aria-disabled={disabled || undefined}
374
+ onPointerDown={onPointerDown}
375
+ onPointerMove={onPointerMove}
376
+ onPointerUp={onPointerEnd}
377
+ onPointerCancel={onPointerEnd}
378
+ onContextMenu={(e) => e.preventDefault()}
379
+ onKeyDown={onKeyDown}
380
+ onKeyUp={onKeyUp}
381
+ onBlur={() => press.current?.pointer === 'key' && letGo(false)}
382
+ onClick={onClick}
383
+ >
384
+ <span className={styles.faces}>
385
+ <span className={styles.face} data-face="idle" aria-hidden={phase === 'done' || undefined}>
386
+ {children}
387
+ </span>
388
+ <span className={styles.face} data-face="done" aria-hidden={phase !== 'done' || undefined}>
389
+ <CheckIcon />
390
+ {doneLabel}
391
+ </span>
392
+ </span>
393
+ <svg className={styles.fuse} width={size.w} height={size.h} aria-hidden="true">
394
+ <path ref={runRef} d={path} className={styles.run} pathLength={1} />
395
+ </svg>
396
+ </button>
397
+ </div>
286
398
  <button
287
- ref={mainRef}
399
+ ref={cancelRef}
400
+ id={`${id}-step`}
288
401
  type="button"
289
- className={styles.main}
402
+ className={styles.cancel}
403
+ aria-label={cancelLabel}
290
404
  aria-describedby={`${id}-hint`}
291
- aria-expanded={open}
292
- aria-controls={`${id}-step`}
293
- aria-disabled={disabled || undefined}
294
- onPointerDown={onPointerDown}
295
- onPointerMove={onPointerMove}
296
- onPointerUp={onPointerEnd}
297
- onPointerCancel={onPointerEnd}
298
- onContextMenu={(e) => e.preventDefault()}
299
- onKeyDown={onKeyDown}
300
- onKeyUp={onKeyUp}
301
- onBlur={() => press.current?.pointer === 'key' && letGo(false)}
302
- onClick={onClick}
405
+ inert={!open}
406
+ onClick={closeStep}
407
+ onKeyDown={onCancelKey}
303
408
  >
304
- <span className={styles.faces}>
305
- <span className={styles.face} data-face="idle" aria-hidden={phase === 'done' || undefined}>
306
- {children}
307
- </span>
308
- <span className={styles.face} data-face="done" aria-hidden={phase !== 'done' || undefined}>
309
- <CheckIcon />
310
- {doneLabel}
311
- </span>
312
- </span>
313
- <svg className={styles.fuse} width={size.w} height={size.h} aria-hidden="true">
314
- <path ref={runRef} d={path} className={styles.run} pathLength={1} />
315
- </svg>
409
+ <XIcon />
316
410
  </button>
317
- <div ref={stepRef} id={`${id}-step`} className={styles.step} role="group" aria-labelledby={`${id}-hint`} inert={!open} onKeyDown={onStepKey}>
318
- <button ref={cancelRef} type="button" className={styles.cancel} onClick={closeStep}>
319
- {cancelLabel}
320
- </button>
321
- <button type="button" className={styles.confirm} onClick={finish}>
322
- {confirmLabel}
323
- </button>
324
- </div>
325
411
  </div>
326
412
  <p id={`${id}-hint`} className={styles.hint}>
327
413
  {line}
@@ -23,8 +23,10 @@
23
23
  align-items: center;
24
24
  gap: var(--gooee-space-3);
25
25
  min-height: var(--h);
26
- padding: 0 var(--gooee-space-5);
27
- border: var(--gooee-line) solid var(--gooee-color-border-strong);
26
+ /* The line's width lives in --edge, so the padding takes it back and the words never move when it thickens. */
27
+ --edge: var(--gooee-line);
28
+ padding: 0 calc(var(--gooee-space-5) - var(--edge));
29
+ border: var(--edge) solid var(--gooee-color-border-strong);
28
30
  border-radius: var(--gooee-radius-md);
29
31
  background: var(--gooee-color-surface);
30
32
  cursor: text;
@@ -35,7 +37,7 @@
35
37
  background-color var(--gooee-motion-fast) var(--gooee-ease-out);
36
38
  }
37
39
 
38
- .sm { --h: var(--gooee-control-h-sm); gap: var(--gooee-space-2); padding: 0 var(--gooee-space-4); }
40
+ .sm { --h: var(--gooee-control-h-sm); gap: var(--gooee-space-2); padding: 0 calc(var(--gooee-space-4) - var(--edge)); }
39
41
  .lg { --h: var(--gooee-control-h-lg); }
40
42
  .floating { --h: var(--gooee-field-h-floating); }
41
43
 
@@ -71,7 +73,7 @@
71
73
  /* Red border, plus the thicker line and the nudge, so the error does not rely on colour. */
72
74
  .field[data-invalid] {
73
75
  border-color: var(--gooee-color-danger);
74
- border-width: var(--gooee-line-thick);
76
+ --edge: var(--gooee-line-thick);
75
77
  animation: nudge var(--gooee-motion-slow) var(--gooee-ease-out);
76
78
  }
77
79
 
@@ -96,13 +96,16 @@
96
96
 
97
97
  .addon > svg { flex: none; font-size: var(--gooee-icon-md); }
98
98
 
99
+ /* The divider takes its width back from the padding on its side, so the words stay on the grid. */
99
100
  .addon[data-side="prefix"] {
101
+ padding-inline-end: calc(var(--gooee-space-4) - var(--gooee-line));
100
102
  border-inline-end: var(--gooee-line) solid var(--gooee-color-border);
101
103
  border-start-start-radius: calc(var(--r) - var(--gooee-line));
102
104
  border-end-start-radius: calc(var(--r) - var(--gooee-line));
103
105
  }
104
106
 
105
107
  .addon[data-side="suffix"] {
108
+ padding-inline-start: calc(var(--gooee-space-4) - var(--gooee-line));
106
109
  border-inline-start: var(--gooee-line) solid var(--gooee-color-border);
107
110
  border-start-end-radius: calc(var(--r) - var(--gooee-line));
108
111
  border-end-end-radius: calc(var(--r) - var(--gooee-line));
@@ -5,7 +5,7 @@
5
5
  justify-content: center;
6
6
  min-width: var(--gooee-kbd-h);
7
7
  height: var(--gooee-kbd-h);
8
- padding: 0 var(--gooee-space-3);
8
+ padding: 0 calc(var(--gooee-space-3) - var(--gooee-line));
9
9
  border: var(--gooee-line) solid var(--gooee-color-border-strong);
10
10
  border-bottom-width: var(--gooee-line-focus);
11
11
  border-radius: var(--gooee-radius-sm);
@@ -13,7 +13,7 @@
13
13
  color: var(--gooee-color-fg);
14
14
  font-family: var(--gooee-font-mono);
15
15
  font-size: var(--gooee-text-xs);
16
- line-height: 1;
16
+ line-height: var(--gooee-leading-none);
17
17
  vertical-align: middle;
18
18
  transition:
19
19
  transform var(--gooee-motion-instant) var(--gooee-ease-out),
@@ -1,6 +1,6 @@
1
1
  .root {
2
2
  /* The row is the pill plus the card's inner padding, so the label keeps its pixels as the card grows round it. */
3
- --pill-pad: calc(var(--gooee-space-6) - (var(--gooee-hit-min) - var(--gooee-text-sm) * var(--gooee-leading-normal)) / 2);
3
+ --pill-pad: calc(var(--gooee-space-6) - (var(--gooee-hit-min) - round(nearest, var(--gooee-text-sm) * var(--gooee-leading-normal-ratio), 4px)) / 2);
4
4
  position: relative;
5
5
  inline-size: 100%;
6
6
  max-inline-size: var(--gooee-panel-w-sm);
@@ -32,10 +32,12 @@
32
32
  --pill-line: var(--gooee-color-border);
33
33
  --pill-key: var(--gooee-color-border-strong);
34
34
  --pill-edge: color-mix(in srgb, var(--pill-fg) 16%, transparent);
35
- --pill-fill: var(--gooee-color-inverse);
36
- --pill-fill-fg: var(--gooee-color-inverse-fg);
35
+ /* As wide as its words, up to the whole row, and centred on the pill so the pill never moves. */
37
36
  position: absolute;
38
- inset-inline: 0;
37
+ left: 50%;
38
+ translate: -50% 0;
39
+ inline-size: max-content;
40
+ max-inline-size: 100%;
39
41
  display: flex;
40
42
  flex-direction: column;
41
43
  border-radius: var(--gooee-radius-sheet);
@@ -53,8 +55,6 @@
53
55
  --pill-line: color-mix(in srgb, var(--pill-fg) 18%, var(--pill-bg));
54
56
  --pill-key: transparent;
55
57
  --pill-edge: transparent;
56
- --pill-fill: var(--gooee-color-surface);
57
- --pill-fill-fg: var(--gooee-color-fg);
58
58
  }
59
59
 
60
60
  /* Shut, it closes fast and falls away. Open, the surface pours out of the pill on the liquid curve. */
@@ -78,10 +78,22 @@
78
78
  visibility: hidden;
79
79
  }
80
80
 
81
- .shell:not([data-measured]):not([data-open]) .button {
81
+ .shell:not([data-measured]):not([data-open]) :is(.button, .lead) {
82
82
  visibility: visible;
83
83
  }
84
84
 
85
+ .root[data-align='start'] .shell {
86
+ left: auto;
87
+ inset-inline-start: calc(var(--pill-pad) * -1);
88
+ translate: none;
89
+ }
90
+
91
+ /* The card keeps the same inner padding at its start as above the pill, and the pill stays on its spot. */
92
+ .root[data-align='start'] .row {
93
+ justify-content: flex-start;
94
+ padding-inline-start: var(--pill-pad);
95
+ }
96
+
85
97
  .root[data-placement='bottom'] .shell {
86
98
  bottom: 0;
87
99
  flex-direction: column-reverse;
@@ -125,7 +137,7 @@
125
137
  -webkit-tap-highlight-color: transparent;
126
138
  }
127
139
 
128
- /* The outline sits over the fill, so both ends match. Mixed from the text colour, it fades into the fill. */
140
+ /* The pill's outline, mixed from the text colour. */
129
141
  .button::after {
130
142
  content: '';
131
143
  position: absolute;
@@ -146,12 +158,7 @@
146
158
  box-shadow: inset 0 0 0 var(--gooee-line) transparent;
147
159
  }
148
160
 
149
- .stack {
150
- display: grid;
151
- }
152
-
153
161
  .face {
154
- grid-area: 1 / 1;
155
162
  display: inline-flex;
156
163
  align-items: center;
157
164
  gap: var(--gooee-space-3);
@@ -164,24 +171,6 @@
164
171
  font-size: var(--gooee-icon-md);
165
172
  }
166
173
 
167
- /* The pill as its own progress bar: words under the fill turn to the fill's own ink. */
168
- .over {
169
- background: var(--pill-fill);
170
- color: var(--pill-fill-fg);
171
- clip-path: inset(0 calc(100% - var(--p) * 100%) 0 0);
172
- transition:
173
- clip-path var(--gooee-motion-slow) var(--gooee-ease-out),
174
- opacity var(--gooee-motion-fast) var(--gooee-ease-out);
175
- }
176
-
177
- .over:dir(rtl) {
178
- clip-path: inset(0 0 0 calc(100% - var(--p) * 100%));
179
- }
180
-
181
- .shell[data-open] .over {
182
- opacity: 0;
183
- }
184
-
185
174
  .body {
186
175
  padding: var(--gooee-space-2) var(--gooee-space-6) var(--gooee-space-6);
187
176
  opacity: 0;
@@ -205,3 +194,196 @@
205
194
  clip-path: inset(50%);
206
195
  white-space: nowrap;
207
196
  }
197
+
198
+ /* With progress, a ring leads the pill. Shut: a 24px ring 10px in from the pill's 22px corner (12 + 10 = 22).
199
+ Open: the same ring at 44px, 12px in from the card's corner, so the card's radius is 22 + 12 = 34.
200
+ Opening, the ring moves from the pill to the card's top start corner and grows; the card's words sit beside it. */
201
+ .root[data-ring] {
202
+ --ring-l: var(--gooee-hit-min);
203
+ --ring-s: var(--gooee-space-7);
204
+ --ring-in: calc((var(--ring-l) - var(--ring-s)) / 2);
205
+ --card-in: var(--gooee-space-4);
206
+ --card-r: calc(var(--ring-l) / 2 + var(--card-in));
207
+ block-size: var(--ring-l);
208
+ }
209
+
210
+ .root[data-ring] .shell {
211
+ display: grid;
212
+ grid-template-columns: var(--ring-l) minmax(0, auto);
213
+ column-gap: var(--gooee-space-4);
214
+ padding: var(--card-in) var(--gooee-space-7) var(--card-in) var(--card-in);
215
+ border-radius: var(--card-r);
216
+ }
217
+
218
+ .root[data-ring] .shell[data-open] {
219
+ clip-path: inset(0 0 0 0 round var(--card-r));
220
+ }
221
+
222
+ .root[data-ring][data-align='start'] .shell {
223
+ inset-inline-start: 0;
224
+ }
225
+
226
+ .root[data-ring] .row {
227
+ position: absolute;
228
+ inset-inline-start: 0;
229
+ padding: 0;
230
+ }
231
+
232
+ /* Shut, the pill sits where the card's middle (or start) is, the same spot as without a ring. */
233
+ .root[data-ring][data-align='center'] .row {
234
+ left: 50%;
235
+ translate: -50% 0;
236
+ }
237
+
238
+ .root[data-ring][data-align='center'] .shell[data-open] .row {
239
+ left: var(--card-in);
240
+ translate: none;
241
+ }
242
+
243
+ .root[data-ring][data-placement='top'] .row {
244
+ top: 0;
245
+ }
246
+
247
+ .root[data-ring][data-placement='bottom'] .row {
248
+ bottom: 0;
249
+ }
250
+
251
+ /* Open, the button is the ring: a 44px target that folds the card back. */
252
+ .root[data-ring] .shell[data-open] .row {
253
+ inset-inline-start: var(--card-in);
254
+ }
255
+
256
+ .root[data-ring][data-placement='top'] .shell[data-open] .row {
257
+ top: var(--card-in);
258
+ }
259
+
260
+ .root[data-ring][data-placement='bottom'] .shell[data-open] .row {
261
+ bottom: var(--card-in);
262
+ }
263
+
264
+ .root[data-ring] .shell[data-open] .button {
265
+ inline-size: var(--ring-l);
266
+ }
267
+
268
+ .slot {
269
+ flex: none;
270
+ inline-size: var(--ring-s);
271
+ block-size: var(--ring-s);
272
+ margin-inline-start: var(--ring-in);
273
+ }
274
+
275
+ .root[data-ring] .face {
276
+ padding-inline: var(--gooee-space-3) var(--gooee-space-6);
277
+ transition: opacity var(--gooee-motion-base) var(--gooee-ease-out) var(--gooee-motion-fast);
278
+ }
279
+
280
+ .root[data-ring] .shell[data-open] .face {
281
+ opacity: 0;
282
+ transition: opacity var(--gooee-motion-instant) var(--gooee-ease-in);
283
+ }
284
+
285
+ .lead {
286
+ --ring-ink: var(--pill-fg);
287
+ position: relative;
288
+ grid-area: 1 / 1;
289
+ inline-size: var(--ring-l);
290
+ block-size: var(--ring-l);
291
+ color: var(--ring-ink);
292
+ /* Shut, the big ring is scaled down onto the pill's ring slot (24 of 44). LivePill measures the move. */
293
+ align-self: start;
294
+ scale: calc(24 / 44);
295
+ translate: var(--ring-x, 0) var(--ring-y, 0);
296
+ transform-origin: 0 0;
297
+ transition:
298
+ scale var(--gooee-motion-fast) var(--gooee-ease-in),
299
+ translate var(--gooee-motion-fast) var(--gooee-ease-in);
300
+ }
301
+
302
+ .shell[data-open] .lead {
303
+ scale: 1;
304
+ translate: 0 0;
305
+ transition:
306
+ scale var(--gooee-motion-liquid) var(--gooee-ease-liquid),
307
+ translate var(--gooee-motion-liquid) var(--gooee-ease-liquid);
308
+ }
309
+
310
+ .lead[data-state='stopped'] {
311
+ --ring-ink: var(--gooee-color-danger);
312
+ }
313
+
314
+ .ring {
315
+ position: absolute;
316
+ inset: 0;
317
+ inline-size: 100%;
318
+ block-size: 100%;
319
+ rotate: -90deg;
320
+ fill: none;
321
+ /* Shut, the stroke is thicker in the drawing (5.5) and reaches past the 44 box; an svg crops by default. */
322
+ overflow: visible;
323
+ }
324
+
325
+ /* Strokes are in the 44px drawing: 5.5 shows as 3px when the ring is shut at 24px, 4 shows as 4px open. */
326
+ .track,
327
+ .arc {
328
+ stroke-width: 5.5;
329
+ transition: stroke-width var(--gooee-motion-fast) var(--gooee-ease-in);
330
+ }
331
+
332
+ .shell[data-open] :is(.track, .arc) {
333
+ stroke-width: 4;
334
+ transition: stroke-width var(--gooee-motion-liquid) var(--gooee-ease-liquid);
335
+ }
336
+
337
+ .track {
338
+ stroke: var(--pill-line);
339
+ }
340
+
341
+ .lead[data-state='stopped'] .track {
342
+ stroke: var(--ring-ink);
343
+ }
344
+
345
+ .arc {
346
+ stroke: var(--ring-ink);
347
+ stroke-linecap: round;
348
+ transition:
349
+ stroke-width var(--gooee-motion-fast) var(--gooee-ease-in),
350
+ stroke-dasharray var(--gooee-motion-slow) var(--gooee-ease-out);
351
+ }
352
+
353
+ .mark {
354
+ position: absolute;
355
+ inset: 0;
356
+ margin: auto;
357
+ inline-size: var(--gooee-space-6);
358
+ block-size: var(--gooee-space-6);
359
+ fill: none;
360
+ stroke: currentColor;
361
+ stroke-width: 2.5;
362
+ stroke-linecap: round;
363
+ stroke-linejoin: round;
364
+ }
365
+
366
+ .pct {
367
+ position: absolute;
368
+ inset: 0;
369
+ display: grid;
370
+ place-items: center;
371
+ font-size: var(--gooee-text-sm);
372
+ font-weight: var(--gooee-weight-semibold);
373
+ font-variant-numeric: tabular-nums;
374
+ letter-spacing: -0.02em;
375
+ line-height: var(--gooee-leading-none);
376
+ opacity: 0;
377
+ transition: opacity var(--gooee-motion-instant) var(--gooee-ease-in);
378
+ }
379
+
380
+ .shell[data-open] .pct {
381
+ opacity: 1;
382
+ transition: opacity var(--gooee-motion-base) var(--gooee-ease-out) var(--gooee-motion-fast);
383
+ }
384
+
385
+ .root[data-ring] .body {
386
+ grid-area: 1 / 2;
387
+ align-self: start;
388
+ padding: 0;
389
+ }