@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
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Local addition: a notch app's settings window. Rebuilt from Just Notch's
|
|
3
|
+
* runtime (`settings/settings.tsx`) as a presentational block: preferences,
|
|
4
|
+
* plugins, permissions and the about rows come in as props.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use client'
|
|
8
|
+
|
|
9
|
+
import Button from '@justanarthur/modo-ui/components/actions/button'
|
|
10
|
+
import List, { LIST_SWITCH } from '@justanarthur/modo-ui/components/data-display/list'
|
|
11
|
+
import StatusDot from '@justanarthur/modo-ui/components/feedback/status-dot'
|
|
12
|
+
import ChoiceList from '@justanarthur/modo-ui/components/inputs/choice-list'
|
|
13
|
+
import Switch from '@justanarthur/modo-ui/components/inputs/switch'
|
|
14
|
+
import Sidebar from '@justanarthur/modo-ui/components/navigation/sidebar'
|
|
15
|
+
import type { IconComponent } from '@justanarthur/modo-ui/lib/icon-context'
|
|
16
|
+
import { useControllableState } from '@justanarthur/modo-ui/lib/use-controllable-state'
|
|
17
|
+
import { cn } from '@justanarthur/modo-ui/lib/utils'
|
|
18
|
+
import ScrollArea from '@justanarthur/modo-ui/primitives/layout/scroll-area'
|
|
19
|
+
import { Info, Puzzle, Settings2, ShieldCheck } from 'lucide-react'
|
|
20
|
+
import type { ReactNode } from 'react'
|
|
21
|
+
|
|
22
|
+
type ScreensPreference = 'notched' | 'all'
|
|
23
|
+
|
|
24
|
+
interface AppPreferences {
|
|
25
|
+
/** Start the app when the user logs in. */
|
|
26
|
+
launchAtLogin: boolean
|
|
27
|
+
/** Where the island shows: on the notched screen only, or on every screen. */
|
|
28
|
+
screens: ScreensPreference
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface SettingsPlugin {
|
|
32
|
+
id: string
|
|
33
|
+
name: string
|
|
34
|
+
/** One line on what it adds. */
|
|
35
|
+
description?: string
|
|
36
|
+
/** Its glyph in the Plugins list. */
|
|
37
|
+
icon?: IconComponent
|
|
38
|
+
/** Its settings, on a page of its own under Plugin settings. */
|
|
39
|
+
settings?: ReactNode
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface SettingsPermission {
|
|
43
|
+
id: string
|
|
44
|
+
label: string
|
|
45
|
+
/** What the app does with it. */
|
|
46
|
+
description: string
|
|
47
|
+
/** Whether macOS granted it; unset while it's being read. */
|
|
48
|
+
granted?: boolean
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface AboutRow {
|
|
52
|
+
label: string
|
|
53
|
+
value: ReactNode
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
interface SettingsWindowProps {
|
|
57
|
+
/** The app's name, over the sidebar. Defaults to `'Notch'`. */
|
|
58
|
+
name?: string
|
|
59
|
+
/** The page shown: `general`, `plugins`, `permissions`, `about` or `plugin:<id>` (controlled). */
|
|
60
|
+
value?: string
|
|
61
|
+
/** The page shown at first (uncontrolled). Defaults to `'general'`. */
|
|
62
|
+
defaultValue?: string
|
|
63
|
+
/** Called with the page a sidebar row opens. */
|
|
64
|
+
onValueChange?: (value: string) => void
|
|
65
|
+
/** The General page's preferences (controlled). */
|
|
66
|
+
preferences?: AppPreferences
|
|
67
|
+
/** The preferences at first (uncontrolled). Defaults to launching at login on the notched screen only. */
|
|
68
|
+
defaultPreferences?: AppPreferences
|
|
69
|
+
/** Called with every preference when one changes. */
|
|
70
|
+
onPreferencesChange?: (preferences: AppPreferences) => void
|
|
71
|
+
/** The installed plugins. Defaults to `[]`. */
|
|
72
|
+
plugins?: SettingsPlugin[]
|
|
73
|
+
/** Which plugins are on, by id (controlled). */
|
|
74
|
+
enabled?: Record<string, boolean>
|
|
75
|
+
/** Which plugins are on at first (uncontrolled). Defaults to every plugin. */
|
|
76
|
+
defaultEnabled?: Record<string, boolean>
|
|
77
|
+
/** Called with every plugin's state when a switch changes one. */
|
|
78
|
+
onEnabledChange?: (enabled: Record<string, boolean>) => void
|
|
79
|
+
/** What macOS lets the app read and control. Defaults to `[]`. */
|
|
80
|
+
permissions?: SettingsPermission[]
|
|
81
|
+
/** Called by Open Settings on a permission that isn't granted. */
|
|
82
|
+
onOpenPermission?: (id: string) => void
|
|
83
|
+
/** The About page's rows: version, mode, screen. Defaults to `[]`. */
|
|
84
|
+
about?: AboutRow[]
|
|
85
|
+
/** Classes for the window's content, which fills its container. */
|
|
86
|
+
className?: string
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const SCREENS: { value: ScreensPreference; label: string; note: string }[] = [
|
|
90
|
+
{ value: 'notched', label: 'Notched screen only', note: 'The built-in display' },
|
|
91
|
+
{ value: 'all', label: 'All screens', note: 'A virtual notch on the others' },
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
function Page({ title, lead, children }: { title: string; lead?: ReactNode; children: ReactNode }) {
|
|
95
|
+
return (
|
|
96
|
+
<section className="flex flex-col gap-4">
|
|
97
|
+
<div className="flex flex-col gap-1">
|
|
98
|
+
<h2 className="m-0 text-title weight-semibold text-foreground">{title}</h2>
|
|
99
|
+
{lead && <p className="m-0 text-body text-muted-foreground">{lead}</p>}
|
|
100
|
+
</div>
|
|
101
|
+
{children}
|
|
102
|
+
</section>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
interface GeneralProps {
|
|
107
|
+
preferences: AppPreferences
|
|
108
|
+
onChange: (preferences: AppPreferences) => void
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function General({ preferences, onChange }: GeneralProps) {
|
|
112
|
+
return (
|
|
113
|
+
<Page title="General">
|
|
114
|
+
<List>
|
|
115
|
+
<List.Section title="Startup">
|
|
116
|
+
<List.Row label="Launch at login" description="Starts the app when you log in to your Mac.">
|
|
117
|
+
<Switch
|
|
118
|
+
aria-label="Launch at login"
|
|
119
|
+
className={LIST_SWITCH}
|
|
120
|
+
checked={preferences.launchAtLogin}
|
|
121
|
+
onCheckedChange={launchAtLogin => onChange({ ...preferences, launchAtLogin })}
|
|
122
|
+
/>
|
|
123
|
+
</List.Row>
|
|
124
|
+
</List.Section>
|
|
125
|
+
</List>
|
|
126
|
+
<div className="flex flex-col gap-2">
|
|
127
|
+
<span className="text-caption text-muted-foreground">Show the island on</span>
|
|
128
|
+
<ChoiceList
|
|
129
|
+
label="Show the island on"
|
|
130
|
+
value={preferences.screens}
|
|
131
|
+
onValueChange={screens => onChange({ ...preferences, screens: screens as ScreensPreference })}
|
|
132
|
+
options={SCREENS.map(screen => ({
|
|
133
|
+
value: screen.value,
|
|
134
|
+
label: screen.label,
|
|
135
|
+
content: (
|
|
136
|
+
<span className="flex min-w-0 flex-1 items-baseline justify-between gap-3">
|
|
137
|
+
<span className="truncate">{screen.label}</span>
|
|
138
|
+
<span className="truncate text-caption text-muted-foreground">{screen.note}</span>
|
|
139
|
+
</span>
|
|
140
|
+
),
|
|
141
|
+
}))}
|
|
142
|
+
/>
|
|
143
|
+
</div>
|
|
144
|
+
</Page>
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
interface PluginsProps {
|
|
149
|
+
plugins: SettingsPlugin[]
|
|
150
|
+
enabled: Record<string, boolean>
|
|
151
|
+
onChange: (enabled: Record<string, boolean>) => void
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function Plugins({ plugins, enabled, onChange }: PluginsProps) {
|
|
155
|
+
return (
|
|
156
|
+
<Page title="Plugins" lead="Each plugin adds activities and widgets to the island.">
|
|
157
|
+
{plugins.length === 0 ? (
|
|
158
|
+
<p className="m-0 text-body text-muted-foreground">No plugins installed.</p>
|
|
159
|
+
) : (
|
|
160
|
+
<List>
|
|
161
|
+
<List.Section title="Installed" aside={`${plugins.filter(p => enabled[p.id] ?? true).length} on`}>
|
|
162
|
+
{plugins.map(plugin => {
|
|
163
|
+
const Icon = plugin.icon ?? Puzzle
|
|
164
|
+
return (
|
|
165
|
+
<List.Row
|
|
166
|
+
key={plugin.id}
|
|
167
|
+
label={
|
|
168
|
+
<span className="flex min-w-0 items-center gap-2">
|
|
169
|
+
<Icon size={16} strokeWidth={1.5} className="shrink-0 text-muted-foreground" />
|
|
170
|
+
<span className="truncate">{plugin.name}</span>
|
|
171
|
+
</span>
|
|
172
|
+
}
|
|
173
|
+
description={plugin.description}
|
|
174
|
+
>
|
|
175
|
+
<Switch
|
|
176
|
+
aria-label={plugin.name}
|
|
177
|
+
className={LIST_SWITCH}
|
|
178
|
+
checked={enabled[plugin.id] ?? true}
|
|
179
|
+
onCheckedChange={on => onChange({ ...enabled, [plugin.id]: on })}
|
|
180
|
+
/>
|
|
181
|
+
</List.Row>
|
|
182
|
+
)
|
|
183
|
+
})}
|
|
184
|
+
</List.Section>
|
|
185
|
+
</List>
|
|
186
|
+
)}
|
|
187
|
+
</Page>
|
|
188
|
+
)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
interface PermissionsProps {
|
|
192
|
+
permissions: SettingsPermission[]
|
|
193
|
+
onOpen?: (id: string) => void
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function Permissions({ permissions, onOpen }: PermissionsProps) {
|
|
197
|
+
return (
|
|
198
|
+
<Page title="Permissions" lead="What macOS lets the app read and control.">
|
|
199
|
+
<List>
|
|
200
|
+
<List.Section title="Privacy & Security">
|
|
201
|
+
{permissions.map(permission => (
|
|
202
|
+
<List.Row
|
|
203
|
+
key={permission.id}
|
|
204
|
+
label={
|
|
205
|
+
<span className="flex min-w-0 items-center gap-2">
|
|
206
|
+
<StatusDot
|
|
207
|
+
status={permission.granted === undefined ? 'running' : permission.granted ? 'success' : 'waiting'}
|
|
208
|
+
label={
|
|
209
|
+
permission.granted === undefined ? 'Checking' : permission.granted ? 'Granted' : 'Not granted'
|
|
210
|
+
}
|
|
211
|
+
/>
|
|
212
|
+
<span className="truncate">{permission.label}</span>
|
|
213
|
+
</span>
|
|
214
|
+
}
|
|
215
|
+
description={permission.description}
|
|
216
|
+
>
|
|
217
|
+
{permission.granted === false ? (
|
|
218
|
+
<Button variant="ghost" size="compact" onClick={() => onOpen?.(permission.id)}>
|
|
219
|
+
Open Settings
|
|
220
|
+
</Button>
|
|
221
|
+
) : (
|
|
222
|
+
<span className="pr-3 text-caption text-muted-foreground">
|
|
223
|
+
{permission.granted ? 'Granted' : 'Checking…'}
|
|
224
|
+
</span>
|
|
225
|
+
)}
|
|
226
|
+
</List.Row>
|
|
227
|
+
))}
|
|
228
|
+
</List.Section>
|
|
229
|
+
</List>
|
|
230
|
+
</Page>
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function About({ rows }: { rows: AboutRow[] }) {
|
|
235
|
+
return (
|
|
236
|
+
<Page title="About">
|
|
237
|
+
<List>
|
|
238
|
+
{rows.map(row => (
|
|
239
|
+
<List.Row key={row.label} label={<span className="text-muted-foreground">{row.label}</span>}>
|
|
240
|
+
<span className="min-w-0 truncate pr-3 text-body text-foreground">{row.value}</span>
|
|
241
|
+
</List.Row>
|
|
242
|
+
))}
|
|
243
|
+
</List>
|
|
244
|
+
</Page>
|
|
245
|
+
)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const PAGES: { value: string; label: string; icon: IconComponent }[] = [
|
|
249
|
+
{ value: 'general', label: 'General', icon: Settings2 },
|
|
250
|
+
{ value: 'plugins', label: 'Plugins', icon: Puzzle },
|
|
251
|
+
{ value: 'permissions', label: 'Permissions', icon: ShieldCheck },
|
|
252
|
+
{ value: 'about', label: 'About', icon: Info },
|
|
253
|
+
]
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* A notch app's settings window: General, Plugins, Permissions and About,
|
|
257
|
+
* and a page for each plugin's own settings.
|
|
258
|
+
*
|
|
259
|
+
* A modo-ui Sidebar pinned open (the window is small, about 760 × 520, so
|
|
260
|
+
* it never folds into a drawer) lists the pages under the app's `name`, then
|
|
261
|
+
* the plugins that bring settings. General holds the launch at login Switch
|
|
262
|
+
* and a ChoiceList of the screens the island shows on. Plugins lists each
|
|
263
|
+
* installed plugin with its glyph, its line and a Switch that turns it on or
|
|
264
|
+
* off. Permissions shows what macOS granted as a StatusDot per row, with
|
|
265
|
+
* Open Settings beside one that isn't granted, and a spinner while it's
|
|
266
|
+
* being read. About lists the `about` rows. A plugin's page shows its
|
|
267
|
+
* `settings` node under its name.
|
|
268
|
+
*
|
|
269
|
+
* The page, the preferences and the plugins' states each run both ways
|
|
270
|
+
* (`value`, `preferences`, `enabled` with their `default*` and `on*Change`),
|
|
271
|
+
* so the window works on its own or on a host's store. It fills its
|
|
272
|
+
* container; the window's frame and title bar are the host's.
|
|
273
|
+
*
|
|
274
|
+
* @example {@include ./examples.mdx}
|
|
275
|
+
*/
|
|
276
|
+
export default function SettingsWindow({
|
|
277
|
+
name = 'Notch',
|
|
278
|
+
value,
|
|
279
|
+
defaultValue = 'general',
|
|
280
|
+
onValueChange,
|
|
281
|
+
preferences: preferencesProp,
|
|
282
|
+
defaultPreferences = { launchAtLogin: true, screens: 'notched' },
|
|
283
|
+
onPreferencesChange,
|
|
284
|
+
plugins = [],
|
|
285
|
+
enabled: enabledProp,
|
|
286
|
+
defaultEnabled = {},
|
|
287
|
+
onEnabledChange,
|
|
288
|
+
permissions = [],
|
|
289
|
+
onOpenPermission,
|
|
290
|
+
about = [],
|
|
291
|
+
className,
|
|
292
|
+
}: SettingsWindowProps) {
|
|
293
|
+
const [page, setPage] = useControllableState(value, defaultValue, onValueChange)
|
|
294
|
+
const [preferences, setPreferences] = useControllableState(preferencesProp, defaultPreferences, onPreferencesChange)
|
|
295
|
+
const [enabled, setEnabled] = useControllableState(enabledProp, defaultEnabled, onEnabledChange)
|
|
296
|
+
const withSettings = plugins.filter(plugin => plugin.settings !== undefined)
|
|
297
|
+
const plugin = withSettings.find(p => `plugin:${p.id}` === page)
|
|
298
|
+
|
|
299
|
+
return (
|
|
300
|
+
<Sidebar.Provider
|
|
301
|
+
className={cn('h-full min-h-0', className)}
|
|
302
|
+
persist={false}
|
|
303
|
+
shortcut={null}
|
|
304
|
+
mobileBreakpoint={0}
|
|
305
|
+
width="13rem"
|
|
306
|
+
>
|
|
307
|
+
<Sidebar className="h-full" collapsible="none" value={page} onValueChange={setPage}>
|
|
308
|
+
<Sidebar.Content>
|
|
309
|
+
<Sidebar.Group>
|
|
310
|
+
<Sidebar.GroupLabel>{name}</Sidebar.GroupLabel>
|
|
311
|
+
<Sidebar.Menu>
|
|
312
|
+
{PAGES.map(item => (
|
|
313
|
+
<Sidebar.MenuItem key={item.value}>
|
|
314
|
+
<Sidebar.MenuButton icon={item.icon} value={item.value}>
|
|
315
|
+
{item.label}
|
|
316
|
+
</Sidebar.MenuButton>
|
|
317
|
+
</Sidebar.MenuItem>
|
|
318
|
+
))}
|
|
319
|
+
</Sidebar.Menu>
|
|
320
|
+
</Sidebar.Group>
|
|
321
|
+
{withSettings.length > 0 && (
|
|
322
|
+
<Sidebar.Group>
|
|
323
|
+
<Sidebar.GroupLabel>Plugin settings</Sidebar.GroupLabel>
|
|
324
|
+
<Sidebar.Menu>
|
|
325
|
+
{withSettings.map(p => (
|
|
326
|
+
<Sidebar.MenuItem key={p.id}>
|
|
327
|
+
<Sidebar.MenuButton icon={p.icon} value={`plugin:${p.id}`}>
|
|
328
|
+
{p.name}
|
|
329
|
+
</Sidebar.MenuButton>
|
|
330
|
+
</Sidebar.MenuItem>
|
|
331
|
+
))}
|
|
332
|
+
</Sidebar.Menu>
|
|
333
|
+
</Sidebar.Group>
|
|
334
|
+
)}
|
|
335
|
+
</Sidebar.Content>
|
|
336
|
+
</Sidebar>
|
|
337
|
+
<Sidebar.Inset className="min-h-0 min-w-0">
|
|
338
|
+
<ScrollArea key={page} className="h-full" viewportClassName="scroll-fade">
|
|
339
|
+
<div className="mx-auto flex w-full max-w-160 flex-col gap-8 p-8">
|
|
340
|
+
{page === 'general' && <General preferences={preferences} onChange={setPreferences} />}
|
|
341
|
+
{page === 'plugins' && <Plugins plugins={plugins} enabled={enabled} onChange={setEnabled} />}
|
|
342
|
+
{page === 'permissions' && <Permissions permissions={permissions} onOpen={onOpenPermission} />}
|
|
343
|
+
{page === 'about' && <About rows={about} />}
|
|
344
|
+
{plugin && (
|
|
345
|
+
<Page title={plugin.name} lead={plugin.description}>
|
|
346
|
+
{plugin.settings}
|
|
347
|
+
</Page>
|
|
348
|
+
)}
|
|
349
|
+
</div>
|
|
350
|
+
</ScrollArea>
|
|
351
|
+
</Sidebar.Inset>
|
|
352
|
+
</Sidebar.Provider>
|
|
353
|
+
)
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export type { AboutRow, AppPreferences, ScreensPreference, SettingsPermission, SettingsPlugin, SettingsWindowProps }
|
|
357
|
+
export { SettingsWindow }
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import Controls from './index'
|
|
2
|
+
import { FlashIsland, WidgetIsland } from '../../../mock/island-content'
|
|
3
|
+
|
|
4
|
+
# Controls
|
|
5
|
+
|
|
6
|
+
Volume, brightness and the keyboard backlight; each glyph follows its level.
|
|
7
|
+
|
|
8
|
+
<WidgetIsland tab="controls">
|
|
9
|
+
<Controls defaultValue={{ volume: 0.6, brightness: 0.8, keyboard: 0.35 }} output="MacBook Pro Speakers" />
|
|
10
|
+
</WidgetIsland>
|
|
11
|
+
|
|
12
|
+
# Volume only
|
|
13
|
+
|
|
14
|
+
An external display without a brightness reading, muted.
|
|
15
|
+
|
|
16
|
+
<WidgetIsland tab="controls">
|
|
17
|
+
<Controls defaultValue={{ volume: 0.4, muted: true }} output="Studio Display Speakers" />
|
|
18
|
+
</WidgetIsland>
|
|
19
|
+
|
|
20
|
+
# HUD
|
|
21
|
+
|
|
22
|
+
`Controls.Level` replaces the system's overlay, keyed by kind.
|
|
23
|
+
|
|
24
|
+
<div className="flex w-full flex-col gap-3">
|
|
25
|
+
<FlashIsland activity="volume">
|
|
26
|
+
<Controls.Level kind="volume" defaultValue={0.7} />
|
|
27
|
+
</FlashIsland>
|
|
28
|
+
<FlashIsland activity="brightness">
|
|
29
|
+
<Controls.Level kind="brightness" defaultValue={0.25} />
|
|
30
|
+
</FlashIsland>
|
|
31
|
+
<FlashIsland activity="keyboard">
|
|
32
|
+
<Controls.Level kind="keyboard" defaultValue={0} />
|
|
33
|
+
</FlashIsland>
|
|
34
|
+
</div>
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Local addition: a notch app's system controls and their HUD, the level the
|
|
3
|
+
* island shows in place of the system's volume and brightness overlay.
|
|
4
|
+
* Rebuilt from Just Notch's HUD plugin (`Level`, `Controls`, `Flash`) as
|
|
5
|
+
* presentational parts: the levels come in as values.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use client'
|
|
9
|
+
|
|
10
|
+
import Slider from '@justanarthur/modo-ui/components/inputs/slider'
|
|
11
|
+
import { useControllableState } from '@justanarthur/modo-ui/lib/use-controllable-state'
|
|
12
|
+
import { cn } from '@justanarthur/modo-ui/lib/utils'
|
|
13
|
+
import {
|
|
14
|
+
Keyboard,
|
|
15
|
+
KeyboardOff,
|
|
16
|
+
type LucideIcon,
|
|
17
|
+
Speaker,
|
|
18
|
+
Sun,
|
|
19
|
+
SunDim,
|
|
20
|
+
SunMedium,
|
|
21
|
+
Volume,
|
|
22
|
+
Volume1,
|
|
23
|
+
Volume2,
|
|
24
|
+
VolumeX,
|
|
25
|
+
} from 'lucide-react'
|
|
26
|
+
|
|
27
|
+
type ControlKind = 'volume' | 'brightness' | 'keyboard'
|
|
28
|
+
|
|
29
|
+
/** The levels, from 0 to 1. A missing brightness or keyboard level hides its row (no built-in display, no backlight). */
|
|
30
|
+
interface ControlLevels {
|
|
31
|
+
volume: number
|
|
32
|
+
muted?: boolean
|
|
33
|
+
brightness?: number
|
|
34
|
+
keyboard?: number
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface ControlsProps {
|
|
38
|
+
/** The levels (controlled). */
|
|
39
|
+
value?: ControlLevels
|
|
40
|
+
/** The levels at first (uncontrolled). Defaults to the volume at half. */
|
|
41
|
+
defaultValue?: ControlLevels
|
|
42
|
+
/** Called with every level when a slider moves one; moving volume unmutes it. */
|
|
43
|
+
onValueChange?: (levels: ControlLevels) => void
|
|
44
|
+
/** The audio output's name, on a muted row under the sliders. */
|
|
45
|
+
output?: string
|
|
46
|
+
/** Classes for the root, which fills its container. */
|
|
47
|
+
className?: string
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const LABEL: Record<ControlKind, string> = {
|
|
51
|
+
volume: 'Volume',
|
|
52
|
+
brightness: 'Brightness',
|
|
53
|
+
keyboard: 'Keyboard brightness',
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** The glyph for a level: the speaker's waves, the sun's rays, the backlight on or off. */
|
|
57
|
+
function glyph(kind: ControlKind, value: number, muted?: boolean): LucideIcon {
|
|
58
|
+
if (kind === 'volume') {
|
|
59
|
+
if (muted || value === 0) return VolumeX
|
|
60
|
+
return value < 0.34 ? Volume : value < 0.67 ? Volume1 : Volume2
|
|
61
|
+
}
|
|
62
|
+
if (kind === 'brightness') return value < 0.34 ? SunDim : value < 0.67 ? SunMedium : Sun
|
|
63
|
+
return value === 0 ? KeyboardOff : Keyboard
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface ControlsLevelProps {
|
|
67
|
+
/** What it sets. */
|
|
68
|
+
kind: ControlKind
|
|
69
|
+
/** The level, from 0 to 1 (controlled). */
|
|
70
|
+
value?: number
|
|
71
|
+
/** The level at first (uncontrolled). Defaults to `0`. */
|
|
72
|
+
defaultValue?: number
|
|
73
|
+
/** Called with the level, from 0 to 1, as the slider moves. */
|
|
74
|
+
onValueChange?: (value: number) => void
|
|
75
|
+
/** Volume only: it is muted, so it reads 0 and shows the crossed speaker until moved. */
|
|
76
|
+
muted?: boolean
|
|
77
|
+
/** Classes for the row. */
|
|
78
|
+
className?: string
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** One level as a row: a glyph that follows it, a compact slider and the percent. Pass it as the HUD's flash, keyed by kind. */
|
|
82
|
+
function ControlsLevel({
|
|
83
|
+
kind,
|
|
84
|
+
value: valueProp,
|
|
85
|
+
defaultValue = 0,
|
|
86
|
+
onValueChange,
|
|
87
|
+
muted,
|
|
88
|
+
className,
|
|
89
|
+
}: ControlsLevelProps) {
|
|
90
|
+
const [value, setValue] = useControllableState(valueProp, defaultValue, onValueChange)
|
|
91
|
+
const shown = muted ? 0 : value
|
|
92
|
+
const Icon = glyph(kind, shown, muted)
|
|
93
|
+
const percent = Math.round(shown * 100)
|
|
94
|
+
return (
|
|
95
|
+
<div className={cn('flex h-7 items-center gap-3', className)}>
|
|
96
|
+
<Icon size={16} strokeWidth={1.5} className="shrink-0 text-foreground" />
|
|
97
|
+
<Slider
|
|
98
|
+
className="mb-0 min-w-0 flex-1"
|
|
99
|
+
size="compact"
|
|
100
|
+
label={LABEL[kind]}
|
|
101
|
+
showValue={false}
|
|
102
|
+
value={percent}
|
|
103
|
+
onValueChange={v => setValue((v as number) / 100)}
|
|
104
|
+
/>
|
|
105
|
+
<span className="w-7 shrink-0 text-right text-caption tabular-nums text-muted-foreground">{percent}</span>
|
|
106
|
+
</div>
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* A notch app's system controls: volume, display brightness and keyboard
|
|
112
|
+
* backlight as sliders, and the audio output.
|
|
113
|
+
*
|
|
114
|
+
* Each row is a glyph that follows its level (the speaker's waves, a muted
|
|
115
|
+
* cross, the sun's rays, the backlight off), modo-ui's compact Slider and the
|
|
116
|
+
* level in percent. A display without a brightness reading, or a keyboard
|
|
117
|
+
* without a backlight, leaves its level out and so its row. The levels are
|
|
118
|
+
* one value from 0 to 1 each (`value` / `onValueChange`, or kept here from
|
|
119
|
+
* `defaultValue`); moving the volume unmutes it.
|
|
120
|
+
*
|
|
121
|
+
* `Controls.Level` is one row on its own: the HUD flash that replaces the
|
|
122
|
+
* system's overlay when a volume or brightness key is pressed. Key it by
|
|
123
|
+
* kind, so pressing a brightness key while the volume shows swaps the flash
|
|
124
|
+
* instead of repainting it.
|
|
125
|
+
*
|
|
126
|
+
* @example {@include ./examples.mdx}
|
|
127
|
+
*/
|
|
128
|
+
function Controls({ value, defaultValue = { volume: 0.5 }, onValueChange, output, className }: ControlsProps) {
|
|
129
|
+
const [levels, setLevels] = useControllableState(value, defaultValue, onValueChange)
|
|
130
|
+
return (
|
|
131
|
+
<div className={cn('flex size-full flex-col justify-center gap-1', className)}>
|
|
132
|
+
<ControlsLevel
|
|
133
|
+
kind="volume"
|
|
134
|
+
value={levels.volume}
|
|
135
|
+
muted={levels.muted}
|
|
136
|
+
onValueChange={volume => setLevels({ ...levels, volume, muted: false })}
|
|
137
|
+
/>
|
|
138
|
+
{levels.brightness !== undefined && (
|
|
139
|
+
<ControlsLevel
|
|
140
|
+
kind="brightness"
|
|
141
|
+
value={levels.brightness}
|
|
142
|
+
onValueChange={brightness => setLevels({ ...levels, brightness })}
|
|
143
|
+
/>
|
|
144
|
+
)}
|
|
145
|
+
{levels.keyboard !== undefined && (
|
|
146
|
+
<ControlsLevel
|
|
147
|
+
kind="keyboard"
|
|
148
|
+
value={levels.keyboard}
|
|
149
|
+
onValueChange={keyboard => setLevels({ ...levels, keyboard })}
|
|
150
|
+
/>
|
|
151
|
+
)}
|
|
152
|
+
{output && (
|
|
153
|
+
<div className="flex h-7 items-center gap-3">
|
|
154
|
+
<Speaker size={16} strokeWidth={1.5} className="shrink-0 text-muted-foreground" />
|
|
155
|
+
<span className="min-w-0 truncate text-caption text-muted-foreground">{output}</span>
|
|
156
|
+
</div>
|
|
157
|
+
)}
|
|
158
|
+
</div>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
Controls.Level = ControlsLevel
|
|
163
|
+
|
|
164
|
+
export default Controls
|
|
165
|
+
|
|
166
|
+
export type { ControlKind, ControlLevels, ControlsLevelProps, ControlsProps }
|
|
167
|
+
export { Controls, ControlsLevel }
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Devices from './index'
|
|
2
|
+
import { FlashIsland, WidgetIsland } from '../../../mock/island-content'
|
|
3
|
+
import { DEVICES } from '../../../mock/data'
|
|
4
|
+
|
|
5
|
+
# Devices
|
|
6
|
+
|
|
7
|
+
Connected first, each with its charge; a low one turns to the warning and error hues.
|
|
8
|
+
|
|
9
|
+
<WidgetIsland tab="devices">
|
|
10
|
+
<Devices devices={DEVICES} />
|
|
11
|
+
</WidgetIsland>
|
|
12
|
+
|
|
13
|
+
# None paired
|
|
14
|
+
|
|
15
|
+
<WidgetIsland tab="devices">
|
|
16
|
+
<Devices devices={[]} onOpenSettings={() => {}} />
|
|
17
|
+
</WidgetIsland>
|
|
18
|
+
|
|
19
|
+
# Connected
|
|
20
|
+
|
|
21
|
+
`Devices.Connected`, the flash when a device connects.
|
|
22
|
+
|
|
23
|
+
<FlashIsland>
|
|
24
|
+
<Devices.Connected device={DEVICES[0]} />
|
|
25
|
+
</FlashIsland>
|