@justanarthur/modo-ui-notch 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +75 -2
- package/blocks/activities/agenda/examples.mdx +58 -0
- package/blocks/activities/agenda/index.tsx +332 -0
- package/blocks/activities/now-playing/examples.mdx +49 -0
- package/blocks/activities/now-playing/index.tsx +218 -0
- package/blocks/activities/shelf/examples.mdx +33 -0
- package/blocks/activities/shelf/index.tsx +289 -0
- package/blocks/activities/timer/examples.mdx +52 -0
- package/blocks/activities/timer/index.tsx +292 -0
- package/blocks/app/expanded-island/examples.mdx +45 -0
- package/blocks/app/expanded-island/index.tsx +127 -0
- package/blocks/app/settings-window/examples.mdx +30 -0
- package/blocks/app/settings-window/index.tsx +357 -0
- package/blocks/system/controls/examples.mdx +34 -0
- package/blocks/system/controls/index.tsx +167 -0
- package/blocks/system/devices/examples.mdx +25 -0
- package/blocks/system/devices/index.tsx +172 -0
- package/blocks/system/power-alert/examples.mdx +32 -0
- package/blocks/system/power-alert/index.tsx +89 -0
- package/blocks/system/system-stats/examples.mdx +23 -0
- package/blocks/system/system-stats/index.tsx +178 -0
- package/components/indicators/battery-glyph/examples.mdx +22 -0
- package/components/indicators/battery-glyph/index.tsx +91 -0
- package/components/indicators/countdown/examples.mdx +25 -0
- package/components/indicators/countdown/index.tsx +83 -0
- package/components/indicators/equalizer/examples.mdx +20 -0
- package/components/indicators/equalizer/index.tsx +116 -0
- package/components/indicators/media-scrubber/examples.mdx +21 -0
- package/components/indicators/media-scrubber/index.tsx +98 -0
- package/components/island/island/examples.mdx +57 -0
- package/components/island/island/index.tsx +415 -0
- package/components/island/island-flash/examples.mdx +55 -0
- package/components/island/island-flash/index.tsx +79 -0
- package/components/island/island-tabs/examples.mdx +53 -0
- package/components/island/island-tabs/index.tsx +285 -0
- package/dist/blocks/activities/agenda/index.d.ts +2 -0
- package/dist/blocks/activities/agenda/index.js +21 -0
- package/dist/blocks/activities/now-playing/index.d.ts +2 -0
- package/dist/blocks/activities/now-playing/index.js +22 -0
- package/dist/blocks/activities/shelf/index.d.ts +2 -0
- package/dist/blocks/activities/shelf/index.js +14 -0
- package/dist/blocks/activities/timer/index.d.ts +2 -0
- package/dist/blocks/activities/timer/index.js +19 -0
- package/dist/blocks/app/expanded-island/index.d.ts +3 -0
- package/dist/blocks/app/expanded-island/index.js +10 -0
- package/dist/blocks/app/settings-window/index.d.ts +2 -0
- package/dist/blocks/app/settings-window/index.js +7 -0
- package/dist/blocks/system/controls/index.d.ts +2 -0
- package/dist/blocks/system/controls/index.js +10 -0
- package/dist/blocks/system/devices/index.d.ts +2 -0
- package/dist/blocks/system/devices/index.js +12 -0
- package/dist/blocks/system/power-alert/index.d.ts +2 -0
- package/dist/blocks/system/power-alert/index.js +9 -0
- package/dist/blocks/system/system-stats/index.d.ts +2 -0
- package/dist/blocks/system/system-stats/index.js +12 -0
- package/dist/components/indicators/battery-glyph/index.d.ts +2 -0
- package/dist/components/indicators/battery-glyph/index.js +9 -0
- package/dist/components/indicators/countdown/index.d.ts +2 -0
- package/dist/components/indicators/countdown/index.js +8 -0
- package/dist/components/indicators/equalizer/index.d.ts +2 -0
- package/dist/components/indicators/equalizer/index.js +7 -0
- package/dist/components/indicators/media-scrubber/index.d.ts +2 -0
- package/dist/components/indicators/media-scrubber/index.js +8 -0
- package/dist/components/island/island/index.d.ts +3 -0
- package/dist/components/island/island/index.js +10 -0
- package/dist/components/island/island-flash/index.d.ts +2 -0
- package/dist/components/island/island-flash/index.js +7 -0
- package/dist/components/island/island-tabs/index.d.ts +2 -0
- package/dist/components/island/island-tabs/index.js +9 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +151 -0
- package/dist/lib/clock.d.ts +2 -0
- package/dist/lib/clock.js +14 -0
- package/dist/lib/geometry.d.ts +2 -0
- package/dist/lib/geometry.js +24 -0
- package/dist/lib/island-context.d.ts +3 -0
- package/dist/lib/island-context.js +8 -0
- package/dist/lib/motion.d.ts +21 -0
- package/dist/lib/motion.js +16 -0
- package/dist/shared/chunk-152gpyq3.d.ts +13 -0
- package/dist/shared/chunk-2f7zxrbk.js +65 -0
- package/dist/shared/chunk-2qpcsv5h.d.ts +45 -0
- package/dist/shared/chunk-2s4q6mt0.js +27 -0
- package/dist/shared/chunk-45gytfr1.d.ts +84 -0
- package/dist/shared/chunk-502rmtap.js +54 -0
- package/dist/shared/chunk-50ffk4r7.d.ts +69 -0
- package/dist/shared/chunk-52gb3g6r.d.ts +12 -0
- package/dist/shared/chunk-5en5aaj1.d.ts +33 -0
- package/dist/shared/chunk-5w0yck07.d.ts +32 -0
- package/dist/shared/chunk-6c1jbefs.d.ts +36 -0
- package/dist/shared/chunk-78w7qwp0.js +58 -0
- package/dist/shared/chunk-7hr53mby.js +116 -0
- package/dist/shared/chunk-9nhpg9t8.d.ts +47 -0
- package/dist/shared/chunk-b8jb1w72.js +145 -0
- package/dist/shared/chunk-cfzmfnyh.d.ts +63 -0
- package/dist/shared/chunk-cpewy6yg.js +178 -0
- package/dist/shared/chunk-d5qm9cps.js +10 -0
- package/dist/shared/chunk-e3e4s4ds.d.ts +77 -0
- package/dist/shared/chunk-enm6td0p.js +280 -0
- package/dist/shared/chunk-fvedaas2.d.ts +33 -0
- package/dist/shared/chunk-gb56m10p.js +39 -0
- package/dist/shared/chunk-gex38j8x.d.ts +82 -0
- package/dist/shared/chunk-hpsabfsd.d.ts +75 -0
- package/dist/shared/chunk-hrpxbqmx.d.ts +28 -0
- package/dist/shared/chunk-hwtxpzg0.js +69 -0
- package/dist/shared/chunk-mp1nx0ez.js +101 -0
- package/dist/shared/chunk-phb53x1f.js +252 -0
- package/dist/shared/chunk-r8esmjfs.d.ts +42 -0
- package/dist/shared/chunk-rcp1g9ca.js +70 -0
- package/dist/shared/chunk-rpfwv3pz.js +209 -0
- package/dist/shared/chunk-rr5e0g15.d.ts +35 -0
- package/dist/shared/chunk-rx9sphz2.js +266 -0
- package/dist/shared/chunk-s33y1pcq.js +305 -0
- package/dist/shared/chunk-sbnrhy5m.js +331 -0
- package/dist/shared/chunk-w48eyvfr.d.ts +56 -0
- package/dist/shared/chunk-wwjxs75m.js +74 -0
- package/dist/shared/chunk-xdeek16r.d.ts +58 -0
- package/dist/shared/chunk-xkzjk1tq.js +206 -0
- package/dist/shared/chunk-yngkkxz2.d.ts +88 -0
- package/dist/shared/chunk-zvh0d3qb.js +63 -0
- package/dist/styles.css +222 -0
- package/index.ts +21 -0
- package/lib/clock.ts +53 -0
- package/lib/geometry.ts +130 -0
- package/lib/island-context.tsx +24 -0
- package/lib/motion.ts +42 -0
- package/mock/activities.tsx +100 -0
- package/mock/artwork.tsx +25 -0
- package/mock/data.ts +153 -0
- package/mock/desktop.tsx +83 -0
- package/mock/fit.ts +26 -0
- package/mock/island-content.tsx +217 -0
- package/mock/scene.tsx +52 -0
- package/mock/settings.tsx +210 -0
- package/package.json +117 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 justAnArthur
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,76 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @justanarthur/modo-ui-notch
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The UI of a macOS notch app on [modo-ui](https://www.npmjs.com/package/@justanarthur/modo-ui): the island
|
|
4
|
+
that grows out of the notch (idle, compact, split, expanded, flash), its icon tabs across the wings around
|
|
5
|
+
the notch, and the pieces its activities show. Presentational: every component takes its data and
|
|
6
|
+
callbacks as props, so it fits any host (a Tauri or Electron panel, a web mock-up).
|
|
7
|
+
|
|
8
|
+
Docs and live examples: https://justanarthur.github.io/modo/notch/
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install @justanarthur/modo-ui-notch @justanarthur/modo-ui react react-dom
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
`@justanarthur/modo-ui`, `react` and `react-dom` are peers: the kit uses your copy of modo-ui, so its
|
|
17
|
+
contexts (size, shape, surface) are the ones your app provides.
|
|
18
|
+
|
|
19
|
+
## Styles
|
|
20
|
+
|
|
21
|
+
Load modo-ui's stylesheet, then the kit's utilities:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import '@justanarthur/modo-ui/styles.css'
|
|
25
|
+
import '@justanarthur/modo-ui-notch/styles.css'
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
On UnoCSS or Tailwind, scan the kit's `dist/` with modo-ui's preset instead (see modo-ui's README).
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { Equalizer, Island, IslandFlash, IslandTabs } from '@justanarthur/modo-ui-notch'
|
|
34
|
+
|
|
35
|
+
export function NotchPanel({ state, onStateChange }) {
|
|
36
|
+
return (
|
|
37
|
+
<Island
|
|
38
|
+
state={state}
|
|
39
|
+
onStateChange={onStateChange}
|
|
40
|
+
expandOnHover
|
|
41
|
+
leading={<Artwork />}
|
|
42
|
+
trailing={<Equalizer playing />}
|
|
43
|
+
flash={<IslandFlash title="Charging" caption="38 min until full" value="82%" tone="success" />}
|
|
44
|
+
expanded={<Panel />}
|
|
45
|
+
/>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
| Export | What it is |
|
|
51
|
+
|---|---|
|
|
52
|
+
| `Island` | The black outline hanging from the top edge, its five states, the compact wings, the split bubble that melts off through modo-ui's goo, the content swap. `state` / `defaultState` / `onStateChange`; geometry from `notchWidth`, `notchHeight`, `panelWidth`, `panelHeight`. |
|
|
53
|
+
| `IslandTabs` | Icon tabs in both wings around the notch, modo-ui's liquid indicator crossing the gap; overflow scrolls behind the notch. `value` / `defaultValue` / `onValueChange`, `onHoverChange` for a title preview. |
|
|
54
|
+
| `IslandFlash` | The transient alert's layout: icon, title, caption, value, trailing glyph, action. |
|
|
55
|
+
| `Equalizer` | Now-playing level bars on a compositor-only Web Animations loop. |
|
|
56
|
+
| `BatteryGlyph` | A battery that fills to its level, with a charging bolt and status tones. |
|
|
57
|
+
| `MediaScrubber` | Elapsed / scrubber / remaining on modo-ui's Slider; seeks once on commit. |
|
|
58
|
+
| `Countdown` | Time left as `4:05` or `4m`, re-rendering only on the shown unit's edge. |
|
|
59
|
+
| `NowPlaying` | The player for the open island, with `.Leading` / `.Trailing` (compact wings), `.Minimal` (split bubble), `.Flash` (track change) and `.Artwork`. |
|
|
60
|
+
| `PowerAlert` | Charging, on battery, low and critical flashes. |
|
|
61
|
+
| `Shelf` | Files dropped on the notch: tiles with a context menu, AirDrop and Clear; `.Drop` (the drop target flash), `.Leading`, `.Trailing`. |
|
|
62
|
+
| `Timer` | Picker, running ring and countdown, Pomodoro cycles; `.Leading`, `.Trailing`, `.Minimal`, `.Done` (time's up). |
|
|
63
|
+
| `Agenda` | Today and tomorrow, access states; `.Leading`, `.Trailing`, `.Minimal`, `.UpNext`, `.Starting` (the countdown to the next event). |
|
|
64
|
+
| `Controls` | Volume, brightness and keyboard backlight sliders; `.Level` is the HUD flash. |
|
|
65
|
+
| `Devices` | Bluetooth devices and their batteries; `.Connected` flash. |
|
|
66
|
+
| `SystemStats` | CPU, memory and network tiles with sparklines; `.Leading`, `.Trailing`. |
|
|
67
|
+
| `ExpandedIsland` | The open island's layout: tabs in the wings, the tab's title, a fixed-height scrolling view. |
|
|
68
|
+
| `SettingsWindow` | The app's settings: General, Plugins, Permissions, About and each plugin's page. |
|
|
69
|
+
| `useIsland()` | The enclosing Island's state, notch and panel geometry and current outline. |
|
|
70
|
+
| `shapeFor`, `islandPath`, `stripLayout`, … | The pure geometry (`@justanarthur/modo-ui-notch/lib/geometry`). |
|
|
71
|
+
|
|
72
|
+
Each component and block is also a subpath: `@justanarthur/modo-ui-notch/components/island/island`, `@justanarthur/modo-ui-notch/blocks/activities/now-playing`.
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
MIT © 2026 justAnArthur
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import Agenda from './index'
|
|
2
|
+
import { WidgetIsland } from '../../../mock/island-content'
|
|
3
|
+
import { AgendaFlash, AgendaSplit, AgendaWings, UpNextIsland } from '../../../mock/activities'
|
|
4
|
+
import { AGENDA_NOW, EVENTS } from '../../../mock/data'
|
|
5
|
+
|
|
6
|
+
# Today and tomorrow
|
|
7
|
+
|
|
8
|
+
Each calendar's color as a dot, the start time, the place, and Join for a video call.
|
|
9
|
+
|
|
10
|
+
<WidgetIsland tab="calendar">
|
|
11
|
+
<Agenda events={EVENTS} now={AGENDA_NOW} />
|
|
12
|
+
</WidgetIsland>
|
|
13
|
+
|
|
14
|
+
# Nothing planned
|
|
15
|
+
|
|
16
|
+
<WidgetIsland tab="calendar">
|
|
17
|
+
<Agenda events={[]} />
|
|
18
|
+
</WidgetIsland>
|
|
19
|
+
|
|
20
|
+
# Asking for access
|
|
21
|
+
|
|
22
|
+
`access="undetermined"` asks to connect the calendar.
|
|
23
|
+
|
|
24
|
+
<WidgetIsland tab="calendar">
|
|
25
|
+
<Agenda events={[]} access="undetermined" />
|
|
26
|
+
</WidgetIsland>
|
|
27
|
+
|
|
28
|
+
# Access off
|
|
29
|
+
|
|
30
|
+
`access="denied"` points to the system's settings.
|
|
31
|
+
|
|
32
|
+
<WidgetIsland tab="calendar">
|
|
33
|
+
<Agenda events={[]} access="denied" />
|
|
34
|
+
</WidgetIsland>
|
|
35
|
+
|
|
36
|
+
# Up next
|
|
37
|
+
|
|
38
|
+
The next event a few minutes out: `Agenda.Leading` and `Agenda.Trailing` count down in the wings.
|
|
39
|
+
|
|
40
|
+
<AgendaWings />
|
|
41
|
+
|
|
42
|
+
# Minimal
|
|
43
|
+
|
|
44
|
+
`Agenda.Minimal` empties toward the start in the split island's bubble.
|
|
45
|
+
|
|
46
|
+
<AgendaSplit />
|
|
47
|
+
|
|
48
|
+
# Up next, open
|
|
49
|
+
|
|
50
|
+
`Agenda.UpNext` in the open island.
|
|
51
|
+
|
|
52
|
+
<UpNextIsland />
|
|
53
|
+
|
|
54
|
+
# Starting
|
|
55
|
+
|
|
56
|
+
`Agenda.Starting`, the flash a minute before.
|
|
57
|
+
|
|
58
|
+
<AgendaFlash />
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Local addition: a notch app's calendar, today's and tomorrow's events and
|
|
3
|
+
* the countdown to the next one. Rebuilt from Just Notch's calendar plugin
|
|
4
|
+
* (`Agenda`, `Upcoming`, `Starting`, `Ring`, `Countdown`) as presentational
|
|
5
|
+
* parts: events, access and actions come in as props.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use client'
|
|
9
|
+
|
|
10
|
+
import Button from '@justanarthur/modo-ui/components/actions/button'
|
|
11
|
+
import EmptyState from '@justanarthur/modo-ui/components/feedback/empty-state'
|
|
12
|
+
import Meter from '@justanarthur/modo-ui/components/feedback/meter'
|
|
13
|
+
import { type SizeVariant, useSize } from '@justanarthur/modo-ui/lib/size-context'
|
|
14
|
+
import { cn } from '@justanarthur/modo-ui/lib/utils'
|
|
15
|
+
import { CalendarCheck, CalendarDays, Video } from 'lucide-react'
|
|
16
|
+
import Countdown from '../../../components/indicators/countdown'
|
|
17
|
+
import IslandFlash from '../../../components/island/island-flash'
|
|
18
|
+
import { formatShort, MINUTE, SECOND, useEdgeClock } from '../../../lib/clock'
|
|
19
|
+
|
|
20
|
+
type AgendaAccess = 'granted' | 'undetermined' | 'denied'
|
|
21
|
+
|
|
22
|
+
interface AgendaEvent {
|
|
23
|
+
id: string
|
|
24
|
+
title: string
|
|
25
|
+
/** When it starts, in epoch ms. */
|
|
26
|
+
start: number
|
|
27
|
+
/** When it ends, in epoch ms. */
|
|
28
|
+
end: number
|
|
29
|
+
allDay?: boolean
|
|
30
|
+
location?: string
|
|
31
|
+
/** A video call's link: the event gets a Join button. */
|
|
32
|
+
meetingUrl?: string
|
|
33
|
+
/** Its calendar's color, any CSS color: data, so it paints the dot and the countdown inline. */
|
|
34
|
+
color: string
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface AgendaProps {
|
|
38
|
+
/** The events, in start order. */
|
|
39
|
+
events: AgendaEvent[]
|
|
40
|
+
/** Whether the calendar may be read: undetermined asks, denied points to the system's settings. Defaults to `'granted'`. */
|
|
41
|
+
access?: AgendaAccess
|
|
42
|
+
/** The moment the agenda is read at, in epoch ms. Defaults to now, re-read on each minute. */
|
|
43
|
+
now?: number
|
|
44
|
+
/** Formats the times. Defaults to the browser's locale. */
|
|
45
|
+
locale?: Intl.LocalesArgument
|
|
46
|
+
/** Called by Connect calendar while access is undetermined. */
|
|
47
|
+
onRequestAccess?: () => void
|
|
48
|
+
/** Called by Open System Settings while access is denied. */
|
|
49
|
+
onOpenSettings?: () => void
|
|
50
|
+
/** Called by an event's Join button. */
|
|
51
|
+
onJoin?: (event: AgendaEvent) => void
|
|
52
|
+
/** Classes for the root, which fills its container. */
|
|
53
|
+
className?: string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const clock = (ms: number, locale?: Intl.LocalesArgument) =>
|
|
57
|
+
new Date(ms).toLocaleTimeString(locale, { hour: 'numeric', minute: '2-digit' })
|
|
58
|
+
const span = (event: AgendaEvent, locale?: Intl.LocalesArgument) =>
|
|
59
|
+
event.allDay ? 'All day' : `${clock(event.start, locale)} – ${clock(event.end, locale)}`
|
|
60
|
+
const meta = (event: AgendaEvent, locale?: Intl.LocalesArgument) =>
|
|
61
|
+
event.location ? `${span(event, locale)} · ${event.location}` : span(event, locale)
|
|
62
|
+
|
|
63
|
+
function relative(ms: number) {
|
|
64
|
+
if (ms <= 0) return 'Now'
|
|
65
|
+
if (ms < MINUTE) return 'In less than a minute'
|
|
66
|
+
return `In ${Math.ceil(ms / MINUTE)} min`
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The time until `start`, re-read on each `unit` edge before it, never in between. */
|
|
70
|
+
function useUntil(start: number, unit = MINUTE) {
|
|
71
|
+
const now = useEdgeClock(start, Date.now() < start + SECOND, unit)
|
|
72
|
+
return start - now
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function Join({
|
|
76
|
+
event,
|
|
77
|
+
size,
|
|
78
|
+
onJoin,
|
|
79
|
+
}: {
|
|
80
|
+
event: AgendaEvent
|
|
81
|
+
size?: SizeVariant
|
|
82
|
+
onJoin?: (event: AgendaEvent) => void
|
|
83
|
+
}) {
|
|
84
|
+
return (
|
|
85
|
+
<Button variant="secondary" size={size} leadingIcon={Video} onClick={() => onJoin?.(event)}>
|
|
86
|
+
Join
|
|
87
|
+
</Button>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface PartProps {
|
|
92
|
+
/** The event the activity counts down to. */
|
|
93
|
+
event: AgendaEvent
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** The compact island's left wing: the calendar glyph in the event's color. */
|
|
97
|
+
function AgendaLeading({ event }: PartProps) {
|
|
98
|
+
return <CalendarDays size={16} strokeWidth={1.5} style={{ color: event.color }} />
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** The compact island's right wing: the time until it starts, `4m` then `45s`. */
|
|
102
|
+
function AgendaTrailing({ event }: PartProps) {
|
|
103
|
+
return (
|
|
104
|
+
<span className="text-caption weight-semibold" style={{ color: event.color }}>
|
|
105
|
+
<Countdown endsAt={event.start} format="short" />
|
|
106
|
+
</span>
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
interface MinimalProps extends PartProps {
|
|
111
|
+
/** How long before the start the countdown opens, in ms: the full ring. Defaults to 10 minutes. */
|
|
112
|
+
lead?: number
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** The split island's bubble: a ring that empties as the start nears. */
|
|
116
|
+
function AgendaMinimal({ event, lead = 10 * MINUTE }: MinimalProps) {
|
|
117
|
+
const left = Math.max(0, useUntil(event.start, SECOND))
|
|
118
|
+
return (
|
|
119
|
+
<Meter
|
|
120
|
+
variant="ring"
|
|
121
|
+
label={`${event.title}, in ${formatShort(left / SECOND)}`}
|
|
122
|
+
value={Math.min(1, left / lead)}
|
|
123
|
+
tone="default"
|
|
124
|
+
animate={false}
|
|
125
|
+
className="size-5.5"
|
|
126
|
+
/>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
interface ActivityProps extends PartProps {
|
|
131
|
+
/** Formats the times. Defaults to the browser's locale. */
|
|
132
|
+
locale?: Intl.LocalesArgument
|
|
133
|
+
/** Called by the Join button, shown when the event has a `meetingUrl`. */
|
|
134
|
+
onJoin?: (event: AgendaEvent) => void
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** The open island's "Up next" view: how soon, the title, the time and place, and Join. */
|
|
138
|
+
function AgendaUpNext({ event, locale, onJoin }: ActivityProps) {
|
|
139
|
+
const left = useUntil(event.start)
|
|
140
|
+
return (
|
|
141
|
+
<div className="flex size-full items-center gap-4">
|
|
142
|
+
<span className="h-14 w-1 shrink-0 rounded-full" style={{ backgroundColor: event.color }} />
|
|
143
|
+
<div className="flex min-w-0 flex-1 flex-col gap-1">
|
|
144
|
+
<span className="text-caption weight-semibold tabular-nums" style={{ color: event.color }}>
|
|
145
|
+
{relative(left)}
|
|
146
|
+
</span>
|
|
147
|
+
<span className="truncate text-title weight-semibold text-foreground">{event.title}</span>
|
|
148
|
+
<span className="truncate text-body text-muted-foreground">{meta(event, locale)}</span>
|
|
149
|
+
</div>
|
|
150
|
+
{event.meetingUrl && <Join event={event} size="default" onJoin={onJoin} />}
|
|
151
|
+
</div>
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** The island's flash a minute before the start: the title, how soon, and Join. */
|
|
156
|
+
function AgendaStarting({ event, onJoin }: Omit<ActivityProps, 'locale'>) {
|
|
157
|
+
const left = useUntil(event.start, SECOND)
|
|
158
|
+
return (
|
|
159
|
+
<IslandFlash
|
|
160
|
+
icon={<span className="size-2.5 rounded-full" style={{ backgroundColor: event.color }} />}
|
|
161
|
+
title={event.title}
|
|
162
|
+
caption={relative(left)}
|
|
163
|
+
action={event.meetingUrl && <Join event={event} size="compact" onJoin={onJoin} />}
|
|
164
|
+
/>
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function Row({
|
|
169
|
+
event,
|
|
170
|
+
locale,
|
|
171
|
+
onJoin,
|
|
172
|
+
}: {
|
|
173
|
+
event: AgendaEvent
|
|
174
|
+
locale?: Intl.LocalesArgument
|
|
175
|
+
onJoin?: (event: AgendaEvent) => void
|
|
176
|
+
}) {
|
|
177
|
+
const size = useSize()
|
|
178
|
+
return (
|
|
179
|
+
<li className={cn('flex items-center gap-3', size.control)}>
|
|
180
|
+
<span className="size-2 shrink-0 rounded-full" style={{ backgroundColor: event.color }} />
|
|
181
|
+
<span className="w-16 shrink-0 whitespace-nowrap text-caption tabular-nums text-muted-foreground">
|
|
182
|
+
{event.allDay ? 'All day' : clock(event.start, locale)}
|
|
183
|
+
</span>
|
|
184
|
+
<span className="flex min-w-0 flex-1 items-baseline gap-2">
|
|
185
|
+
<span className="min-w-0 truncate text-body text-foreground">{event.title}</span>
|
|
186
|
+
{event.location && !event.meetingUrl && (
|
|
187
|
+
<span className="min-w-0 shrink-[100] truncate text-caption text-muted-foreground">{event.location}</span>
|
|
188
|
+
)}
|
|
189
|
+
</span>
|
|
190
|
+
{event.meetingUrl && <Join event={event} size="compact" onJoin={onJoin} />}
|
|
191
|
+
</li>
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
interface DayProps {
|
|
196
|
+
title: string
|
|
197
|
+
events: AgendaEvent[]
|
|
198
|
+
empty: string
|
|
199
|
+
locale?: Intl.LocalesArgument
|
|
200
|
+
onJoin?: (event: AgendaEvent) => void
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function Day({ title, events, empty, locale, onJoin }: DayProps) {
|
|
204
|
+
return (
|
|
205
|
+
<section aria-label={title} className="flex min-w-0 flex-1 flex-col">
|
|
206
|
+
<h3 className="m-0 flex h-5 items-center text-caption weight-normal text-muted-foreground">{title}</h3>
|
|
207
|
+
{events.length === 0 ? (
|
|
208
|
+
<p className="m-0 flex h-9 items-center text-body text-muted-foreground">{empty}</p>
|
|
209
|
+
) : (
|
|
210
|
+
<ul className="m-0 flex list-none flex-col p-0">
|
|
211
|
+
{events.map(event => (
|
|
212
|
+
<Row key={event.id} event={event} locale={locale} onJoin={onJoin} />
|
|
213
|
+
))}
|
|
214
|
+
</ul>
|
|
215
|
+
)}
|
|
216
|
+
</section>
|
|
217
|
+
)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* A notch app's calendar: what's left of today and what's on tomorrow, side
|
|
222
|
+
* by side.
|
|
223
|
+
*
|
|
224
|
+
* Each event is a row with its calendar's color as a dot, its start time (or
|
|
225
|
+
* All day), its title and place, and a Join button when it has a video call.
|
|
226
|
+
* Events that have ended drop off; the day boundary is read from `now`, which
|
|
227
|
+
* follows the clock on each minute unless you pin it. Before the calendar may
|
|
228
|
+
* be read it asks to connect (`access="undetermined"`), and when access is
|
|
229
|
+
* off it points to the system's settings (`"denied"`).
|
|
230
|
+
*
|
|
231
|
+
* The countdown to the next event is an activity of parts:
|
|
232
|
+
* `Agenda.Leading` and `Agenda.Trailing` for the compact island's wings (the
|
|
233
|
+
* glyph in the event's color, and `4m` that turns to seconds in the last
|
|
234
|
+
* minute), `Agenda.Minimal`, a ring that empties toward the start, for the
|
|
235
|
+
* split island's bubble, `Agenda.UpNext` for the open island and
|
|
236
|
+
* `Agenda.Starting`, the flash a minute before. Each re-renders only on the
|
|
237
|
+
* edge of the unit it shows.
|
|
238
|
+
*
|
|
239
|
+
* @example {@include ./examples.mdx}
|
|
240
|
+
*/
|
|
241
|
+
function Agenda({
|
|
242
|
+
events,
|
|
243
|
+
access = 'granted',
|
|
244
|
+
now: nowProp,
|
|
245
|
+
locale,
|
|
246
|
+
onRequestAccess,
|
|
247
|
+
onOpenSettings,
|
|
248
|
+
onJoin,
|
|
249
|
+
className,
|
|
250
|
+
}: AgendaProps) {
|
|
251
|
+
const ticking = useEdgeClock(0, nowProp === undefined, MINUTE)
|
|
252
|
+
const now = nowProp ?? ticking
|
|
253
|
+
|
|
254
|
+
if (access === 'undetermined')
|
|
255
|
+
return (
|
|
256
|
+
<div className={cn('flex size-full items-center justify-center', className)}>
|
|
257
|
+
<EmptyState
|
|
258
|
+
size="compact"
|
|
259
|
+
icon={CalendarDays}
|
|
260
|
+
title="See what's next"
|
|
261
|
+
description="Today's and tomorrow's events, with a countdown before each one starts."
|
|
262
|
+
actions={
|
|
263
|
+
<Button variant="primary" size="compact" onClick={onRequestAccess}>
|
|
264
|
+
Connect calendar
|
|
265
|
+
</Button>
|
|
266
|
+
}
|
|
267
|
+
/>
|
|
268
|
+
</div>
|
|
269
|
+
)
|
|
270
|
+
|
|
271
|
+
if (access === 'denied')
|
|
272
|
+
return (
|
|
273
|
+
<div className={cn('flex size-full items-center justify-center', className)}>
|
|
274
|
+
<EmptyState
|
|
275
|
+
size="compact"
|
|
276
|
+
icon={CalendarDays}
|
|
277
|
+
title="Calendar access is off"
|
|
278
|
+
description="Turn it on in Privacy & Security › Calendars."
|
|
279
|
+
actions={
|
|
280
|
+
<Button variant="secondary" size="compact" onClick={onOpenSettings}>
|
|
281
|
+
Open System Settings
|
|
282
|
+
</Button>
|
|
283
|
+
}
|
|
284
|
+
/>
|
|
285
|
+
</div>
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
const midnight = new Date(now).setHours(24, 0, 0, 0)
|
|
289
|
+
const next = new Date(midnight).setHours(24, 0, 0, 0)
|
|
290
|
+
const live = events.filter(event => event.end > now && event.start < next)
|
|
291
|
+
if (live.length === 0)
|
|
292
|
+
return (
|
|
293
|
+
<div className={cn('flex size-full items-center justify-center', className)}>
|
|
294
|
+
<EmptyState
|
|
295
|
+
size="compact"
|
|
296
|
+
icon={CalendarCheck}
|
|
297
|
+
title="Nothing planned"
|
|
298
|
+
description="No events for the rest of today or tomorrow."
|
|
299
|
+
/>
|
|
300
|
+
</div>
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
return (
|
|
304
|
+
<div className={cn('flex min-h-full gap-8', className)}>
|
|
305
|
+
<Day
|
|
306
|
+
title="Today"
|
|
307
|
+
events={live.filter(event => event.start < midnight)}
|
|
308
|
+
empty="Nothing else today"
|
|
309
|
+
locale={locale}
|
|
310
|
+
onJoin={onJoin}
|
|
311
|
+
/>
|
|
312
|
+
<Day
|
|
313
|
+
title="Tomorrow"
|
|
314
|
+
events={live.filter(event => event.start >= midnight)}
|
|
315
|
+
empty="Nothing planned"
|
|
316
|
+
locale={locale}
|
|
317
|
+
onJoin={onJoin}
|
|
318
|
+
/>
|
|
319
|
+
</div>
|
|
320
|
+
)
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
Agenda.Leading = AgendaLeading
|
|
324
|
+
Agenda.Trailing = AgendaTrailing
|
|
325
|
+
Agenda.Minimal = AgendaMinimal
|
|
326
|
+
Agenda.UpNext = AgendaUpNext
|
|
327
|
+
Agenda.Starting = AgendaStarting
|
|
328
|
+
|
|
329
|
+
export default Agenda
|
|
330
|
+
|
|
331
|
+
export type { AgendaAccess, AgendaEvent, AgendaProps }
|
|
332
|
+
export { Agenda, AgendaLeading, AgendaMinimal, AgendaStarting, AgendaTrailing, AgendaUpNext }
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import NowPlaying from './index'
|
|
2
|
+
import { MockArtwork } from '../../../mock/artwork'
|
|
3
|
+
import { FlashIsland, PLAYING, ScreenEdge, TimerBubble, WidgetIsland, WingsIsland } from '../../../mock/island-content'
|
|
4
|
+
import { TRACK } from '../../../mock/data'
|
|
5
|
+
|
|
6
|
+
# Player
|
|
7
|
+
|
|
8
|
+
The open island's view: artwork, title and artist, the scrubber running on by itself, the transport and the app it plays in.
|
|
9
|
+
|
|
10
|
+
<WidgetIsland tab="now-playing">
|
|
11
|
+
<NowPlaying track={PLAYING} />
|
|
12
|
+
</WidgetIsland>
|
|
13
|
+
|
|
14
|
+
# Without artwork
|
|
15
|
+
|
|
16
|
+
A small note tile leads the title row instead of an empty square.
|
|
17
|
+
|
|
18
|
+
<WidgetIsland tab="now-playing">
|
|
19
|
+
<NowPlaying track={TRACK} defaultPlaying={false} />
|
|
20
|
+
</WidgetIsland>
|
|
21
|
+
|
|
22
|
+
# Nothing playing
|
|
23
|
+
|
|
24
|
+
<WidgetIsland tab="now-playing">
|
|
25
|
+
<NowPlaying track={null} />
|
|
26
|
+
</WidgetIsland>
|
|
27
|
+
|
|
28
|
+
# Compact
|
|
29
|
+
|
|
30
|
+
`NowPlaying.Leading` and `NowPlaying.Trailing` in the wings; the bars settle low while paused.
|
|
31
|
+
|
|
32
|
+
<div className="flex w-full flex-col gap-3">
|
|
33
|
+
<WingsIsland leading={<NowPlaying.Leading track={PLAYING} />} trailing={<NowPlaying.Trailing />} />
|
|
34
|
+
<WingsIsland leading={<NowPlaying.Leading track={PLAYING} />} trailing={<NowPlaying.Trailing playing={false} />} />
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
# Minimal
|
|
38
|
+
|
|
39
|
+
`NowPlaying.Minimal`, the artwork as a disc, in the split island's bubble beside a timer.
|
|
40
|
+
|
|
41
|
+
<WingsIsland leading={<NowPlaying.Leading track={PLAYING} />} trailing={<NowPlaying.Trailing />} minimal={<NowPlaying.Minimal track={PLAYING} />} />
|
|
42
|
+
|
|
43
|
+
# Track change
|
|
44
|
+
|
|
45
|
+
`NowPlaying.Flash` announces the next track for a moment.
|
|
46
|
+
|
|
47
|
+
<FlashIsland>
|
|
48
|
+
<NowPlaying.Flash track={{ ...PLAYING, title: 'Teardrop', artist: 'Massive Attack', artwork: <MockArtwork variant="night" /> }} />
|
|
49
|
+
</FlashIsland>
|