@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
|
@@ -72,3 +72,11 @@ The next event a few minutes out: `Agenda.Leading` and `Agenda.Trailing` count d
|
|
|
72
72
|
`Agenda.Starting`, the flash a minute before.
|
|
73
73
|
|
|
74
74
|
<AgendaFlash />
|
|
75
|
+
|
|
76
|
+
# Tall
|
|
77
|
+
|
|
78
|
+
`layout="tall"` at the island's tall snap: the hero, then today and tomorrow in full, each event with its times, place and Join, then the rest of the week by day.
|
|
79
|
+
|
|
80
|
+
<WidgetIsland tab="calendar" tall>
|
|
81
|
+
<Agenda events={EVENTS} now={AGENDA_NOW} layout="tall" />
|
|
82
|
+
</WidgetIsland>
|
|
@@ -14,7 +14,7 @@ import { useControllableState } from '@justanarthur/modo-ui/lib/use-controllable
|
|
|
14
14
|
import { cn } from '@justanarthur/modo-ui/lib/utils'
|
|
15
15
|
import { CalendarCheck, CalendarDays, ChevronDown, ChevronUp, Clock, Lock, MapPin, Video } from 'lucide-react'
|
|
16
16
|
import IslandFlash from '../../../components/island/island-flash'
|
|
17
|
-
import Widget from '../../../components/island/widget'
|
|
17
|
+
import Widget, { type WidgetLayout } from '../../../components/island/widget'
|
|
18
18
|
import { formatShort, MINUTE, SECOND, useEdgeClock } from '../../../lib/clock'
|
|
19
19
|
|
|
20
20
|
type AgendaAccess = 'granted' | 'undetermined' | 'denied'
|
|
@@ -53,14 +53,27 @@ interface AgendaProps {
|
|
|
53
53
|
onRequestAccess?: () => void
|
|
54
54
|
/** Called by Open System Settings while access is denied. */
|
|
55
55
|
onOpenSettings?: () => void
|
|
56
|
-
/** Called by the next event's Join button. */
|
|
56
|
+
/** Called by the next event's Join button, and at the tall snap by every call's. */
|
|
57
57
|
onJoin?: (event: AgendaEvent) => void
|
|
58
|
+
/** `tall` is the open island's tall snap: the next event as the hero, then today and tomorrow listed in full, each event with its times, place or call and Join, then the rest of the week by day. Defaults to `'fit'`. */
|
|
59
|
+
layout?: WidgetLayout
|
|
58
60
|
/** Classes for the root, which fills its container. */
|
|
59
61
|
className?: string
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
/** Rows the timeline lists per day before it says how many more. */
|
|
63
65
|
const ROWS = 3
|
|
66
|
+
/** Days the tall layout lists, today included. */
|
|
67
|
+
const WEEK = 7
|
|
68
|
+
|
|
69
|
+
const addDays = (ms: number, days: number) => {
|
|
70
|
+
const date = new Date(ms)
|
|
71
|
+
date.setDate(date.getDate() + days)
|
|
72
|
+
return date.getTime()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Whether an event covers any of the day from `start` to `end`. */
|
|
76
|
+
const covers = (event: AgendaEvent, start: number, end: number) => event.start < end && event.end > start
|
|
64
77
|
|
|
65
78
|
const time = (ms: number, locale?: Intl.LocalesArgument) =>
|
|
66
79
|
new Date(ms).toLocaleTimeString(locale, { hour: 'numeric', minute: '2-digit' })
|
|
@@ -129,7 +142,13 @@ function When({ event, now, midnight, locale }: Omit<HeroProps, 'onJoin'>) {
|
|
|
129
142
|
if (event.start - now < 60 * MINUTE)
|
|
130
143
|
return <Widget.Figure prefix="in" value={Math.max(1, Math.ceil((event.start - now) / MINUTE))} unit="min" />
|
|
131
144
|
const { value, period } = timeParts(event.start, locale)
|
|
132
|
-
|
|
145
|
+
const prefix =
|
|
146
|
+
event.start >= addDays(midnight, 1)
|
|
147
|
+
? new Date(event.start).toLocaleDateString(locale, { weekday: 'long' })
|
|
148
|
+
: event.start >= midnight
|
|
149
|
+
? 'Tomorrow'
|
|
150
|
+
: 'at'
|
|
151
|
+
return <Widget.Figure prefix={prefix} value={value} unit={period} />
|
|
133
152
|
}
|
|
134
153
|
|
|
135
154
|
/** The next event, set as the widget's hero: how soon, its title in its calendar's color, when and where, and Join. */
|
|
@@ -171,6 +190,75 @@ function Rows({ events, locale }: { events: AgendaEvent[]; locale?: Intl.Locales
|
|
|
171
190
|
))
|
|
172
191
|
}
|
|
173
192
|
|
|
193
|
+
interface EntryProps {
|
|
194
|
+
event: AgendaEvent
|
|
195
|
+
locale?: Intl.LocalesArgument
|
|
196
|
+
onJoin?: (event: AgendaEvent) => void
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** An event in the tall layout's list: its start over its end, its calendar's mark, the title over how long and where, and Join for a call. */
|
|
200
|
+
function Entry({ event, locale, onJoin }: EntryProps) {
|
|
201
|
+
return (
|
|
202
|
+
<div className="flex min-w-0 items-center gap-2.5 py-1.5">
|
|
203
|
+
<span className="flex w-15 shrink-0 flex-col whitespace-nowrap text-caption tabular-nums">
|
|
204
|
+
<span className="text-foreground">{time(event.start, locale)}</span>
|
|
205
|
+
<span className="text-muted-foreground">{time(event.end, locale)}</span>
|
|
206
|
+
</span>
|
|
207
|
+
<span
|
|
208
|
+
aria-hidden
|
|
209
|
+
className="w-0.75 shrink-0 self-stretch rounded-full"
|
|
210
|
+
style={{ backgroundColor: event.color }}
|
|
211
|
+
/>
|
|
212
|
+
<span className="flex min-w-0 flex-1 flex-col">
|
|
213
|
+
<span className="truncate text-body text-foreground">{event.title}</span>
|
|
214
|
+
<Widget.Meta>
|
|
215
|
+
<Widget.MetaItem icon={Clock}>{length(event.end - event.start)}</Widget.MetaItem>
|
|
216
|
+
{event.meetingUrl && <Widget.MetaItem icon={Video}>Video call</Widget.MetaItem>}
|
|
217
|
+
{event.location && <Widget.MetaItem icon={MapPin}>{event.location}</Widget.MetaItem>}
|
|
218
|
+
</Widget.Meta>
|
|
219
|
+
</span>
|
|
220
|
+
{event.meetingUrl && (
|
|
221
|
+
<Button variant="secondary" size="compact" leadingIcon={Video} onClick={() => onJoin?.(event)}>
|
|
222
|
+
Join
|
|
223
|
+
</Button>
|
|
224
|
+
)}
|
|
225
|
+
</div>
|
|
226
|
+
)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
interface DayProps {
|
|
230
|
+
label: string
|
|
231
|
+
/** The day's timed events, in order. */
|
|
232
|
+
events: AgendaEvent[]
|
|
233
|
+
/** The day's all-day events: chips on the label's line. */
|
|
234
|
+
allDay?: AgendaEvent[]
|
|
235
|
+
/** What to say when the day has no timed events. */
|
|
236
|
+
empty?: string
|
|
237
|
+
locale?: Intl.LocalesArgument
|
|
238
|
+
onJoin?: (event: AgendaEvent) => void
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** A day of the tall layout's list: its name with its all-day chips, then its events. */
|
|
242
|
+
function Day({ label, events, allDay = [], empty, locale, onJoin }: DayProps) {
|
|
243
|
+
return (
|
|
244
|
+
<Widget.Section
|
|
245
|
+
label={label}
|
|
246
|
+
trailing={allDay.map(event => (
|
|
247
|
+
<Widget.Chip key={event.id} color={event.color}>
|
|
248
|
+
{event.title}
|
|
249
|
+
</Widget.Chip>
|
|
250
|
+
))}
|
|
251
|
+
>
|
|
252
|
+
{events.map(event => (
|
|
253
|
+
<Entry key={event.id} event={event} locale={locale} onJoin={onJoin} />
|
|
254
|
+
))}
|
|
255
|
+
{!events.length && empty && (
|
|
256
|
+
<span className="flex h-7 items-center text-body text-muted-foreground">{empty}</span>
|
|
257
|
+
)}
|
|
258
|
+
</Widget.Section>
|
|
259
|
+
)
|
|
260
|
+
}
|
|
261
|
+
|
|
174
262
|
function More({ count }: { count: number }) {
|
|
175
263
|
if (count <= 0) return null
|
|
176
264
|
return <span className="flex h-6 items-center pl-17.5 text-caption text-muted-foreground">{count} more</span>
|
|
@@ -283,6 +371,14 @@ function AgendaStarting({ event, onJoin }: Omit<ActivityProps, 'locale'>) {
|
|
|
283
371
|
* (`tomorrowOpen` / `onTomorrowOpenChange`, or kept here). Ended events drop
|
|
284
372
|
* off; `now` follows the clock on each minute unless you pin it.
|
|
285
373
|
*
|
|
374
|
+
* At the open island's tall snap (`layout="tall"`) it becomes a sheet: the
|
|
375
|
+
* date and the hero as above, then the rest of today and all of tomorrow
|
|
376
|
+
* listed in full, each event with its start over its end, its calendar's
|
|
377
|
+
* mark, the title over how long it runs and where (or that it's a call),
|
|
378
|
+
* and Join for every call; then the rest of the week, a section per day
|
|
379
|
+
* with events, named by its weekday and date, its all-day events as chips
|
|
380
|
+
* on the name's line.
|
|
381
|
+
*
|
|
286
382
|
* Before the calendar may be read it asks to connect
|
|
287
383
|
* (`access="undetermined"`), and when access is off it says where to turn it
|
|
288
384
|
* on (`"denied"`).
|
|
@@ -309,6 +405,7 @@ const Agenda = Object.assign(
|
|
|
309
405
|
onRequestAccess,
|
|
310
406
|
onOpenSettings,
|
|
311
407
|
onJoin,
|
|
408
|
+
layout = 'fit',
|
|
312
409
|
className,
|
|
313
410
|
}: AgendaProps) {
|
|
314
411
|
const ticking = useEdgeClock(0, nowProp === undefined, MINUTE)
|
|
@@ -351,7 +448,8 @@ const Agenda = Object.assign(
|
|
|
351
448
|
|
|
352
449
|
const midnight = new Date(now).setHours(24, 0, 0, 0)
|
|
353
450
|
const next = new Date(midnight).setHours(24, 0, 0, 0)
|
|
354
|
-
const
|
|
451
|
+
const until = layout === 'tall' ? addDays(midnight, WEEK - 1) : next
|
|
452
|
+
const live = events.filter(event => event.end > now && event.start < until).sort((a, b) => a.start - b.start)
|
|
355
453
|
const allDay = live.filter(event => event.allDay && event.start < midnight)
|
|
356
454
|
const timed = live.filter(event => !event.allDay)
|
|
357
455
|
const [hero] = timed
|
|
@@ -369,9 +467,68 @@ const Agenda = Object.assign(
|
|
|
369
467
|
)
|
|
370
468
|
|
|
371
469
|
const today = timed.filter(event => event !== hero && event.start < midnight)
|
|
372
|
-
const tomorrow = timed.filter(event => event !== hero && event.start >= midnight)
|
|
470
|
+
const tomorrow = timed.filter(event => event !== hero && event.start >= midnight && event.start < next)
|
|
373
471
|
const tomorrowShown = tomorrowOpen ? tomorrow.slice(0, ROWS) : tomorrow.slice(0, 1)
|
|
374
472
|
const date = new Date(now).toLocaleDateString(locale, { weekday: 'long', month: 'long', day: 'numeric' })
|
|
473
|
+
const header = (
|
|
474
|
+
<Widget.Header
|
|
475
|
+
icon={CalendarDays}
|
|
476
|
+
trailing={allDay.map(event => (
|
|
477
|
+
<Widget.Chip key={event.id} color={event.color}>
|
|
478
|
+
{event.title}
|
|
479
|
+
</Widget.Chip>
|
|
480
|
+
))}
|
|
481
|
+
>
|
|
482
|
+
{date}
|
|
483
|
+
</Widget.Header>
|
|
484
|
+
)
|
|
485
|
+
const heroBlock = <Hero event={hero} now={now} midnight={midnight} locale={locale} onJoin={onJoin} />
|
|
486
|
+
|
|
487
|
+
if (layout === 'tall') {
|
|
488
|
+
const later = Array.from({ length: WEEK - 2 }, (_, i) => {
|
|
489
|
+
const start = addDays(next, i)
|
|
490
|
+
const end = addDays(next, i + 1)
|
|
491
|
+
return {
|
|
492
|
+
start,
|
|
493
|
+
events: timed.filter(event => event !== hero && event.start >= start && event.start < end),
|
|
494
|
+
allDay: live.filter(event => event.allDay && covers(event, start, end)),
|
|
495
|
+
}
|
|
496
|
+
}).filter(day => day.events.length || day.allDay.length)
|
|
497
|
+
return (
|
|
498
|
+
<Widget.Sheet className={className}>
|
|
499
|
+
<div className="flex min-w-0 flex-col gap-2">
|
|
500
|
+
{header}
|
|
501
|
+
{heroBlock}
|
|
502
|
+
</div>
|
|
503
|
+
|
|
504
|
+
<div className="flex min-w-0 flex-col gap-3">
|
|
505
|
+
<Day label="Later today" events={today} empty="Nothing else today" locale={locale} onJoin={onJoin} />
|
|
506
|
+
<Day
|
|
507
|
+
label="Tomorrow"
|
|
508
|
+
events={tomorrow}
|
|
509
|
+
allDay={live.filter(event => event.allDay && covers(event, midnight, next))}
|
|
510
|
+
empty="Nothing planned"
|
|
511
|
+
locale={locale}
|
|
512
|
+
onJoin={onJoin}
|
|
513
|
+
/>
|
|
514
|
+
{later.map(day => (
|
|
515
|
+
<Day
|
|
516
|
+
key={day.start}
|
|
517
|
+
label={new Date(day.start).toLocaleDateString(locale, {
|
|
518
|
+
weekday: 'long',
|
|
519
|
+
month: 'long',
|
|
520
|
+
day: 'numeric',
|
|
521
|
+
})}
|
|
522
|
+
events={day.events}
|
|
523
|
+
allDay={day.allDay}
|
|
524
|
+
locale={locale}
|
|
525
|
+
onJoin={onJoin}
|
|
526
|
+
/>
|
|
527
|
+
))}
|
|
528
|
+
</div>
|
|
529
|
+
</Widget.Sheet>
|
|
530
|
+
)
|
|
531
|
+
}
|
|
375
532
|
|
|
376
533
|
return (
|
|
377
534
|
<Widget
|
|
@@ -412,17 +569,8 @@ const Agenda = Object.assign(
|
|
|
412
569
|
</>
|
|
413
570
|
}
|
|
414
571
|
>
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
trailing={allDay.map(event => (
|
|
418
|
-
<Widget.Chip key={event.id} color={event.color}>
|
|
419
|
-
{event.title}
|
|
420
|
-
</Widget.Chip>
|
|
421
|
-
))}
|
|
422
|
-
>
|
|
423
|
-
{date}
|
|
424
|
-
</Widget.Header>
|
|
425
|
-
<Hero event={hero} now={now} midnight={midnight} locale={locale} onJoin={onJoin} />
|
|
572
|
+
{header}
|
|
573
|
+
{heroBlock}
|
|
426
574
|
</Widget>
|
|
427
575
|
)
|
|
428
576
|
},
|
|
@@ -71,3 +71,19 @@ A paused phase keeps the time it had left and says so.
|
|
|
71
71
|
# Break over
|
|
72
72
|
|
|
73
73
|
<PhaseDoneFlash ended={{ phase: 'short-break', round: 2 }} />
|
|
74
|
+
|
|
75
|
+
# Tall
|
|
76
|
+
|
|
77
|
+
`layout="tall"` at the island's tall snap: the time large, every world clock as a column, the Pomodoro's whole cycle as a strip over its three lengths, and today's finished rounds (`completedToday`).
|
|
78
|
+
|
|
79
|
+
<WidgetIsland tab="clock" tall>
|
|
80
|
+
<Clock zones={ZONES} now={CLOCK_NOW} completedToday={3} layout="tall" />
|
|
81
|
+
</WidgetIsland>
|
|
82
|
+
|
|
83
|
+
# Tall, in focus
|
|
84
|
+
|
|
85
|
+
A run at the tall snap: the ring large beside the time left, then every phase of the cycle, done, now and when each starts.
|
|
86
|
+
|
|
87
|
+
<WidgetIsland tab="clock" tall>
|
|
88
|
+
<FocusClock completedToday={5} layout="tall" />
|
|
89
|
+
</WidgetIsland>
|