@justanarthur/modo-ui-notch 0.2.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/README.md +11 -11
- package/blocks/activities/agenda/examples.mdx +29 -5
- package/blocks/activities/agenda/index.tsx +438 -181
- package/blocks/activities/clock/examples.mdx +89 -0
- package/blocks/activities/clock/index.tsx +917 -0
- package/blocks/activities/now-playing/examples.mdx +40 -13
- package/blocks/activities/now-playing/index.tsx +399 -120
- package/blocks/activities/weather/examples.mdx +123 -0
- package/blocks/activities/weather/index.tsx +863 -0
- package/blocks/app/expanded-island/examples.mdx +8 -7
- package/blocks/app/expanded-island/index.tsx +22 -4
- package/blocks/app/settings-window/examples.mdx +14 -2
- package/blocks/app/settings-window/index.tsx +33 -10
- package/blocks/system/clipboard/examples.mdx +91 -0
- package/blocks/system/clipboard/index.tsx +773 -0
- package/blocks/system/recent-files/examples.mdx +80 -0
- package/blocks/system/recent-files/index.tsx +627 -0
- package/blocks/system/system-stats/examples.mdx +46 -9
- package/blocks/system/system-stats/index.tsx +445 -104
- package/components/indicators/media-scrubber/examples.mdx +8 -0
- package/components/indicators/media-scrubber/index.tsx +37 -13
- package/components/island/island/examples.mdx +4 -4
- package/components/island/island/index.tsx +2 -2
- package/components/island/island-flash/examples.mdx +15 -18
- package/components/island/island-flash/index.tsx +4 -4
- package/components/island/island-tabs/examples.mdx +5 -5
- package/components/island/widget/examples.mdx +76 -0
- package/components/island/widget/index.tsx +465 -0
- package/dist/blocks/activities/agenda/index.d.ts +2 -1
- package/dist/blocks/activities/agenda/index.js +3 -3
- package/dist/blocks/activities/clock/index.d.ts +3 -0
- package/dist/blocks/activities/clock/index.js +25 -0
- package/dist/blocks/activities/now-playing/index.d.ts +4 -2
- package/dist/blocks/activities/now-playing/index.js +5 -3
- package/dist/blocks/activities/weather/index.d.ts +3 -0
- package/dist/blocks/activities/weather/index.js +21 -0
- package/dist/blocks/app/expanded-island/index.d.ts +1 -1
- package/dist/blocks/app/expanded-island/index.js +4 -3
- 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 +3 -0
- package/dist/blocks/system/clipboard/index.js +17 -0
- package/dist/blocks/system/recent-files/index.d.ts +3 -0
- package/dist/blocks/system/recent-files/index.js +19 -0
- package/dist/blocks/system/system-stats/index.d.ts +3 -2
- package/dist/blocks/system/system-stats/index.js +4 -1
- package/dist/components/indicators/media-scrubber/index.d.ts +1 -1
- package/dist/components/indicators/media-scrubber/index.js +1 -1
- package/dist/components/island/island/index.d.ts +1 -1
- package/dist/components/island/island/index.js +2 -2
- package/dist/components/island/island-flash/index.d.ts +1 -1
- package/dist/components/island/island-flash/index.js +1 -1
- package/dist/components/island/island-tabs/index.js +2 -2
- package/dist/components/island/widget/index.d.ts +2 -0
- package/dist/components/island/widget/index.js +32 -0
- package/dist/index.d.ts +15 -15
- package/dist/index.js +104 -58
- package/dist/lib/artwork.d.ts +2 -0
- package/dist/lib/artwork.js +8 -0
- package/dist/lib/geometry.js +1 -1
- package/dist/shared/{chunk-yngkkxz2.d.ts → chunk-0ym9mcqc.d.ts} +10 -6
- package/dist/shared/chunk-2b6gpn8k.js +444 -0
- package/dist/shared/chunk-3hcnf4yx.js +481 -0
- package/dist/shared/chunk-42wab62s.d.ts +197 -0
- package/dist/shared/{chunk-zvh0d3qb.js → chunk-61t2dfte.js} +1 -1
- package/dist/shared/{chunk-9nhpg9t8.d.ts → chunk-6tnq6p89.d.ts} +9 -1
- package/dist/shared/{chunk-hpsabfsd.d.ts → chunk-81fpptwp.d.ts} +1 -1
- package/dist/shared/chunk-93dtpjz7.js +789 -0
- package/dist/shared/{chunk-wwjxs75m.js → chunk-9xtcv3sy.js} +26 -12
- package/dist/shared/chunk-a6njb8db.d.ts +129 -0
- package/dist/shared/chunk-ab8mdg0n.d.ts +149 -0
- package/dist/shared/chunk-evqpf92s.d.ts +168 -0
- package/dist/shared/{chunk-6c1jbefs.d.ts → chunk-fexwzycv.d.ts} +3 -3
- package/dist/shared/chunk-gcyspvgr.js +582 -0
- package/dist/shared/chunk-gejenfap.d.ts +25 -0
- package/dist/shared/chunk-gkj0hjrn.d.ts +136 -0
- package/dist/shared/{chunk-rr5e0g15.d.ts → chunk-j755a1a5.d.ts} +7 -1
- package/dist/shared/chunk-n739am8j.d.ts +112 -0
- package/dist/shared/{chunk-78w7qwp0.js → chunk-ndf79pv5.js} +1 -1
- package/dist/shared/chunk-nwzpekvy.js +774 -0
- package/dist/shared/{chunk-rpfwv3pz.js → chunk-r471sknr.js} +1 -1
- package/dist/shared/chunk-sbrtesdg.d.ts +138 -0
- package/dist/shared/chunk-swc7dqpw.d.ts +115 -0
- package/dist/shared/chunk-t9wqhgzt.js +765 -0
- package/dist/shared/chunk-w5h6ay93.js +72 -0
- package/dist/shared/{chunk-mp1nx0ez.js → chunk-wayv5rhr.js} +15 -4
- package/dist/shared/chunk-wf0jtzhs.js +295 -0
- package/dist/shared/{chunk-sbnrhy5m.js → chunk-y0188bbn.js} +2 -2
- package/dist/shared/chunk-yq5svpk7.js +524 -0
- package/dist/shared/{chunk-s33y1pcq.js → chunk-z3tj1ydg.js} +23 -10
- package/dist/styles.css +151 -49
- package/index.ts +7 -6
- package/lib/artwork.ts +112 -0
- package/lib/geometry.ts +1 -1
- package/mock/activities.tsx +9 -32
- package/mock/artwork.tsx +13 -1
- package/mock/clipboard.tsx +113 -0
- package/mock/clock.tsx +77 -0
- package/mock/data.ts +78 -44
- package/mock/files.tsx +83 -0
- package/mock/island-content.tsx +79 -122
- package/mock/screen.tsx +76 -0
- package/mock/settings.tsx +370 -91
- package/mock/system.ts +49 -0
- package/mock/weather.tsx +135 -0
- package/package.json +7 -2
- package/blocks/activities/shelf/examples.mdx +0 -33
- package/blocks/activities/shelf/index.tsx +0 -289
- package/blocks/activities/timer/examples.mdx +0 -52
- package/blocks/activities/timer/index.tsx +0 -292
- package/blocks/system/controls/examples.mdx +0 -34
- package/blocks/system/controls/index.tsx +0 -167
- package/blocks/system/devices/examples.mdx +0 -25
- package/blocks/system/devices/index.tsx +0 -172
- package/blocks/system/power-alert/examples.mdx +0 -32
- package/blocks/system/power-alert/index.tsx +0 -89
- package/components/indicators/battery-glyph/examples.mdx +0 -22
- package/components/indicators/battery-glyph/index.tsx +0 -91
- package/dist/blocks/activities/shelf/index.d.ts +0 -2
- package/dist/blocks/activities/shelf/index.js +0 -14
- package/dist/blocks/activities/timer/index.d.ts +0 -2
- package/dist/blocks/activities/timer/index.js +0 -19
- package/dist/blocks/system/controls/index.d.ts +0 -2
- package/dist/blocks/system/controls/index.js +0 -10
- package/dist/blocks/system/devices/index.d.ts +0 -2
- package/dist/blocks/system/devices/index.js +0 -12
- package/dist/blocks/system/power-alert/index.d.ts +0 -2
- package/dist/blocks/system/power-alert/index.js +0 -9
- package/dist/components/indicators/battery-glyph/index.d.ts +0 -2
- package/dist/components/indicators/battery-glyph/index.js +0 -9
- package/dist/shared/chunk-2qpcsv5h.d.ts +0 -45
- package/dist/shared/chunk-45gytfr1.d.ts +0 -84
- package/dist/shared/chunk-50ffk4r7.d.ts +0 -69
- package/dist/shared/chunk-5w0yck07.d.ts +0 -32
- package/dist/shared/chunk-7hr53mby.js +0 -116
- package/dist/shared/chunk-b8jb1w72.js +0 -145
- package/dist/shared/chunk-cpewy6yg.js +0 -178
- package/dist/shared/chunk-e3e4s4ds.d.ts +0 -77
- package/dist/shared/chunk-enm6td0p.js +0 -280
- package/dist/shared/chunk-fvedaas2.d.ts +0 -33
- package/dist/shared/chunk-gex38j8x.d.ts +0 -82
- package/dist/shared/chunk-hwtxpzg0.js +0 -69
- package/dist/shared/chunk-phb53x1f.js +0 -252
- package/dist/shared/chunk-r8esmjfs.d.ts +0 -42
- package/dist/shared/chunk-rcp1g9ca.js +0 -70
- package/dist/shared/chunk-rx9sphz2.js +0 -266
- package/dist/shared/chunk-xdeek16r.d.ts +0 -58
- package/dist/shared/chunk-xkzjk1tq.js +0 -206
package/mock/island-content.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Mock: what the docs put in the island, on the kit's blocks and mock data:
|
|
3
|
-
* the now-playing wings, a
|
|
4
|
-
* island with a tab per widget. Pages and examples start from
|
|
5
|
-
* here ships in the barrel.
|
|
3
|
+
* the now-playing wings, a Pomodoro ring in the bubble, a download's flash
|
|
4
|
+
* and the open island with a tab per widget. Pages and examples start from
|
|
5
|
+
* these; nothing here ships in the barrel.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
'use client'
|
|
@@ -11,77 +11,88 @@ import Tabs from '@justanarthur/modo-ui/components/navigation/tabs'
|
|
|
11
11
|
import { useSize } from '@justanarthur/modo-ui/lib/size-context'
|
|
12
12
|
import { type ReactNode, useState } from 'react'
|
|
13
13
|
import Agenda from '../blocks/activities/agenda'
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
14
|
+
import Clock from '../blocks/activities/clock'
|
|
15
|
+
import NowPlaying from '../blocks/activities/now-playing'
|
|
16
|
+
import Weather from '../blocks/activities/weather'
|
|
17
17
|
import ExpandedIsland, { type ExpandedIslandTab } from '../blocks/app/expanded-island'
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import PowerAlert from '../blocks/system/power-alert'
|
|
18
|
+
import ClipboardHistory from '../blocks/system/clipboard'
|
|
19
|
+
import RecentFiles from '../blocks/system/recent-files'
|
|
21
20
|
import SystemStats from '../blocks/system/system-stats'
|
|
22
21
|
import Island from '../components/island/island'
|
|
22
|
+
import type { WidgetLayout } from '../components/island/widget'
|
|
23
23
|
import { ISLAND_STATES, type IslandState } from '../lib/geometry'
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
export
|
|
35
|
-
file.id === 'cover'
|
|
36
|
-
? { ...file, thumbnail: <MockArtwork variant="dusk" /> }
|
|
37
|
-
: file.id === 'demo'
|
|
38
|
-
? { ...file, thumbnail: <MockArtwork variant="night" /> }
|
|
39
|
-
: file,
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
/** A focus run with `left` of its length to go, from now. */
|
|
43
|
-
export function focusRun(left = 0.62, minutes = TIMER.minutes): TimerRun {
|
|
44
|
-
return { kind: 'focus', total: minutes * MINUTE, endsAt: Date.now() + left * minutes * MINUTE }
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** A run made once, when the component mounts, so it keeps counting down across renders. */
|
|
48
|
-
export function useRun(left?: number) {
|
|
49
|
-
return useState(() => focusRun(left))[0]
|
|
50
|
-
}
|
|
24
|
+
import { PLAYING } from './artwork'
|
|
25
|
+
import { CLIP_NOW, CLIPS, PINNED } from './clipboard'
|
|
26
|
+
import { useRun, ZONES } from './clock'
|
|
27
|
+
import { AGENDA_NOW, EVENTS, TABS } from './data'
|
|
28
|
+
import { DOWNLOADS, FILES_NOW, RECENT_FILES } from './files'
|
|
29
|
+
import { ScreenEdge } from './screen'
|
|
30
|
+
import { BATTERY, DISK, PROCESSES, READINGS, UPTIME } from './system'
|
|
31
|
+
import { FORECAST } from './weather'
|
|
32
|
+
|
|
33
|
+
export { PLAYING } from './artwork'
|
|
34
|
+
export { Fit, FlashIsland, ScreenEdge, WingsIsland } from './screen'
|
|
51
35
|
|
|
52
36
|
/** The now-playing glyph for the compact island's left wing. */
|
|
53
37
|
export function ArtworkTile() {
|
|
54
38
|
return <NowPlaying.Leading track={PLAYING} />
|
|
55
39
|
}
|
|
56
40
|
|
|
57
|
-
/**
|
|
58
|
-
export function
|
|
59
|
-
return <
|
|
41
|
+
/** A focus round's ring for the split bubble, 62% to go. */
|
|
42
|
+
export function PomodoroBubble() {
|
|
43
|
+
return <Clock.Minimal run={useRun()} />
|
|
60
44
|
}
|
|
61
45
|
|
|
62
|
-
/**
|
|
63
|
-
export function
|
|
64
|
-
return <
|
|
46
|
+
/** A download landing, for the island's `flash`. */
|
|
47
|
+
export function DownloadedFlash() {
|
|
48
|
+
return <RecentFiles.Saved file={DOWNLOADS[0]!} onOpen={() => {}} />
|
|
65
49
|
}
|
|
66
50
|
|
|
51
|
+
const noop = () => {}
|
|
52
|
+
|
|
67
53
|
/** Every widget of the open island, by tab value. */
|
|
68
|
-
export function widgetFor(tab: string): ReactNode {
|
|
69
|
-
if (tab === 'now-playing')
|
|
70
|
-
|
|
71
|
-
if (tab === 'calendar') return <Agenda events={EVENTS} now={AGENDA_NOW} />
|
|
72
|
-
if (tab === '
|
|
73
|
-
if (tab === '
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
54
|
+
export function widgetFor(tab: string, layout: WidgetLayout = 'fit'): ReactNode {
|
|
55
|
+
if (tab === 'now-playing')
|
|
56
|
+
return <NowPlaying track={PLAYING} defaultShuffle={false} defaultRepeat="all" defaultLiked layout={layout} />
|
|
57
|
+
if (tab === 'calendar') return <Agenda events={EVENTS} now={AGENDA_NOW} layout={layout} />
|
|
58
|
+
if (tab === 'weather') return <Weather {...FORECAST} onRefresh={noop} layout={layout} />
|
|
59
|
+
if (tab === 'clock') return <Clock zones={ZONES} completedToday={3} layout={layout} />
|
|
60
|
+
if (tab === 'system')
|
|
61
|
+
return (
|
|
62
|
+
<SystemStats
|
|
63
|
+
samples={READINGS}
|
|
64
|
+
battery={BATTERY}
|
|
65
|
+
disk={DISK}
|
|
66
|
+
uptime={UPTIME}
|
|
67
|
+
processes={PROCESSES}
|
|
68
|
+
layout={layout}
|
|
69
|
+
/>
|
|
70
|
+
)
|
|
71
|
+
if (tab === 'clipboard')
|
|
72
|
+
return <ClipboardHistory clips={CLIPS} defaultPinned={PINNED} now={CLIP_NOW} onDelete={noop} layout={layout} />
|
|
73
|
+
if (tab === 'files')
|
|
74
|
+
return (
|
|
75
|
+
<RecentFiles
|
|
76
|
+
files={RECENT_FILES}
|
|
77
|
+
now={FILES_NOW}
|
|
78
|
+
onReveal={noop}
|
|
79
|
+
onCopy={noop}
|
|
80
|
+
onDelete={noop}
|
|
81
|
+
onClear={noop}
|
|
82
|
+
layout={layout}
|
|
83
|
+
/>
|
|
84
|
+
)
|
|
77
85
|
return null
|
|
78
86
|
}
|
|
79
87
|
|
|
80
88
|
const WIDGET_TABS: ExpandedIslandTab[] = TABS.map(tab => ({ ...tab, content: widgetFor(tab.value) }))
|
|
89
|
+
const TALL_TABS: ExpandedIslandTab[] = TABS.map(tab => ({ ...tab, content: widgetFor(tab.value, 'tall') }))
|
|
81
90
|
|
|
82
|
-
/** The open island's tabs, a view per widget
|
|
83
|
-
export function panelTabs(views: Record<string, ReactNode> = {}): ExpandedIslandTab[] {
|
|
84
|
-
return
|
|
91
|
+
/** The open island's tabs, a view per widget at `layout`, with `views` in place of the mock ones. */
|
|
92
|
+
export function panelTabs(views: Record<string, ReactNode> = {}, layout: WidgetLayout = 'fit'): ExpandedIslandTab[] {
|
|
93
|
+
return (layout === 'tall' ? TALL_TABS : WIDGET_TABS).map(tab =>
|
|
94
|
+
tab.value in views ? { ...tab, content: views[tab.value] } : tab,
|
|
95
|
+
)
|
|
85
96
|
}
|
|
86
97
|
|
|
87
98
|
/** The open island: a tab per widget in the wings, settings at the far right. */
|
|
@@ -99,9 +110,9 @@ export function DemoIsland({ defaultTab, ...props }: DemoIslandProps) {
|
|
|
99
110
|
return (
|
|
100
111
|
<Island
|
|
101
112
|
leading={<ArtworkTile />}
|
|
102
|
-
trailing={<NowPlaying.Trailing />}
|
|
103
|
-
minimal={<
|
|
104
|
-
flash={<
|
|
113
|
+
trailing={<NowPlaying.Trailing track={PLAYING} />}
|
|
114
|
+
minimal={<PomodoroBubble />}
|
|
115
|
+
flash={<DownloadedFlash />}
|
|
105
116
|
expanded={<ExpandedPanel defaultTab={defaultTab} />}
|
|
106
117
|
activity="now-playing"
|
|
107
118
|
{...props}
|
|
@@ -137,81 +148,27 @@ export function IslandPlayground({ defaultState = 'compact' }: { defaultState?:
|
|
|
137
148
|
)
|
|
138
149
|
}
|
|
139
150
|
|
|
140
|
-
/**
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
* proportions it has on a Mac.
|
|
144
|
-
*/
|
|
145
|
-
export function ScreenEdge({
|
|
151
|
+
/** The open island on a strip of screen, on `tab`, its view replaced by `children` when given; `tall` pulls it down to the 560 px sheet. */
|
|
152
|
+
export function WidgetIsland({
|
|
153
|
+
tab,
|
|
146
154
|
children,
|
|
147
|
-
height
|
|
148
|
-
|
|
155
|
+
height,
|
|
156
|
+
tall = false,
|
|
149
157
|
}: {
|
|
150
|
-
|
|
158
|
+
tab: string
|
|
159
|
+
children?: ReactNode
|
|
151
160
|
height?: number
|
|
152
|
-
|
|
161
|
+
tall?: boolean
|
|
153
162
|
}) {
|
|
154
|
-
const {
|
|
163
|
+
const tabs = panelTabs(children ? { [tab]: children } : {}, tall ? 'tall' : 'fit')
|
|
155
164
|
return (
|
|
156
|
-
<
|
|
157
|
-
<div
|
|
158
|
-
className="relative mx-auto overflow-hidden rounded-box bg-sunken"
|
|
159
|
-
style={{ width: scale < 1 ? width : '100%', maxWidth: width, height, zoom: scale }}
|
|
160
|
-
>
|
|
161
|
-
{children}
|
|
162
|
-
</div>
|
|
163
|
-
</div>
|
|
164
|
-
)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/** The open island on a strip of screen, on `tab`, its view replaced by `children` when given. */
|
|
168
|
-
export function WidgetIsland({ tab, children, height = 340 }: { tab: string; children?: ReactNode; height?: number }) {
|
|
169
|
-
const tabs = panelTabs(children ? { [tab]: children } : {})
|
|
170
|
-
return (
|
|
171
|
-
<ScreenEdge height={height}>
|
|
165
|
+
<ScreenEdge height={height ?? (tall ? 580 : 260)}>
|
|
172
166
|
<Island
|
|
173
167
|
defaultState="expanded"
|
|
174
168
|
collapsedState="idle"
|
|
169
|
+
panelHeight={tall ? 560 : undefined}
|
|
175
170
|
expanded={<ExpandedIsland tabs={tabs} defaultValue={tab} onSettings={() => {}} />}
|
|
176
171
|
/>
|
|
177
172
|
</ScreenEdge>
|
|
178
173
|
)
|
|
179
174
|
}
|
|
180
|
-
|
|
181
|
-
/** A flash below the notch, on a strip of screen. */
|
|
182
|
-
export function FlashIsland({ children, activity }: { children: ReactNode; activity?: string }) {
|
|
183
|
-
return (
|
|
184
|
-
<ScreenEdge height={112}>
|
|
185
|
-
<Island defaultState="flash" collapsedState="idle" flash={children} activity={activity} />
|
|
186
|
-
</ScreenEdge>
|
|
187
|
-
)
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/** An activity in the compact island's wings, with a second one's bubble when `minimal` is given. */
|
|
191
|
-
export function WingsIsland({
|
|
192
|
-
leading,
|
|
193
|
-
trailing,
|
|
194
|
-
minimal,
|
|
195
|
-
}: {
|
|
196
|
-
leading: ReactNode
|
|
197
|
-
trailing: ReactNode
|
|
198
|
-
minimal?: ReactNode
|
|
199
|
-
}) {
|
|
200
|
-
return (
|
|
201
|
-
<ScreenEdge height={64}>
|
|
202
|
-
<Island defaultState={minimal ? 'split' : 'compact'} leading={leading} trailing={trailing} minimal={minimal} />
|
|
203
|
-
</ScreenEdge>
|
|
204
|
-
)
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/** Lays `children` out at `width` and scales them down whole when the column is narrower. */
|
|
208
|
-
export function Fit({ width, children }: { width: number; children: ReactNode }) {
|
|
209
|
-
const { outer, scale } = useFitScale(width)
|
|
210
|
-
return (
|
|
211
|
-
<div ref={outer} className="flex w-full justify-center">
|
|
212
|
-
<div className="shrink-0" style={{ width: scale < 1 ? width : '100%', maxWidth: width, zoom: scale }}>
|
|
213
|
-
{children}
|
|
214
|
-
</div>
|
|
215
|
-
</div>
|
|
216
|
-
)
|
|
217
|
-
}
|
package/mock/screen.tsx
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Mock: strips of screen edge the island hangs from in the docs, a flash or
|
|
3
|
+
* the wings on their own, and a stage that scales down to its column.
|
|
4
|
+
* Nothing here ships in the barrel.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use client'
|
|
8
|
+
|
|
9
|
+
import type { ReactNode } from 'react'
|
|
10
|
+
import Island from '../components/island/island'
|
|
11
|
+
import { useFitScale } from './fit'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The top of a screen: a band the island hangs from, tall enough for what it
|
|
15
|
+
* shows. Narrower than `width`, it scales down whole, so the island keeps the
|
|
16
|
+
* proportions it has on a Mac.
|
|
17
|
+
*/
|
|
18
|
+
export function ScreenEdge({
|
|
19
|
+
children,
|
|
20
|
+
height = 360,
|
|
21
|
+
width = 760,
|
|
22
|
+
}: {
|
|
23
|
+
children: ReactNode
|
|
24
|
+
height?: number
|
|
25
|
+
width?: number
|
|
26
|
+
}) {
|
|
27
|
+
const { outer, scale } = useFitScale(width)
|
|
28
|
+
return (
|
|
29
|
+
<div ref={outer} className="w-full" style={{ height: height * scale }}>
|
|
30
|
+
<div
|
|
31
|
+
className="relative mx-auto overflow-hidden rounded-box bg-sunken"
|
|
32
|
+
style={{ width: scale < 1 ? width : '100%', maxWidth: width, height, zoom: scale }}
|
|
33
|
+
>
|
|
34
|
+
{children}
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** A flash below the notch, on a strip of screen. */
|
|
41
|
+
export function FlashIsland({ children, activity }: { children: ReactNode; activity?: string }) {
|
|
42
|
+
return (
|
|
43
|
+
<ScreenEdge height={112}>
|
|
44
|
+
<Island defaultState="flash" collapsedState="idle" flash={children} activity={activity} />
|
|
45
|
+
</ScreenEdge>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** An activity in the compact island's wings, with a second one's bubble when `minimal` is given. */
|
|
50
|
+
export function WingsIsland({
|
|
51
|
+
leading,
|
|
52
|
+
trailing,
|
|
53
|
+
minimal,
|
|
54
|
+
}: {
|
|
55
|
+
leading: ReactNode
|
|
56
|
+
trailing: ReactNode
|
|
57
|
+
minimal?: ReactNode
|
|
58
|
+
}) {
|
|
59
|
+
return (
|
|
60
|
+
<ScreenEdge height={64}>
|
|
61
|
+
<Island defaultState={minimal ? 'split' : 'compact'} leading={leading} trailing={trailing} minimal={minimal} />
|
|
62
|
+
</ScreenEdge>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Lays `children` out at `width` and scales them down whole when the column is narrower. */
|
|
67
|
+
export function Fit({ width, children }: { width: number; children: ReactNode }) {
|
|
68
|
+
const { outer, scale } = useFitScale(width)
|
|
69
|
+
return (
|
|
70
|
+
<div ref={outer} className="flex w-full justify-center">
|
|
71
|
+
<div className="shrink-0" style={{ width: scale < 1 ? width : '100%', maxWidth: width, zoom: scale }}>
|
|
72
|
+
{children}
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
)
|
|
76
|
+
}
|