@justanarthur/modo-ui-notch 0.3.0 → 0.4.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/blocks/activities/agenda/examples.mdx +8 -0
- package/blocks/activities/agenda/index.tsx +164 -16
- package/blocks/activities/clock/examples.mdx +16 -0
- package/blocks/activities/clock/index.tsx +357 -59
- package/blocks/activities/now-playing/examples.mdx +8 -0
- package/blocks/activities/now-playing/index.tsx +140 -54
- package/blocks/activities/weather/examples.mdx +9 -1
- package/blocks/activities/weather/index.tsx +241 -12
- package/blocks/app/expanded-island/index.tsx +3 -1
- package/blocks/app/settings-window/examples.mdx +8 -0
- package/blocks/app/settings-window/index.tsx +8 -3
- package/blocks/system/clipboard/examples.mdx +8 -0
- package/blocks/system/clipboard/index.tsx +262 -52
- package/blocks/system/recent-files/examples.mdx +14 -0
- package/blocks/system/recent-files/index.tsx +110 -25
- package/blocks/system/system-stats/examples.mdx +8 -0
- package/blocks/system/system-stats/index.tsx +211 -4
- package/components/island/widget/index.tsx +34 -0
- package/dist/blocks/activities/agenda/index.d.ts +2 -1
- package/dist/blocks/activities/agenda/index.js +2 -2
- package/dist/blocks/activities/clock/index.d.ts +2 -1
- package/dist/blocks/activities/clock/index.js +2 -2
- package/dist/blocks/activities/now-playing/index.d.ts +2 -1
- package/dist/blocks/activities/now-playing/index.js +2 -2
- package/dist/blocks/activities/weather/index.d.ts +2 -1
- package/dist/blocks/activities/weather/index.js +2 -2
- package/dist/blocks/app/expanded-island/index.d.ts +1 -1
- package/dist/blocks/app/expanded-island/index.js +1 -1
- package/dist/blocks/app/settings-window/index.d.ts +1 -1
- package/dist/blocks/app/settings-window/index.js +1 -1
- package/dist/blocks/system/clipboard/index.d.ts +2 -1
- package/dist/blocks/system/clipboard/index.js +2 -2
- package/dist/blocks/system/recent-files/index.d.ts +2 -1
- package/dist/blocks/system/recent-files/index.js +2 -2
- package/dist/blocks/system/system-stats/index.d.ts +2 -1
- package/dist/blocks/system/system-stats/index.js +2 -2
- package/dist/components/island/widget/index.d.ts +2 -2
- package/dist/components/island/widget/index.js +3 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.js +12 -10
- package/dist/shared/{chunk-2m5dz8nf.d.ts → chunk-0ym9mcqc.d.ts} +6 -2
- package/dist/shared/{chunk-xq5hc5gv.js → chunk-2b6gpn8k.js} +177 -66
- package/dist/shared/chunk-3hcnf4yx.js +481 -0
- package/dist/shared/{chunk-416tsgbc.d.ts → chunk-42wab62s.d.ts} +23 -1
- package/dist/shared/{chunk-pfhy5e4q.d.ts → chunk-6tnq6p89.d.ts} +2 -0
- package/dist/shared/{chunk-qdzemt2v.js → chunk-93dtpjz7.js} +401 -89
- package/dist/shared/{chunk-da177e8r.d.ts → chunk-a6njb8db.d.ts} +16 -1
- package/dist/shared/{chunk-2818esrq.d.ts → chunk-ab8mdg0n.d.ts} +10 -1
- package/dist/shared/{chunk-3thgcfcq.d.ts → chunk-evqpf92s.d.ts} +18 -1
- package/dist/shared/{chunk-mt0k6v8x.js → chunk-gcyspvgr.js} +147 -39
- package/dist/shared/{chunk-t0hcxh89.d.ts → chunk-gkj0hjrn.d.ts} +12 -0
- package/dist/shared/{chunk-wkg17nxs.d.ts → chunk-n739am8j.d.ts} +13 -2
- package/dist/shared/{chunk-ym0xbses.js → chunk-nwzpekvy.js} +274 -18
- package/dist/shared/{chunk-bvtyjcce.d.ts → chunk-sbrtesdg.d.ts} +16 -1
- package/dist/shared/{chunk-7fvnrtz4.d.ts → chunk-swc7dqpw.d.ts} +12 -2
- package/dist/shared/{chunk-j77cx8dp.js → chunk-t9wqhgzt.js} +325 -58
- package/dist/shared/{chunk-9m0xbg5v.js → chunk-wayv5rhr.js} +1 -1
- package/dist/shared/{chunk-x7f3g82r.js → chunk-wf0jtzhs.js} +12 -2
- package/dist/shared/{chunk-9c7ewvkk.js → chunk-yq5svpk7.js} +162 -19
- package/dist/shared/{chunk-cc9nwbtf.js → chunk-z3tj1ydg.js} +3 -0
- package/dist/styles.css +60 -0
- package/mock/clipboard.tsx +34 -0
- package/mock/clock.tsx +3 -3
- package/mock/data.ts +48 -0
- package/mock/files.tsx +14 -1
- package/mock/island-content.tsx +47 -15
- package/mock/system.ts +3 -0
- package/mock/weather.tsx +42 -12
- package/package.json +1 -1
- package/dist/shared/chunk-s2jeqqan.js +0 -243
|
@@ -12,6 +12,7 @@ import { useControllableState } from '@justanarthur/modo-ui/lib/use-controllable
|
|
|
12
12
|
import { cn } from '@justanarthur/modo-ui/lib/utils'
|
|
13
13
|
import {
|
|
14
14
|
CalendarDays,
|
|
15
|
+
Check,
|
|
15
16
|
Clock3,
|
|
16
17
|
Coffee,
|
|
17
18
|
Moon,
|
|
@@ -27,7 +28,7 @@ import {
|
|
|
27
28
|
} from 'lucide-react'
|
|
28
29
|
import { useEffect } from 'react'
|
|
29
30
|
import IslandFlash from '../../../components/island/island-flash'
|
|
30
|
-
import Widget from '../../../components/island/widget'
|
|
31
|
+
import Widget, { type WidgetLayout } from '../../../components/island/widget'
|
|
31
32
|
import { formatClock, MINUTE, SECOND, useEdgeClock } from '../../../lib/clock'
|
|
32
33
|
|
|
33
34
|
type PomodoroPhase = 'focus' | 'short-break' | 'long-break'
|
|
@@ -83,6 +84,10 @@ interface ClockProps {
|
|
|
83
84
|
onValueChange?: (run: PomodoroRun | null) => void
|
|
84
85
|
/** Called when a phase reaches zero, with the next one, which waits paused to be started: show `Clock.PhaseDone`. */
|
|
85
86
|
onPhaseEnd?: (ended: PomodoroRun, next: PomodoroRun) => void
|
|
87
|
+
/** The focus rounds finished today, shown at the tall snap as a row of dots and the time focused. Left out, the tall view leaves the line out. */
|
|
88
|
+
completedToday?: number
|
|
89
|
+
/** `tall` is the open island's tall snap: the time larger, every world clock as a column, the Pomodoro's whole cycle as a strip and its lengths, today's finished rounds; a run lists every phase of its cycle. Defaults to `'fit'`. */
|
|
90
|
+
layout?: WidgetLayout
|
|
86
91
|
/** Classes for the root, which fills its container. */
|
|
87
92
|
className?: string
|
|
88
93
|
}
|
|
@@ -110,7 +115,13 @@ const MARK: Record<PomodoroPhase, string> = {
|
|
|
110
115
|
'short-break': 'var(--status-success)',
|
|
111
116
|
'long-break': 'var(--status-success)',
|
|
112
117
|
}
|
|
118
|
+
const WASH: Record<PomodoroPhase, string> = {
|
|
119
|
+
focus: 'bg-status-warning/16',
|
|
120
|
+
'short-break': 'bg-status-success/16',
|
|
121
|
+
'long-break': 'bg-status-success/16',
|
|
122
|
+
}
|
|
113
123
|
const GLYPH = { focus: Target, 'short-break': Coffee, 'long-break': Coffee }
|
|
124
|
+
const PHASES: PomodoroPhase[] = ['focus', 'short-break', 'long-break']
|
|
114
125
|
|
|
115
126
|
const settingsOf = (pomodoro?: Partial<PomodoroSettings> | false): PomodoroSettings => ({
|
|
116
127
|
...DEFAULTS,
|
|
@@ -165,6 +176,26 @@ function useLeft(run: PomodoroRun) {
|
|
|
165
176
|
return run.endsAt === undefined ? (run.remaining ?? run.total) : Math.max(0, end - now)
|
|
166
177
|
}
|
|
167
178
|
|
|
179
|
+
/** Every phase of one cycle, in order: each focus round and the break after it, the last one long. */
|
|
180
|
+
function cycleOf(settings: PomodoroSettings) {
|
|
181
|
+
return Array.from({ length: settings.rounds }, (_, i) => [
|
|
182
|
+
{ phase: 'focus' as const, round: i + 1 },
|
|
183
|
+
{ phase: i + 1 === settings.rounds ? ('long-break' as const) : ('short-break' as const), round: i + 1 },
|
|
184
|
+
]).flat()
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Where `run` sits in its cycle. */
|
|
188
|
+
const indexIn = (run: Pick<PomodoroRun, 'phase' | 'round'>, settings: PomodoroSettings) =>
|
|
189
|
+
Math.min(settings.rounds * 2 - 1, (run.round - 1) * 2 + (run.phase === 'focus' ? 0 : 1))
|
|
190
|
+
|
|
191
|
+
/** Minutes as `2 h 10 min`, `1 h` or `50 min`. */
|
|
192
|
+
function minutesLabel(minutes: number) {
|
|
193
|
+
const h = Math.floor(minutes / 60)
|
|
194
|
+
const m = minutes % 60
|
|
195
|
+
if (!h) return `${m} min`
|
|
196
|
+
return m ? `${h} h ${m} min` : `${h} h`
|
|
197
|
+
}
|
|
198
|
+
|
|
168
199
|
function phaseName(run: Pick<PomodoroRun, 'phase' | 'round'>, rounds: number) {
|
|
169
200
|
if (run.phase === 'focus') return `Focus ${run.round} of ${rounds}`
|
|
170
201
|
return run.phase === 'long-break' ? 'Long break' : 'Short break'
|
|
@@ -231,19 +262,27 @@ interface ZoneRowProps extends Pick<ClockProps, 'locale' | 'hour12' | 'timeZone'
|
|
|
231
262
|
now: number
|
|
232
263
|
}
|
|
233
264
|
|
|
234
|
-
|
|
265
|
+
/** How a zone differs from here at `now`: its day if not today, its offset, and whether it's day there. */
|
|
266
|
+
function zoneFacts(zone: ClockZone, now: number, timeZone?: string) {
|
|
235
267
|
const there = dayKey(now, zone.timeZone)
|
|
236
268
|
const here = dayKey(now, timeZone)
|
|
237
|
-
const day = there > here ? 'Tomorrow' : there < here ? 'Yesterday' : undefined
|
|
238
269
|
const hour = hourIn(now, zone.timeZone)
|
|
239
|
-
|
|
270
|
+
return {
|
|
271
|
+
day: there > here ? 'Tomorrow' : there < here ? 'Yesterday' : undefined,
|
|
272
|
+
offset: offsetLabel(offsetOf(now, zone.timeZone) - offsetOf(now, timeZone)),
|
|
273
|
+
DayGlyph: hour >= 6 && hour < 18 ? Sun : Moon,
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function ZoneRow({ zone, now, locale, hour12, timeZone }: ZoneRowProps) {
|
|
278
|
+
const { day, offset, DayGlyph } = zoneFacts(zone, now, timeZone)
|
|
240
279
|
return (
|
|
241
280
|
<Widget.Row
|
|
242
281
|
leading={shortTime(now, { locale, hour12, timeZone: zone.timeZone })}
|
|
243
282
|
trailing={
|
|
244
283
|
<>
|
|
245
284
|
{day && <span>{day} ·</span>}
|
|
246
|
-
<span className="tabular-nums">{
|
|
285
|
+
<span className="tabular-nums">{offset}</span>
|
|
247
286
|
<DayGlyph size={12} strokeWidth={1.5} aria-label={DayGlyph === Sun ? 'Day' : 'Night'} className="ml-1" />
|
|
248
287
|
</>
|
|
249
288
|
}
|
|
@@ -253,6 +292,100 @@ function ZoneRow({ zone, now, locale, hour12, timeZone }: ZoneRowProps) {
|
|
|
253
292
|
)
|
|
254
293
|
}
|
|
255
294
|
|
|
295
|
+
/** A world clock at the tall snap, a column: the city, the time large, its day and offset. */
|
|
296
|
+
function ZoneTile({ zone, now, locale, hour12, timeZone }: ZoneRowProps) {
|
|
297
|
+
const { day, offset, DayGlyph } = zoneFacts(zone, now, timeZone)
|
|
298
|
+
const time = timeParts(now, { locale, hour12, timeZone: zone.timeZone })
|
|
299
|
+
return (
|
|
300
|
+
<div className="flex min-w-0 flex-col gap-0.5 px-5 first:pl-0 last:pr-0">
|
|
301
|
+
<span className="truncate text-body text-foreground">{zone.city}</span>
|
|
302
|
+
<span className="flex items-baseline gap-1 whitespace-nowrap tabular-nums">
|
|
303
|
+
<span className="text-title weight-semibold text-foreground">{time.text}</span>
|
|
304
|
+
{time.period && <span className="text-caption text-muted-foreground">{time.period}</span>}
|
|
305
|
+
</span>
|
|
306
|
+
<span className="flex min-w-0 items-center gap-1.5 text-caption text-muted-foreground">
|
|
307
|
+
<DayGlyph size={12} strokeWidth={1.5} aria-label={DayGlyph === Sun ? 'Day' : 'Night'} className="shrink-0" />
|
|
308
|
+
<span className="truncate tabular-nums">
|
|
309
|
+
{day ?? 'Today'}, {offset}
|
|
310
|
+
</span>
|
|
311
|
+
</span>
|
|
312
|
+
</div>
|
|
313
|
+
)
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
interface WorldClocksProps extends Pick<ClockProps, 'locale' | 'hour12' | 'timeZone'> {
|
|
317
|
+
zones: ClockZone[]
|
|
318
|
+
now: number
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/** The tall snap's world clocks: every zone, a column each, split by hairlines. */
|
|
322
|
+
function WorldClocks({ zones, ...rest }: WorldClocksProps) {
|
|
323
|
+
return (
|
|
324
|
+
<Widget.Section label="World clock">
|
|
325
|
+
<div className="grid auto-cols-fr grid-flow-col divide-x divide-border pt-1">
|
|
326
|
+
{zones.map(zone => (
|
|
327
|
+
<ZoneTile key={zone.timeZone + zone.city} zone={zone} {...rest} />
|
|
328
|
+
))}
|
|
329
|
+
</div>
|
|
330
|
+
</Widget.Section>
|
|
331
|
+
)
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
interface CycleStripProps {
|
|
335
|
+
settings: PomodoroSettings
|
|
336
|
+
/** The phase running, by its place in the cycle: those before it fill, it fills to `progress`. Left out, nothing has run. */
|
|
337
|
+
at?: number
|
|
338
|
+
/** How far the phase at `at` has run, from 0 to 1. */
|
|
339
|
+
progress?: number
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/** One cycle as a strip, each phase as long as its minutes, in its hue. */
|
|
343
|
+
function CycleStrip({ settings, at = -1, progress = 0 }: CycleStripProps) {
|
|
344
|
+
return (
|
|
345
|
+
<div aria-hidden className="flex h-1.5 w-full gap-1">
|
|
346
|
+
{cycleOf(settings).map((step, i) => (
|
|
347
|
+
<span
|
|
348
|
+
key={`${step.phase}-${step.round}`}
|
|
349
|
+
className={cn('relative basis-0 overflow-hidden rounded-full', i < at ? DOT[step.phase] : WASH[step.phase])}
|
|
350
|
+
style={{ flexGrow: lengthOf(step.phase, settings) }}
|
|
351
|
+
>
|
|
352
|
+
{i === at && (
|
|
353
|
+
<span
|
|
354
|
+
className={cn('absolute inset-y-0 left-0', DOT[step.phase])}
|
|
355
|
+
style={{ width: `${progress * 100}%` }}
|
|
356
|
+
/>
|
|
357
|
+
)}
|
|
358
|
+
</span>
|
|
359
|
+
))}
|
|
360
|
+
</div>
|
|
361
|
+
)
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/** Today's finished focus rounds: a dot for each, the cycle's open ones washed, and the time focused. */
|
|
365
|
+
function Today({ completed, settings }: { completed: number; settings: PomodoroSettings }) {
|
|
366
|
+
const slots = Math.min(24, Math.max(1, Math.ceil(completed / settings.rounds)) * settings.rounds)
|
|
367
|
+
return (
|
|
368
|
+
<Widget.Section
|
|
369
|
+
label="Today"
|
|
370
|
+
trailing={
|
|
371
|
+
<span className="tabular-nums">
|
|
372
|
+
{completed} {completed === 1 ? 'round' : 'rounds'} · {minutesLabel(completed * settings.focus)} focused
|
|
373
|
+
</span>
|
|
374
|
+
}
|
|
375
|
+
>
|
|
376
|
+
<div className="flex flex-wrap items-center gap-1.5 py-1">
|
|
377
|
+
{Array.from({ length: slots }, (_, slot) => slot).map(slot => (
|
|
378
|
+
<span
|
|
379
|
+
key={slot}
|
|
380
|
+
aria-hidden
|
|
381
|
+
className={cn('size-2.5 rounded-full', slot < completed ? DOT.focus : WASH.focus)}
|
|
382
|
+
/>
|
|
383
|
+
))}
|
|
384
|
+
</div>
|
|
385
|
+
</Widget.Section>
|
|
386
|
+
)
|
|
387
|
+
}
|
|
388
|
+
|
|
256
389
|
interface RingProps {
|
|
257
390
|
run: PomodoroRun
|
|
258
391
|
rounds?: number
|
|
@@ -357,7 +490,11 @@ function ClockPhaseDone({ ended, pomodoro, onStart }: ClockPhaseDoneProps) {
|
|
|
357
490
|
)
|
|
358
491
|
}
|
|
359
492
|
|
|
360
|
-
interface RunningProps
|
|
493
|
+
interface RunningProps
|
|
494
|
+
extends Pick<
|
|
495
|
+
ClockProps,
|
|
496
|
+
'zones' | 'locale' | 'hour12' | 'timeZone' | 'onPhaseEnd' | 'completedToday' | 'layout' | 'className'
|
|
497
|
+
> {
|
|
361
498
|
run: PomodoroRun
|
|
362
499
|
settings: PomodoroSettings
|
|
363
500
|
onChange: (run: PomodoroRun | null) => void
|
|
@@ -377,7 +514,19 @@ function schedule(run: PomodoroRun, start: number, settings: PomodoroSettings, c
|
|
|
377
514
|
return phases
|
|
378
515
|
}
|
|
379
516
|
|
|
380
|
-
function Running({
|
|
517
|
+
function Running({
|
|
518
|
+
run,
|
|
519
|
+
settings,
|
|
520
|
+
onChange,
|
|
521
|
+
onPhaseEnd,
|
|
522
|
+
zones = [],
|
|
523
|
+
locale,
|
|
524
|
+
hour12,
|
|
525
|
+
timeZone,
|
|
526
|
+
completedToday,
|
|
527
|
+
layout = 'fit',
|
|
528
|
+
className,
|
|
529
|
+
}: RunningProps) {
|
|
381
530
|
const left = useLeft(run)
|
|
382
531
|
const running = run.endsAt !== undefined
|
|
383
532
|
const now = running ? (run.endsAt ?? 0) - left : Date.now()
|
|
@@ -402,6 +551,104 @@ function Running({ run, settings, onChange, onPhaseEnd, locale, hour12, timeZone
|
|
|
402
551
|
next.phase === 'focus'
|
|
403
552
|
? `${phaseName(next, settings.rounds)} next`
|
|
404
553
|
: `${lengthOf(next.phase, settings) / MINUTE} min ${next.phase === 'long-break' ? 'long break' : 'break'} next`
|
|
554
|
+
const figure = <Widget.Figure value={formatClock(Math.ceil(left / SECOND))} />
|
|
555
|
+
const controls = (
|
|
556
|
+
<div className="-mr-1 flex shrink-0 items-center gap-1">
|
|
557
|
+
<Widget.Action icon={Plus} label="Add a minute" onClick={() => onChange(addMinute(run))} />
|
|
558
|
+
<Widget.Action
|
|
559
|
+
icon={running ? Pause : Play}
|
|
560
|
+
label={running ? 'Pause' : ready ? 'Start' : 'Resume'}
|
|
561
|
+
emphasis="primary"
|
|
562
|
+
filled
|
|
563
|
+
onClick={() => onChange(running ? pause(run, left) : resumePomodoro(run))}
|
|
564
|
+
/>
|
|
565
|
+
<Widget.Action
|
|
566
|
+
icon={SkipForward}
|
|
567
|
+
label={next.phase === 'focus' ? 'Skip to focus' : 'Skip to break'}
|
|
568
|
+
filled
|
|
569
|
+
onClick={() => onChange(resumePomodoro(advancePomodoro(run, settings)))}
|
|
570
|
+
/>
|
|
571
|
+
</div>
|
|
572
|
+
)
|
|
573
|
+
const header = (
|
|
574
|
+
<Widget.Header
|
|
575
|
+
icon={Timer}
|
|
576
|
+
trailing={<Widget.Action icon={RotateCcw} label="Reset" onClick={() => onChange(null)} />}
|
|
577
|
+
>
|
|
578
|
+
Pomodoro
|
|
579
|
+
</Widget.Header>
|
|
580
|
+
)
|
|
581
|
+
const phase = (
|
|
582
|
+
<div className="flex min-w-0 flex-col gap-0.5">
|
|
583
|
+
<Widget.Title leading={<span aria-hidden className={cn('size-2.5 shrink-0 rounded-full', DOT[run.phase])} />}>
|
|
584
|
+
{phaseName(run, settings.rounds)}
|
|
585
|
+
</Widget.Title>
|
|
586
|
+
<Widget.Meta className="pl-4.5">
|
|
587
|
+
<Widget.MetaItem icon={running ? Clock3 : Pause}>{status}</Widget.MetaItem>
|
|
588
|
+
<Widget.MetaItem icon={GLYPH[next.phase]}>{nextLabel}</Widget.MetaItem>
|
|
589
|
+
</Widget.Meta>
|
|
590
|
+
</div>
|
|
591
|
+
)
|
|
592
|
+
|
|
593
|
+
if (layout === 'tall') {
|
|
594
|
+
const cycle = cycleOf(settings)
|
|
595
|
+
const at = indexIn(run, settings)
|
|
596
|
+
const starts: number[] = []
|
|
597
|
+
let when = ends
|
|
598
|
+
for (const step of cycle.slice(at + 1)) {
|
|
599
|
+
starts.push(when)
|
|
600
|
+
when += lengthOf(step.phase, settings)
|
|
601
|
+
}
|
|
602
|
+
return (
|
|
603
|
+
<Widget.Sheet className={className}>
|
|
604
|
+
<div className="flex min-w-0 items-center gap-8">
|
|
605
|
+
<PhaseRing run={run} rounds={settings.rounds} className="size-36 shrink-0" />
|
|
606
|
+
<div className="flex min-w-0 flex-1 flex-col gap-1">
|
|
607
|
+
{header}
|
|
608
|
+
<div className="flex min-w-0 items-center justify-between gap-3">
|
|
609
|
+
{figure}
|
|
610
|
+
{controls}
|
|
611
|
+
</div>
|
|
612
|
+
{phase}
|
|
613
|
+
</div>
|
|
614
|
+
</div>
|
|
615
|
+
|
|
616
|
+
<Widget.Section
|
|
617
|
+
label="This cycle"
|
|
618
|
+
trailing={<span className="tabular-nums">Ends at {shortTime(when, options)}</span>}
|
|
619
|
+
>
|
|
620
|
+
<div className="pt-1 pb-2">
|
|
621
|
+
<CycleStrip settings={settings} at={at} progress={run.total ? 1 - left / run.total : 0} />
|
|
622
|
+
</div>
|
|
623
|
+
<div className="grid grid-cols-2 gap-x-8">
|
|
624
|
+
{cycle.map((step, i) => (
|
|
625
|
+
<Widget.Row
|
|
626
|
+
key={`${step.phase}-${step.round}`}
|
|
627
|
+
leading={i < at ? 'Done' : i === at ? 'Now' : shortTime(starts[i - at - 1] ?? when, options)}
|
|
628
|
+
color={MARK[step.phase]}
|
|
629
|
+
trailing={
|
|
630
|
+
i < at ? (
|
|
631
|
+
<Check size={14} strokeWidth={1.5} aria-label="Done" />
|
|
632
|
+
) : i === at ? (
|
|
633
|
+
`${formatClock(Math.ceil(left / SECOND))} left`
|
|
634
|
+
) : (
|
|
635
|
+
`${lengthOf(step.phase, settings) / MINUTE} min`
|
|
636
|
+
)
|
|
637
|
+
}
|
|
638
|
+
>
|
|
639
|
+
{phaseName(step, settings.rounds)}
|
|
640
|
+
</Widget.Row>
|
|
641
|
+
))}
|
|
642
|
+
</div>
|
|
643
|
+
</Widget.Section>
|
|
644
|
+
|
|
645
|
+
{completedToday !== undefined && <Today completed={completedToday} settings={settings} />}
|
|
646
|
+
{zones.length > 0 && (
|
|
647
|
+
<WorldClocks zones={zones} now={now} locale={locale} hour12={hour12} timeZone={timeZone} />
|
|
648
|
+
)}
|
|
649
|
+
</Widget.Sheet>
|
|
650
|
+
)
|
|
651
|
+
}
|
|
405
652
|
|
|
406
653
|
return (
|
|
407
654
|
<Widget
|
|
@@ -425,40 +672,12 @@ function Running({ run, settings, onChange, onPhaseEnd, locale, hour12, timeZone
|
|
|
425
672
|
</Widget.Section>
|
|
426
673
|
}
|
|
427
674
|
>
|
|
428
|
-
|
|
429
|
-
icon={Timer}
|
|
430
|
-
trailing={<Widget.Action icon={RotateCcw} label="Reset" onClick={() => onChange(null)} />}
|
|
431
|
-
>
|
|
432
|
-
Pomodoro
|
|
433
|
-
</Widget.Header>
|
|
675
|
+
{header}
|
|
434
676
|
<div className="flex min-w-0 items-center justify-between gap-3">
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
<Widget.Action icon={Plus} label="Add a minute" onClick={() => onChange(addMinute(run))} />
|
|
438
|
-
<Widget.Action
|
|
439
|
-
icon={running ? Pause : Play}
|
|
440
|
-
label={running ? 'Pause' : ready ? 'Start' : 'Resume'}
|
|
441
|
-
emphasis="primary"
|
|
442
|
-
filled
|
|
443
|
-
onClick={() => onChange(running ? pause(run, left) : resumePomodoro(run))}
|
|
444
|
-
/>
|
|
445
|
-
<Widget.Action
|
|
446
|
-
icon={SkipForward}
|
|
447
|
-
label={next.phase === 'focus' ? 'Skip to focus' : 'Skip to break'}
|
|
448
|
-
filled
|
|
449
|
-
onClick={() => onChange(resumePomodoro(advancePomodoro(run, settings)))}
|
|
450
|
-
/>
|
|
451
|
-
</div>
|
|
452
|
-
</div>
|
|
453
|
-
<div className="flex min-w-0 flex-col gap-0.5">
|
|
454
|
-
<Widget.Title leading={<span aria-hidden className={cn('size-2.5 shrink-0 rounded-full', DOT[run.phase])} />}>
|
|
455
|
-
{phaseName(run, settings.rounds)}
|
|
456
|
-
</Widget.Title>
|
|
457
|
-
<Widget.Meta className="pl-4.5">
|
|
458
|
-
<Widget.MetaItem icon={running ? Clock3 : Pause}>{status}</Widget.MetaItem>
|
|
459
|
-
<Widget.MetaItem icon={GLYPH[next.phase]}>{nextLabel}</Widget.MetaItem>
|
|
460
|
-
</Widget.Meta>
|
|
677
|
+
{figure}
|
|
678
|
+
{controls}
|
|
461
679
|
</div>
|
|
680
|
+
{phase}
|
|
462
681
|
</Widget>
|
|
463
682
|
)
|
|
464
683
|
}
|
|
@@ -491,6 +710,16 @@ function Running({ run, settings, onChange, onPhaseEnd, locale, hour12, timeZone
|
|
|
491
710
|
* `advancePomodoro` and `resumePomodoro` build the same runs for a host
|
|
492
711
|
* that keeps time itself.
|
|
493
712
|
*
|
|
713
|
+
* At the open island's tall snap (`layout="tall"`) it becomes a sheet: the
|
|
714
|
+
* time and the date as the hero with Start focus beside them; every world
|
|
715
|
+
* clock as a column, the city, the time large, and its day, offset and
|
|
716
|
+
* whether it's day or night there; the Pomodoro's whole cycle as a strip, each phase
|
|
717
|
+
* as long as its minutes in its hue, over its three lengths in columns;
|
|
718
|
+
* and today's finished rounds (`completedToday`) as dots with the time
|
|
719
|
+
* focused. A run puts its ring large beside the time left and the
|
|
720
|
+
* controls, then lists every phase of its cycle, done, now and when each
|
|
721
|
+
* starts, under the strip filling as it goes.
|
|
722
|
+
*
|
|
494
723
|
* The other forms are parts: `Clock.Leading` and `Clock.Trailing` for the
|
|
495
724
|
* compact island's wings (the ring and `mm:ss`, nothing without a run),
|
|
496
725
|
* `Clock.Minimal`, the ring, for the split island's bubble, and
|
|
@@ -512,6 +741,8 @@ const Clock = Object.assign(
|
|
|
512
741
|
defaultValue = null,
|
|
513
742
|
onValueChange,
|
|
514
743
|
onPhaseEnd,
|
|
744
|
+
completedToday,
|
|
745
|
+
layout = 'fit',
|
|
515
746
|
className,
|
|
516
747
|
}: ClockProps) {
|
|
517
748
|
const [run, setRun] = useControllableState(value, defaultValue, onValueChange)
|
|
@@ -525,6 +756,9 @@ const Clock = Object.assign(
|
|
|
525
756
|
settings={settings}
|
|
526
757
|
onChange={setRun}
|
|
527
758
|
onPhaseEnd={onPhaseEnd}
|
|
759
|
+
zones={zones}
|
|
760
|
+
completedToday={completedToday}
|
|
761
|
+
layout={layout}
|
|
528
762
|
locale={locale}
|
|
529
763
|
hour12={hour12}
|
|
530
764
|
timeZone={timeZone}
|
|
@@ -539,6 +773,88 @@ const Clock = Object.assign(
|
|
|
539
773
|
const zoneName = new Intl.DateTimeFormat(locale, { timeZone, timeZoneName: 'long' })
|
|
540
774
|
.formatToParts(now)
|
|
541
775
|
.find(part => part.type === 'timeZoneName')?.value
|
|
776
|
+
const figure = (
|
|
777
|
+
<Widget.Figure
|
|
778
|
+
value={
|
|
779
|
+
<>
|
|
780
|
+
{time.text}
|
|
781
|
+
{second && <span className="text-muted-foreground">:{second.padStart(2, '0')}</span>}
|
|
782
|
+
</>
|
|
783
|
+
}
|
|
784
|
+
unit={time.period}
|
|
785
|
+
/>
|
|
786
|
+
)
|
|
787
|
+
const start = pomodoro !== false && (
|
|
788
|
+
<Button
|
|
789
|
+
variant="secondary"
|
|
790
|
+
size="compact"
|
|
791
|
+
leadingIcon={Play}
|
|
792
|
+
className="mb-1"
|
|
793
|
+
onClick={() => setRun(startPomodoro(settings))}
|
|
794
|
+
>
|
|
795
|
+
Start focus
|
|
796
|
+
</Button>
|
|
797
|
+
)
|
|
798
|
+
|
|
799
|
+
if (layout === 'tall')
|
|
800
|
+
return (
|
|
801
|
+
<Widget.Sheet className={className}>
|
|
802
|
+
<div className="flex min-w-0 items-end justify-between gap-6">
|
|
803
|
+
<div className="flex min-w-0 flex-col gap-1">
|
|
804
|
+
<Widget.Header icon={CalendarDays}>{date}</Widget.Header>
|
|
805
|
+
{figure}
|
|
806
|
+
{zoneName && <Widget.Subtitle>{zoneName}</Widget.Subtitle>}
|
|
807
|
+
</div>
|
|
808
|
+
{start}
|
|
809
|
+
</div>
|
|
810
|
+
|
|
811
|
+
{zones.length > 0 && (
|
|
812
|
+
<WorldClocks zones={zones} now={now} locale={locale} hour12={hour12} timeZone={timeZone} />
|
|
813
|
+
)}
|
|
814
|
+
|
|
815
|
+
{pomodoro !== false && (
|
|
816
|
+
<Widget.Section
|
|
817
|
+
label="Pomodoro"
|
|
818
|
+
trailing={
|
|
819
|
+
<span className="tabular-nums">
|
|
820
|
+
{minutesLabel(
|
|
821
|
+
cycleOf(settings).reduce((sum, step) => sum + lengthOf(step.phase, settings), 0) / MINUTE,
|
|
822
|
+
)}{' '}
|
|
823
|
+
a cycle
|
|
824
|
+
</span>
|
|
825
|
+
}
|
|
826
|
+
>
|
|
827
|
+
<div className="pt-1 pb-3">
|
|
828
|
+
<CycleStrip settings={settings} />
|
|
829
|
+
</div>
|
|
830
|
+
<div className="grid grid-cols-3 divide-x divide-border">
|
|
831
|
+
{PHASES.map(phase => (
|
|
832
|
+
<div key={phase} className="flex min-w-0 flex-col gap-0.5 px-5 first:pl-0">
|
|
833
|
+
<span className="flex items-center gap-2 text-caption text-muted-foreground">
|
|
834
|
+
<span aria-hidden className={cn('size-2 shrink-0 rounded-full', DOT[phase])} />
|
|
835
|
+
{phase === 'focus' ? 'Focus' : phase === 'long-break' ? 'Long break' : 'Short break'}
|
|
836
|
+
</span>
|
|
837
|
+
<span className="text-title weight-semibold tabular-nums text-foreground">
|
|
838
|
+
{lengthOf(phase, settings) / MINUTE} min
|
|
839
|
+
</span>
|
|
840
|
+
<span className="truncate text-caption text-muted-foreground">
|
|
841
|
+
{phase === 'focus'
|
|
842
|
+
? `${settings.rounds} rounds`
|
|
843
|
+
: phase === 'long-break'
|
|
844
|
+
? `After round ${settings.rounds}`
|
|
845
|
+
: `Between rounds`}
|
|
846
|
+
</span>
|
|
847
|
+
</div>
|
|
848
|
+
))}
|
|
849
|
+
</div>
|
|
850
|
+
</Widget.Section>
|
|
851
|
+
)}
|
|
852
|
+
|
|
853
|
+
{pomodoro !== false && completedToday !== undefined && (
|
|
854
|
+
<Today completed={completedToday} settings={settings} />
|
|
855
|
+
)}
|
|
856
|
+
</Widget.Sheet>
|
|
857
|
+
)
|
|
542
858
|
|
|
543
859
|
return (
|
|
544
860
|
<Widget
|
|
@@ -562,26 +878,8 @@ const Clock = Object.assign(
|
|
|
562
878
|
>
|
|
563
879
|
<Widget.Header icon={CalendarDays}>{date}</Widget.Header>
|
|
564
880
|
<div className="flex min-w-0 items-end justify-between gap-3">
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
<>
|
|
568
|
-
{time.text}
|
|
569
|
-
{second && <span className="text-muted-foreground">:{second.padStart(2, '0')}</span>}
|
|
570
|
-
</>
|
|
571
|
-
}
|
|
572
|
-
unit={time.period}
|
|
573
|
-
/>
|
|
574
|
-
{pomodoro !== false && (
|
|
575
|
-
<Button
|
|
576
|
-
variant="secondary"
|
|
577
|
-
size="compact"
|
|
578
|
-
leadingIcon={Play}
|
|
579
|
-
className="mb-1"
|
|
580
|
-
onClick={() => setRun(startPomodoro(settings))}
|
|
581
|
-
>
|
|
582
|
-
Start focus
|
|
583
|
-
</Button>
|
|
584
|
-
)}
|
|
881
|
+
{figure}
|
|
882
|
+
{start}
|
|
585
883
|
</div>
|
|
586
884
|
{zoneName && <Widget.Subtitle>{zoneName}</Widget.Subtitle>}
|
|
587
885
|
{pomodoro !== false && (
|
|
@@ -66,3 +66,11 @@ A `duration` of `0` hides the scrubber.
|
|
|
66
66
|
<FlashIsland>
|
|
67
67
|
<NowPlaying.Flash track={{ ...PLAYING, title: 'Teardrop', artist: 'Massive Attack', album: 'Mezzanine', artwork: <MockArtwork variant="night" />, tint: ARTWORK_TINT.night }} />
|
|
68
68
|
</FlashIsland>
|
|
69
|
+
|
|
70
|
+
# Tall
|
|
71
|
+
|
|
72
|
+
`layout="tall"` at the island's tall snap: the artwork large, the title on the display role, the scrubber across the width with the transport under it, and where it plays from and to.
|
|
73
|
+
|
|
74
|
+
<WidgetIsland tab="now-playing" tall>
|
|
75
|
+
<NowPlaying track={PLAYING} defaultShuffle={false} defaultRepeat="all" defaultLiked layout="tall" />
|
|
76
|
+
</WidgetIsland>
|