@justanarthur/modo-ui-notch 0.0.0-stage → 0.3.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.
Files changed (141) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +75 -2
  3. package/blocks/activities/agenda/examples.mdx +74 -0
  4. package/blocks/activities/agenda/index.tsx +441 -0
  5. package/blocks/activities/clock/examples.mdx +73 -0
  6. package/blocks/activities/clock/index.tsx +619 -0
  7. package/blocks/activities/now-playing/examples.mdx +68 -0
  8. package/blocks/activities/now-playing/index.tsx +411 -0
  9. package/blocks/activities/weather/examples.mdx +115 -0
  10. package/blocks/activities/weather/index.tsx +634 -0
  11. package/blocks/app/expanded-island/examples.mdx +46 -0
  12. package/blocks/app/expanded-island/index.tsx +143 -0
  13. package/blocks/app/settings-window/examples.mdx +34 -0
  14. package/blocks/app/settings-window/index.tsx +375 -0
  15. package/blocks/system/clipboard/examples.mdx +83 -0
  16. package/blocks/system/clipboard/index.tsx +563 -0
  17. package/blocks/system/recent-files/examples.mdx +66 -0
  18. package/blocks/system/recent-files/index.tsx +542 -0
  19. package/blocks/system/system-stats/examples.mdx +52 -0
  20. package/blocks/system/system-stats/index.tsx +312 -0
  21. package/components/indicators/countdown/examples.mdx +25 -0
  22. package/components/indicators/countdown/index.tsx +83 -0
  23. package/components/indicators/equalizer/examples.mdx +20 -0
  24. package/components/indicators/equalizer/index.tsx +116 -0
  25. package/components/indicators/media-scrubber/examples.mdx +29 -0
  26. package/components/indicators/media-scrubber/index.tsx +122 -0
  27. package/components/island/island/examples.mdx +57 -0
  28. package/components/island/island/index.tsx +415 -0
  29. package/components/island/island-flash/examples.mdx +52 -0
  30. package/components/island/island-flash/index.tsx +79 -0
  31. package/components/island/island-tabs/examples.mdx +53 -0
  32. package/components/island/island-tabs/index.tsx +285 -0
  33. package/components/island/widget/examples.mdx +76 -0
  34. package/components/island/widget/index.tsx +431 -0
  35. package/dist/blocks/activities/agenda/index.d.ts +2 -0
  36. package/dist/blocks/activities/agenda/index.js +21 -0
  37. package/dist/blocks/activities/clock/index.d.ts +2 -0
  38. package/dist/blocks/activities/clock/index.js +25 -0
  39. package/dist/blocks/activities/now-playing/index.d.ts +3 -0
  40. package/dist/blocks/activities/now-playing/index.js +24 -0
  41. package/dist/blocks/activities/weather/index.d.ts +2 -0
  42. package/dist/blocks/activities/weather/index.js +21 -0
  43. package/dist/blocks/app/expanded-island/index.d.ts +3 -0
  44. package/dist/blocks/app/expanded-island/index.js +11 -0
  45. package/dist/blocks/app/settings-window/index.d.ts +2 -0
  46. package/dist/blocks/app/settings-window/index.js +7 -0
  47. package/dist/blocks/system/clipboard/index.d.ts +2 -0
  48. package/dist/blocks/system/clipboard/index.js +17 -0
  49. package/dist/blocks/system/recent-files/index.d.ts +2 -0
  50. package/dist/blocks/system/recent-files/index.js +19 -0
  51. package/dist/blocks/system/system-stats/index.d.ts +2 -0
  52. package/dist/blocks/system/system-stats/index.js +15 -0
  53. package/dist/components/indicators/countdown/index.d.ts +2 -0
  54. package/dist/components/indicators/countdown/index.js +8 -0
  55. package/dist/components/indicators/equalizer/index.d.ts +2 -0
  56. package/dist/components/indicators/equalizer/index.js +7 -0
  57. package/dist/components/indicators/media-scrubber/index.d.ts +2 -0
  58. package/dist/components/indicators/media-scrubber/index.js +8 -0
  59. package/dist/components/island/island/index.d.ts +3 -0
  60. package/dist/components/island/island/index.js +10 -0
  61. package/dist/components/island/island-flash/index.d.ts +2 -0
  62. package/dist/components/island/island-flash/index.js +7 -0
  63. package/dist/components/island/island-tabs/index.d.ts +2 -0
  64. package/dist/components/island/island-tabs/index.js +9 -0
  65. package/dist/components/island/widget/index.d.ts +2 -0
  66. package/dist/components/island/widget/index.js +30 -0
  67. package/dist/index.d.ts +21 -0
  68. package/dist/index.js +195 -0
  69. package/dist/lib/artwork.d.ts +2 -0
  70. package/dist/lib/artwork.js +8 -0
  71. package/dist/lib/clock.d.ts +2 -0
  72. package/dist/lib/clock.js +14 -0
  73. package/dist/lib/geometry.d.ts +2 -0
  74. package/dist/lib/geometry.js +24 -0
  75. package/dist/lib/island-context.d.ts +3 -0
  76. package/dist/lib/island-context.js +8 -0
  77. package/dist/lib/motion.d.ts +21 -0
  78. package/dist/lib/motion.js +16 -0
  79. package/dist/shared/chunk-152gpyq3.d.ts +13 -0
  80. package/dist/shared/chunk-2818esrq.d.ts +140 -0
  81. package/dist/shared/chunk-2f7zxrbk.js +65 -0
  82. package/dist/shared/chunk-2m5dz8nf.d.ts +88 -0
  83. package/dist/shared/chunk-2s4q6mt0.js +27 -0
  84. package/dist/shared/chunk-3thgcfcq.d.ts +151 -0
  85. package/dist/shared/chunk-416tsgbc.d.ts +175 -0
  86. package/dist/shared/chunk-502rmtap.js +54 -0
  87. package/dist/shared/chunk-52gb3g6r.d.ts +12 -0
  88. package/dist/shared/chunk-5en5aaj1.d.ts +33 -0
  89. package/dist/shared/chunk-61t2dfte.js +63 -0
  90. package/dist/shared/chunk-7fvnrtz4.d.ts +105 -0
  91. package/dist/shared/chunk-81fpptwp.d.ts +75 -0
  92. package/dist/shared/chunk-9c7ewvkk.js +381 -0
  93. package/dist/shared/chunk-9m0xbg5v.js +112 -0
  94. package/dist/shared/chunk-9xtcv3sy.js +88 -0
  95. package/dist/shared/chunk-bvtyjcce.d.ts +123 -0
  96. package/dist/shared/chunk-cc9nwbtf.js +315 -0
  97. package/dist/shared/chunk-cfzmfnyh.d.ts +63 -0
  98. package/dist/shared/chunk-d5qm9cps.js +10 -0
  99. package/dist/shared/chunk-da177e8r.d.ts +114 -0
  100. package/dist/shared/chunk-fexwzycv.d.ts +36 -0
  101. package/dist/shared/chunk-gb56m10p.js +39 -0
  102. package/dist/shared/chunk-gejenfap.d.ts +25 -0
  103. package/dist/shared/chunk-hrpxbqmx.d.ts +28 -0
  104. package/dist/shared/chunk-j755a1a5.d.ts +41 -0
  105. package/dist/shared/chunk-j77cx8dp.js +498 -0
  106. package/dist/shared/chunk-mt0k6v8x.js +474 -0
  107. package/dist/shared/chunk-ndf79pv5.js +58 -0
  108. package/dist/shared/chunk-pfhy5e4q.d.ts +53 -0
  109. package/dist/shared/chunk-qdzemt2v.js +477 -0
  110. package/dist/shared/chunk-r471sknr.js +209 -0
  111. package/dist/shared/chunk-s2jeqqan.js +243 -0
  112. package/dist/shared/chunk-t0hcxh89.d.ts +124 -0
  113. package/dist/shared/chunk-w48eyvfr.d.ts +56 -0
  114. package/dist/shared/chunk-w5h6ay93.js +72 -0
  115. package/dist/shared/chunk-wkg17nxs.d.ts +101 -0
  116. package/dist/shared/chunk-x7f3g82r.js +285 -0
  117. package/dist/shared/chunk-xq5hc5gv.js +333 -0
  118. package/dist/shared/chunk-y0188bbn.js +331 -0
  119. package/dist/shared/chunk-ym0xbses.js +518 -0
  120. package/dist/styles.css +264 -0
  121. package/index.ts +22 -0
  122. package/lib/artwork.ts +112 -0
  123. package/lib/clock.ts +53 -0
  124. package/lib/geometry.ts +130 -0
  125. package/lib/island-context.tsx +24 -0
  126. package/lib/motion.ts +42 -0
  127. package/mock/activities.tsx +77 -0
  128. package/mock/artwork.tsx +37 -0
  129. package/mock/clipboard.tsx +79 -0
  130. package/mock/clock.tsx +77 -0
  131. package/mock/data.ts +139 -0
  132. package/mock/desktop.tsx +83 -0
  133. package/mock/files.tsx +70 -0
  134. package/mock/fit.ts +26 -0
  135. package/mock/island-content.tsx +142 -0
  136. package/mock/scene.tsx +52 -0
  137. package/mock/screen.tsx +76 -0
  138. package/mock/settings.tsx +489 -0
  139. package/mock/system.ts +46 -0
  140. package/mock/weather.tsx +105 -0
  141. package/package.json +122 -4
@@ -0,0 +1,143 @@
1
+ /*!
2
+ * Local addition: the open island's layout, tabs in the wings, the tab's
3
+ * title and its view. Rebuilt from Just Notch's runtime
4
+ * (`island/expanded.tsx`) as a presentational block: tabs and their views
5
+ * come in as props.
6
+ */
7
+
8
+ 'use client'
9
+
10
+ import Button from '@justanarthur/modo-ui/components/actions/button'
11
+ import { useReduceMotion } from '@justanarthur/modo-ui/lib/reduced-motion'
12
+ import { useControllableState } from '@justanarthur/modo-ui/lib/use-controllable-state'
13
+ import { cn } from '@justanarthur/modo-ui/lib/utils'
14
+ import ScrollArea from '@justanarthur/modo-ui/primitives/layout/scroll-area'
15
+ import { SizeProvider } from '@justanarthur/modo-ui/primitives/systems/sizes'
16
+ import { Settings } from 'lucide-react'
17
+ import { motion } from 'motion/react'
18
+ import { type ReactNode, useState } from 'react'
19
+ import IslandTabs, { type IslandTab } from '../../../components/island/island-tabs'
20
+ import { DEFAULT_NOTCH, INSET } from '../../../lib/geometry'
21
+ import { useIsland } from '../../../lib/island-context'
22
+ import { contentEnter, contentHidden, contentShown } from '../../../lib/motion'
23
+
24
+ interface ExpandedIslandTab extends IslandTab {
25
+ /** The tab's view, in the content area. */
26
+ content: ReactNode
27
+ }
28
+
29
+ interface ExpandedIslandProps {
30
+ /** The tabs, in order, each with its view. */
31
+ tabs: ExpandedIslandTab[]
32
+ /** The selected tab's value (controlled). */
33
+ value?: string
34
+ /** The tab selected at first (uncontrolled). Defaults to the first tab. */
35
+ defaultValue?: string
36
+ /** Called with the value of the tab a press or an arrow key selects. */
37
+ onValueChange?: (value: string) => void
38
+ /** Called by the settings button at the right wing's far end; without it the button hides. */
39
+ onSettings?: () => void
40
+ /** The settings button's accessible name. Defaults to `'Settings'`. */
41
+ settingsLabel?: string
42
+ /** What the content area says without tabs. Defaults to `'Nothing here yet'`. */
43
+ empty?: ReactNode
44
+ /** Classes for the root, which fills the open island. */
45
+ className?: string
46
+ }
47
+
48
+ /**
49
+ * The open island's layout: icon tabs in the wings around the notch, the
50
+ * tab's title under them, and its view in a content area of fixed height.
51
+ *
52
+ * The header is the notch's height, so the tabs sit in the wings beside the
53
+ * hardware notch: the kit's IslandTabs at the compact step, with a settings
54
+ * button at the right wing's far end when `onSettings` is given. Under it
55
+ * the selected tab's title, or the hovered tab's as a preview. The view
56
+ * fills the rest: the area keeps its height whatever the view holds, and a
57
+ * taller view scrolls inside it, its edges fading with `scroll-fade` (a
58
+ * modo-ui ScrollArea), back at the top on each new tab, where the new view
59
+ * sharpens in the way the island swaps its content. Every part starts at
60
+ * the island's one inset, clear of its rounded bottom corners.
61
+ *
62
+ * The views are made for the area the default panel leaves (about 680 × 165
63
+ * at 720 × 240): build each one on the kit's Widget frame, so every tab has
64
+ * one hero set large, a muted line, its facts and quiet actions in the same
65
+ * places.
66
+ *
67
+ * Pass it as the Island's `expanded`; it reads the notch from the Island.
68
+ * Selection runs through `value` / `onValueChange`, or is kept here from
69
+ * `defaultValue`.
70
+ *
71
+ * @example {@include ./examples.mdx}
72
+ */
73
+ export default function ExpandedIsland({
74
+ tabs,
75
+ value: valueProp,
76
+ defaultValue,
77
+ onValueChange,
78
+ onSettings,
79
+ settingsLabel = 'Settings',
80
+ empty = 'Nothing here yet',
81
+ className,
82
+ }: ExpandedIslandProps) {
83
+ const island = useIsland()
84
+ const [value, setValue] = useControllableState(valueProp, defaultValue ?? tabs[0]?.value, onValueChange)
85
+ const [hovered, setHovered] = useState<string | null>(null)
86
+ const tab = tabs.find(t => t.value === value) ?? tabs[0]
87
+ const title = tabs.find(t => t.value === hovered)?.label ?? tab?.label
88
+ const notch = island?.geometry.notch.height ?? DEFAULT_NOTCH.height
89
+ const reduced = useReduceMotion()
90
+
91
+ return (
92
+ <div className={cn('flex size-full flex-col', className)}>
93
+ <SizeProvider size="compact">
94
+ <div className="flex shrink-0 items-center" style={{ height: notch, paddingInline: INSET }}>
95
+ {tabs.length > 0 ? (
96
+ <IslandTabs
97
+ tabs={tabs}
98
+ value={tab?.value}
99
+ onValueChange={setValue}
100
+ onHoverChange={setHovered}
101
+ trailing={
102
+ onSettings && (
103
+ <Button variant="ghost" size="icon-compact" aria-label={settingsLabel} onClick={onSettings}>
104
+ <Settings size={14} strokeWidth={1.5} />
105
+ </Button>
106
+ )
107
+ }
108
+ />
109
+ ) : (
110
+ <div className="flex-1" />
111
+ )}
112
+ </div>
113
+ </SizeProvider>
114
+ <div className="flex min-h-0 flex-1 flex-col pb-3">
115
+ <div className="flex h-6 shrink-0 items-end" style={{ paddingInline: INSET }}>
116
+ <span className="truncate text-caption weight-medium text-muted-foreground">{title}</span>
117
+ </div>
118
+ <ScrollArea
119
+ key={tab?.value}
120
+ className="min-h-0 flex-1"
121
+ viewportClassName="scroll-fade [&>div]:flex [&>div]:min-h-full [&>div]:flex-col"
122
+ >
123
+ <motion.div
124
+ className="flex flex-1 flex-col py-1 [&>*]:flex-1"
125
+ style={{ paddingInline: INSET }}
126
+ initial={reduced ? { opacity: 0 } : contentHidden}
127
+ animate={reduced ? { opacity: 1 } : contentShown}
128
+ transition={contentEnter}
129
+ >
130
+ {tab ? (
131
+ tab.content
132
+ ) : (
133
+ <div className="flex items-center justify-center text-caption text-muted-foreground">{empty}</div>
134
+ )}
135
+ </motion.div>
136
+ </ScrollArea>
137
+ </div>
138
+ </div>
139
+ )
140
+ }
141
+
142
+ export type { ExpandedIslandProps, ExpandedIslandTab }
143
+ export { ExpandedIsland }
@@ -0,0 +1,34 @@
1
+ import SettingsWindow from './index'
2
+ import { ABOUT, MockWindow, PERMISSIONS, PLUGINS } from '../../../mock/settings'
3
+
4
+ # Settings
5
+
6
+ General, Plugins, Permissions and About, then a page per plugin's settings.
7
+
8
+ <MockWindow title="Settings">
9
+ <SettingsWindow name="Just Notch" plugins={PLUGINS} permissions={PERMISSIONS} about={ABOUT} />
10
+ </MockWindow>
11
+
12
+ # Plugins
13
+
14
+ A switch per plugin, and a chevron to the page of one that brings settings.
15
+
16
+ <MockWindow title="Settings">
17
+ <SettingsWindow name="Just Notch" defaultValue="plugins" plugins={PLUGINS} defaultEnabled={{ system: false }} permissions={PERMISSIONS} about={ABOUT} />
18
+ </MockWindow>
19
+
20
+ # Permissions
21
+
22
+ A spinner while one is read; Open Settings beside one that isn't granted.
23
+
24
+ <MockWindow title="Settings">
25
+ <SettingsWindow name="Just Notch" defaultValue="permissions" plugins={PLUGINS} permissions={PERMISSIONS} about={ABOUT} />
26
+ </MockWindow>
27
+
28
+ # A plugin's settings
29
+
30
+ Grouped rows: a label, what it does, the control at the end.
31
+
32
+ <MockWindow title="Settings">
33
+ <SettingsWindow name="Just Notch" defaultValue="plugin:clock" plugins={PLUGINS} permissions={PERMISSIONS} about={ABOUT} />
34
+ </MockWindow>
@@ -0,0 +1,375 @@
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 { ChevronRight, 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
+ onOpen: (id: string) => void
153
+ }
154
+
155
+ function Plugins({ plugins, enabled, onChange, onOpen }: PluginsProps) {
156
+ return (
157
+ <Page title="Plugins" lead="Each plugin adds activities and widgets to the island.">
158
+ {plugins.length === 0 ? (
159
+ <p className="m-0 text-body text-muted-foreground">No plugins installed.</p>
160
+ ) : (
161
+ <List>
162
+ <List.Section title="Installed" aside={`${plugins.filter(p => enabled[p.id] ?? true).length} on`}>
163
+ {plugins.map(plugin => {
164
+ const Icon = plugin.icon ?? Puzzle
165
+ return (
166
+ <List.Row
167
+ key={plugin.id}
168
+ label={
169
+ <span className="flex min-w-0 items-center gap-2">
170
+ <Icon size={16} strokeWidth={1.5} className="shrink-0 text-muted-foreground" />
171
+ <span className="truncate">{plugin.name}</span>
172
+ </span>
173
+ }
174
+ description={plugin.description}
175
+ >
176
+ {plugin.settings !== undefined && (
177
+ <Button
178
+ variant="ghost"
179
+ size="icon"
180
+ aria-label={`${plugin.name} settings`}
181
+ onClick={() => onOpen(plugin.id)}
182
+ >
183
+ <ChevronRight />
184
+ </Button>
185
+ )}
186
+ <Switch
187
+ aria-label={plugin.name}
188
+ className={LIST_SWITCH}
189
+ checked={enabled[plugin.id] ?? true}
190
+ onCheckedChange={on => onChange({ ...enabled, [plugin.id]: on })}
191
+ />
192
+ </List.Row>
193
+ )
194
+ })}
195
+ </List.Section>
196
+ </List>
197
+ )}
198
+ </Page>
199
+ )
200
+ }
201
+
202
+ interface PermissionsProps {
203
+ permissions: SettingsPermission[]
204
+ onOpen?: (id: string) => void
205
+ }
206
+
207
+ function Permissions({ permissions, onOpen }: PermissionsProps) {
208
+ return (
209
+ <Page title="Permissions" lead="What macOS lets the app read and control.">
210
+ <List>
211
+ <List.Section title="Privacy & Security">
212
+ {permissions.map(permission => (
213
+ <List.Row
214
+ key={permission.id}
215
+ label={
216
+ <span className="flex min-w-0 items-center gap-2">
217
+ <StatusDot
218
+ status={permission.granted === undefined ? 'running' : permission.granted ? 'success' : 'waiting'}
219
+ label={
220
+ permission.granted === undefined ? 'Checking' : permission.granted ? 'Granted' : 'Not granted'
221
+ }
222
+ />
223
+ <span className="truncate">{permission.label}</span>
224
+ </span>
225
+ }
226
+ description={permission.description}
227
+ >
228
+ {permission.granted === false ? (
229
+ <Button variant="ghost" size="compact" onClick={() => onOpen?.(permission.id)}>
230
+ Open Settings
231
+ </Button>
232
+ ) : (
233
+ <span className="pr-3 text-caption text-muted-foreground">
234
+ {permission.granted ? 'Granted' : 'Checking…'}
235
+ </span>
236
+ )}
237
+ </List.Row>
238
+ ))}
239
+ </List.Section>
240
+ </List>
241
+ </Page>
242
+ )
243
+ }
244
+
245
+ function About({ rows }: { rows: AboutRow[] }) {
246
+ return (
247
+ <Page title="About">
248
+ <List>
249
+ {rows.map(row => (
250
+ <List.Row key={row.label} label={<span className="text-muted-foreground">{row.label}</span>}>
251
+ <span className="min-w-0 truncate pr-3 text-body text-foreground">{row.value}</span>
252
+ </List.Row>
253
+ ))}
254
+ </List>
255
+ </Page>
256
+ )
257
+ }
258
+
259
+ const PAGES: { value: string; label: string; icon: IconComponent }[] = [
260
+ { value: 'general', label: 'General', icon: Settings2 },
261
+ { value: 'plugins', label: 'Plugins', icon: Puzzle },
262
+ { value: 'permissions', label: 'Permissions', icon: ShieldCheck },
263
+ { value: 'about', label: 'About', icon: Info },
264
+ ]
265
+
266
+ /**
267
+ * A notch app's settings window: General, Plugins, Permissions and About,
268
+ * and a page for each plugin's own settings.
269
+ *
270
+ * A modo-ui Sidebar pinned open (the window is small, about 760 × 520, so
271
+ * it never folds into a drawer) lists the pages under the app's `name`, then
272
+ * the plugins that bring settings. General holds the launch at login Switch
273
+ * and a ChoiceList of the screens the island shows on. Plugins lists each
274
+ * installed plugin with its glyph, its line, a Switch that turns it on or
275
+ * off and, for one that brings settings, a chevron to its page. Permissions
276
+ * shows what macOS granted as a StatusDot per row, with Open Settings beside
277
+ * one that isn't granted, and a spinner while it's being read. About lists the `about` rows. A plugin's page shows its
278
+ * `settings` node under its name.
279
+ *
280
+ * The page, the preferences and the plugins' states each run both ways
281
+ * (`value`, `preferences`, `enabled` with their `default*` and `on*Change`),
282
+ * so the window works on its own or on a host's store. It fills its
283
+ * container; the window's frame and title bar are the host's.
284
+ *
285
+ * @example {@include ./examples.mdx}
286
+ */
287
+ export default function SettingsWindow({
288
+ name = 'Notch',
289
+ value,
290
+ defaultValue = 'general',
291
+ onValueChange,
292
+ preferences: preferencesProp,
293
+ defaultPreferences = { launchAtLogin: true, screens: 'notched' },
294
+ onPreferencesChange,
295
+ plugins = [],
296
+ enabled: enabledProp,
297
+ defaultEnabled = {},
298
+ onEnabledChange,
299
+ permissions = [],
300
+ onOpenPermission,
301
+ about = [],
302
+ className,
303
+ }: SettingsWindowProps) {
304
+ const [page, setPage] = useControllableState(value, defaultValue, onValueChange)
305
+ const [preferences, setPreferences] = useControllableState(preferencesProp, defaultPreferences, onPreferencesChange)
306
+ const [enabled, setEnabled] = useControllableState(enabledProp, defaultEnabled, onEnabledChange)
307
+ const withSettings = plugins.filter(plugin => plugin.settings !== undefined)
308
+ const plugin = withSettings.find(p => `plugin:${p.id}` === page)
309
+
310
+ return (
311
+ <Sidebar.Provider
312
+ className={cn('h-full min-h-0', className)}
313
+ persist={false}
314
+ shortcut={null}
315
+ mobileBreakpoint={0}
316
+ width="13rem"
317
+ >
318
+ <Sidebar className="h-full" collapsible="none" value={page} onValueChange={setPage}>
319
+ <Sidebar.Content>
320
+ <Sidebar.Group>
321
+ <Sidebar.GroupLabel>{name}</Sidebar.GroupLabel>
322
+ <Sidebar.Menu>
323
+ {PAGES.map(item => (
324
+ <Sidebar.MenuItem key={item.value}>
325
+ <Sidebar.MenuButton icon={item.icon} value={item.value}>
326
+ {item.label}
327
+ </Sidebar.MenuButton>
328
+ </Sidebar.MenuItem>
329
+ ))}
330
+ </Sidebar.Menu>
331
+ </Sidebar.Group>
332
+ {withSettings.length > 0 && (
333
+ <Sidebar.Group>
334
+ <Sidebar.GroupLabel>Plugin settings</Sidebar.GroupLabel>
335
+ <Sidebar.Menu>
336
+ {withSettings.map(p => (
337
+ <Sidebar.MenuItem key={p.id}>
338
+ <Sidebar.MenuButton icon={p.icon} value={`plugin:${p.id}`}>
339
+ {p.name}
340
+ </Sidebar.MenuButton>
341
+ </Sidebar.MenuItem>
342
+ ))}
343
+ </Sidebar.Menu>
344
+ </Sidebar.Group>
345
+ )}
346
+ </Sidebar.Content>
347
+ </Sidebar>
348
+ <Sidebar.Inset className="min-h-0 min-w-0">
349
+ <ScrollArea key={page} className="h-full" viewportClassName="scroll-fade">
350
+ <div className="mx-auto flex w-full max-w-160 flex-col gap-8 p-8">
351
+ {page === 'general' && <General preferences={preferences} onChange={setPreferences} />}
352
+ {page === 'plugins' && (
353
+ <Plugins
354
+ plugins={plugins}
355
+ enabled={enabled}
356
+ onChange={setEnabled}
357
+ onOpen={id => setPage(`plugin:${id}`)}
358
+ />
359
+ )}
360
+ {page === 'permissions' && <Permissions permissions={permissions} onOpen={onOpenPermission} />}
361
+ {page === 'about' && <About rows={about} />}
362
+ {plugin && (
363
+ <Page title={plugin.name} lead={plugin.description}>
364
+ {plugin.settings}
365
+ </Page>
366
+ )}
367
+ </div>
368
+ </ScrollArea>
369
+ </Sidebar.Inset>
370
+ </Sidebar.Provider>
371
+ )
372
+ }
373
+
374
+ export type { AboutRow, AppPreferences, ScreensPreference, SettingsPermission, SettingsPlugin, SettingsWindowProps }
375
+ export { SettingsWindow }
@@ -0,0 +1,83 @@
1
+ import ClipboardHistory from './index'
2
+ import { FlashIsland, WidgetIsland, WingsIsland } from '../../../mock/island-content'
3
+ import { CLIP_NOW, CLIPS, PINNED } from '../../../mock/clipboard'
4
+
5
+ # Latest clip
6
+
7
+ The newest clip as the hero, with where it came from and Copy; the history beside it, pinned clips on top. Arrow keys move the selection, Enter copies.
8
+
9
+ <WidgetIsland tab="clipboard">
10
+ <ClipboardHistory clips={CLIPS} defaultPinned={PINNED} now={CLIP_NOW} onDelete={() => {}} />
11
+ </WidgetIsland>
12
+
13
+ # Kinds
14
+
15
+ Each kind previews as what it is.
16
+
17
+ ## Link
18
+
19
+ The domain with its favicon, the page's title, the path.
20
+
21
+ <WidgetIsland tab="clipboard">
22
+ <ClipboardHistory clips={CLIPS} defaultValue="docs" now={CLIP_NOW} onDelete={() => {}} />
23
+ </WidgetIsland>
24
+
25
+ ## Image
26
+
27
+ <WidgetIsland tab="clipboard">
28
+ <ClipboardHistory clips={CLIPS} defaultValue="shot" now={CLIP_NOW} onDelete={() => {}} />
29
+ </WidgetIsland>
30
+
31
+ ## Color
32
+
33
+ <WidgetIsland tab="clipboard">
34
+ <ClipboardHistory clips={CLIPS} defaultValue="brand" defaultPinned={PINNED} now={CLIP_NOW} onDelete={() => {}} />
35
+ </WidgetIsland>
36
+
37
+ ## File
38
+
39
+ <WidgetIsland tab="clipboard">
40
+ <ClipboardHistory clips={CLIPS} defaultValue="brief" now={CLIP_NOW} onDelete={() => {}} />
41
+ </WidgetIsland>
42
+
43
+ # Searching
44
+
45
+ `defaultQuery` (or `query`) narrows the list; the hero follows the first match.
46
+
47
+ <WidgetIsland tab="clipboard">
48
+ <ClipboardHistory clips={CLIPS} defaultQuery="main" now={CLIP_NOW} />
49
+ </WidgetIsland>
50
+
51
+ # Paused, an app ignored
52
+
53
+ `paused` stops recording, with a chip and Resume on the context line; `ignoredApp` says whose copies are never kept.
54
+
55
+ <WidgetIsland tab="clipboard">
56
+ <ClipboardHistory clips={CLIPS} defaultPaused ignoredApp="1Password" now={CLIP_NOW} />
57
+ </WidgetIsland>
58
+
59
+ # Empty
60
+
61
+ <WidgetIsland tab="clipboard">
62
+ <ClipboardHistory clips={[]} />
63
+ </WidgetIsland>
64
+
65
+ # Empty and paused
66
+
67
+ <WidgetIsland tab="clipboard">
68
+ <ClipboardHistory clips={[]} defaultPaused />
69
+ </WidgetIsland>
70
+
71
+ # Compact
72
+
73
+ `ClipboardHistory.Leading` and `ClipboardHistory.Trailing`: the glyph and the clips that came in since the island was open.
74
+
75
+ <WingsIsland leading={<ClipboardHistory.Leading />} trailing={<ClipboardHistory.Trailing count={3} />} />
76
+
77
+ # Copied
78
+
79
+ `ClipboardHistory.Copied`, the flash when something is copied, with Pin.
80
+
81
+ <FlashIsland>
82
+ <ClipboardHistory.Copied clip={CLIPS[3]} onPin={() => {}} />
83
+ </FlashIsland>