@justanarthur/modo-ui-notch 0.2.0 → 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.
- package/README.md +11 -11
- package/blocks/activities/agenda/examples.mdx +21 -5
- package/blocks/activities/agenda/index.tsx +291 -182
- package/blocks/activities/clock/examples.mdx +73 -0
- package/blocks/activities/clock/index.tsx +619 -0
- package/blocks/activities/now-playing/examples.mdx +32 -13
- package/blocks/activities/now-playing/index.tsx +319 -126
- package/blocks/activities/weather/examples.mdx +115 -0
- package/blocks/activities/weather/index.tsx +634 -0
- package/blocks/app/expanded-island/examples.mdx +8 -7
- package/blocks/app/expanded-island/index.tsx +19 -3
- package/blocks/app/settings-window/examples.mdx +6 -2
- package/blocks/app/settings-window/index.tsx +25 -7
- package/blocks/system/clipboard/examples.mdx +83 -0
- package/blocks/system/clipboard/index.tsx +563 -0
- package/blocks/system/recent-files/examples.mdx +66 -0
- package/blocks/system/recent-files/index.tsx +542 -0
- package/blocks/system/system-stats/examples.mdx +38 -9
- package/blocks/system/system-stats/index.tsx +241 -107
- 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 +431 -0
- package/dist/blocks/activities/agenda/index.d.ts +1 -1
- package/dist/blocks/activities/agenda/index.js +3 -3
- package/dist/blocks/activities/clock/index.d.ts +2 -0
- package/dist/blocks/activities/clock/index.js +25 -0
- package/dist/blocks/activities/now-playing/index.d.ts +3 -2
- package/dist/blocks/activities/now-playing/index.js +5 -3
- package/dist/blocks/activities/weather/index.d.ts +2 -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 +2 -0
- package/dist/blocks/system/clipboard/index.js +17 -0
- package/dist/blocks/system/recent-files/index.d.ts +2 -0
- package/dist/blocks/system/recent-files/index.js +19 -0
- package/dist/blocks/system/system-stats/index.d.ts +2 -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 +30 -0
- package/dist/index.d.ts +15 -15
- package/dist/index.js +102 -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-2818esrq.d.ts +140 -0
- package/dist/shared/{chunk-yngkkxz2.d.ts → chunk-2m5dz8nf.d.ts} +4 -4
- package/dist/shared/chunk-3thgcfcq.d.ts +151 -0
- package/dist/shared/chunk-416tsgbc.d.ts +175 -0
- package/dist/shared/{chunk-zvh0d3qb.js → chunk-61t2dfte.js} +1 -1
- package/dist/shared/chunk-7fvnrtz4.d.ts +105 -0
- package/dist/shared/{chunk-hpsabfsd.d.ts → chunk-81fpptwp.d.ts} +1 -1
- package/dist/shared/chunk-9c7ewvkk.js +381 -0
- package/dist/shared/{chunk-mp1nx0ez.js → chunk-9m0xbg5v.js} +14 -3
- package/dist/shared/{chunk-wwjxs75m.js → chunk-9xtcv3sy.js} +26 -12
- package/dist/shared/chunk-bvtyjcce.d.ts +123 -0
- package/dist/shared/{chunk-s33y1pcq.js → chunk-cc9nwbtf.js} +20 -10
- package/dist/shared/chunk-da177e8r.d.ts +114 -0
- package/dist/shared/{chunk-6c1jbefs.d.ts → chunk-fexwzycv.d.ts} +3 -3
- package/dist/shared/chunk-gejenfap.d.ts +25 -0
- package/dist/shared/{chunk-rr5e0g15.d.ts → chunk-j755a1a5.d.ts} +7 -1
- package/dist/shared/chunk-j77cx8dp.js +498 -0
- package/dist/shared/chunk-mt0k6v8x.js +474 -0
- package/dist/shared/{chunk-78w7qwp0.js → chunk-ndf79pv5.js} +1 -1
- package/dist/shared/{chunk-9nhpg9t8.d.ts → chunk-pfhy5e4q.d.ts} +7 -1
- package/dist/shared/chunk-qdzemt2v.js +477 -0
- package/dist/shared/{chunk-rpfwv3pz.js → chunk-r471sknr.js} +1 -1
- package/dist/shared/chunk-s2jeqqan.js +243 -0
- package/dist/shared/chunk-t0hcxh89.d.ts +124 -0
- package/dist/shared/chunk-w5h6ay93.js +72 -0
- package/dist/shared/chunk-wkg17nxs.d.ts +101 -0
- package/dist/shared/chunk-x7f3g82r.js +285 -0
- package/dist/shared/chunk-xq5hc5gv.js +333 -0
- package/dist/shared/{chunk-sbnrhy5m.js → chunk-y0188bbn.js} +2 -2
- package/dist/shared/chunk-ym0xbses.js +518 -0
- package/dist/styles.css +97 -55
- 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 +79 -0
- package/mock/clock.tsx +77 -0
- package/mock/data.ts +30 -44
- package/mock/files.tsx +70 -0
- package/mock/island-content.tsx +43 -118
- package/mock/screen.tsx +76 -0
- package/mock/settings.tsx +370 -91
- package/mock/system.ts +46 -0
- package/mock/weather.tsx +105 -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
|
@@ -1,34 +0,0 @@
|
|
|
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>
|
|
@@ -1,167 +0,0 @@
|
|
|
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 }
|
|
@@ -1,25 +0,0 @@
|
|
|
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>
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Local addition: a notch app's Bluetooth devices and their batteries.
|
|
3
|
-
* Rebuilt from Just Notch's devices plugin (`Devices`, `Device`, `Connected`)
|
|
4
|
-
* as presentational parts: the devices come in as props.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
'use client'
|
|
8
|
-
|
|
9
|
-
import Button from '@justanarthur/modo-ui/components/actions/button'
|
|
10
|
-
import EmptyState from '@justanarthur/modo-ui/components/feedback/empty-state'
|
|
11
|
-
import StatusDot from '@justanarthur/modo-ui/components/feedback/status-dot'
|
|
12
|
-
import { cn } from '@justanarthur/modo-ui/lib/utils'
|
|
13
|
-
import {
|
|
14
|
-
Bluetooth,
|
|
15
|
-
Gamepad2,
|
|
16
|
-
Headphones,
|
|
17
|
-
Keyboard,
|
|
18
|
-
type LucideIcon,
|
|
19
|
-
Mouse,
|
|
20
|
-
Smartphone,
|
|
21
|
-
Speaker,
|
|
22
|
-
Watch,
|
|
23
|
-
} from 'lucide-react'
|
|
24
|
-
import BatteryGlyph from '../../../components/indicators/battery-glyph'
|
|
25
|
-
import IslandFlash from '../../../components/island/island-flash'
|
|
26
|
-
|
|
27
|
-
type DeviceKind = 'headphones' | 'keyboard' | 'mouse' | 'speaker' | 'gamepad' | 'phone' | 'watch' | 'other'
|
|
28
|
-
|
|
29
|
-
interface DeviceInfo {
|
|
30
|
-
id: string
|
|
31
|
-
name: string
|
|
32
|
-
/** What it is, for its glyph. */
|
|
33
|
-
kind: DeviceKind
|
|
34
|
-
connected: boolean
|
|
35
|
-
/** Its charge in percent, when it reports one. */
|
|
36
|
-
battery?: number
|
|
37
|
-
charging?: boolean
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
interface DevicesProps {
|
|
41
|
-
/** The paired devices; connected ones list first, then by name. */
|
|
42
|
-
devices: DeviceInfo[]
|
|
43
|
-
/** Called by the empty state's Open Bluetooth Settings; without it the button hides. */
|
|
44
|
-
onOpenSettings?: () => void
|
|
45
|
-
/** Classes for the root, which fills its container. */
|
|
46
|
-
className?: string
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const KIND: Record<DeviceKind, LucideIcon> = {
|
|
50
|
-
headphones: Headphones,
|
|
51
|
-
keyboard: Keyboard,
|
|
52
|
-
mouse: Mouse,
|
|
53
|
-
speaker: Speaker,
|
|
54
|
-
gamepad: Gamepad2,
|
|
55
|
-
phone: Smartphone,
|
|
56
|
-
watch: Watch,
|
|
57
|
-
other: Bluetooth,
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function Charge({ device }: { device: DeviceInfo }) {
|
|
61
|
-
if (device.battery === undefined) return null
|
|
62
|
-
return (
|
|
63
|
-
<span className="flex shrink-0 items-center gap-2 text-caption tabular-nums text-muted-foreground">
|
|
64
|
-
{device.battery}%
|
|
65
|
-
<BatteryGlyph level={device.battery} charging={device.charging} fillIn={false} />
|
|
66
|
-
</span>
|
|
67
|
-
)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function Glyph({ device }: { device: DeviceInfo }) {
|
|
71
|
-
const Icon = KIND[device.kind]
|
|
72
|
-
return (
|
|
73
|
-
<span
|
|
74
|
-
className={cn(
|
|
75
|
-
'flex size-8 shrink-0 items-center justify-center rounded-full',
|
|
76
|
-
device.connected ? 'bg-surface-3 text-foreground' : 'bg-surface-2 text-muted-foreground',
|
|
77
|
-
)}
|
|
78
|
-
>
|
|
79
|
-
<Icon size={16} strokeWidth={1.5} />
|
|
80
|
-
</span>
|
|
81
|
-
)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function Device({ device }: { device: DeviceInfo }) {
|
|
85
|
-
return (
|
|
86
|
-
<li className="flex h-11 min-w-0 items-center gap-3">
|
|
87
|
-
<Glyph device={device} />
|
|
88
|
-
<div className="flex min-w-0 flex-1 flex-col">
|
|
89
|
-
<span className={cn('truncate text-body', device.connected ? 'text-foreground' : 'text-muted-foreground')}>
|
|
90
|
-
{device.name}
|
|
91
|
-
</span>
|
|
92
|
-
<span className="flex items-center gap-1.5 text-caption text-muted-foreground">
|
|
93
|
-
<StatusDot status={device.connected ? 'success' : 'idle'} size="compact" />
|
|
94
|
-
{device.connected ? 'Connected' : 'Not connected'}
|
|
95
|
-
</span>
|
|
96
|
-
</div>
|
|
97
|
-
{device.connected && <Charge device={device} />}
|
|
98
|
-
</li>
|
|
99
|
-
)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/** The island's flash when a device connects: its glyph, name and battery. */
|
|
103
|
-
function DevicesConnected({ device }: { device: DeviceInfo }) {
|
|
104
|
-
const Icon = KIND[device.kind]
|
|
105
|
-
return (
|
|
106
|
-
<IslandFlash
|
|
107
|
-
icon={
|
|
108
|
-
<span className="flex size-8 items-center justify-center rounded-full bg-surface-3 text-foreground">
|
|
109
|
-
<Icon size={16} strokeWidth={1.5} />
|
|
110
|
-
</span>
|
|
111
|
-
}
|
|
112
|
-
title={device.name}
|
|
113
|
-
caption="Connected"
|
|
114
|
-
value={device.battery === undefined ? undefined : `${device.battery}%`}
|
|
115
|
-
trailing={
|
|
116
|
-
device.battery === undefined ? undefined : <BatteryGlyph level={device.battery} charging={device.charging} />
|
|
117
|
-
}
|
|
118
|
-
/>
|
|
119
|
-
)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* A notch app's Bluetooth devices: what's paired, what's connected and how
|
|
124
|
-
* much charge each has left.
|
|
125
|
-
*
|
|
126
|
-
* Devices list in two columns, connected first: a glyph for the kind of
|
|
127
|
-
* device (raised while connected), the name, a StatusDot with Connected or
|
|
128
|
-
* Not connected, and for a connected device that reports one, its charge as
|
|
129
|
-
* a figure and a BatteryGlyph, which turns to the warning and error hues as
|
|
130
|
-
* it runs low. Without devices it says how to pair one, with a button to the
|
|
131
|
-
* system's Bluetooth settings when `onOpenSettings` is given.
|
|
132
|
-
*
|
|
133
|
-
* `Devices.Connected` is the island's flash when a device connects.
|
|
134
|
-
*
|
|
135
|
-
* @example {@include ./examples.mdx}
|
|
136
|
-
*/
|
|
137
|
-
function Devices({ devices, onOpenSettings, className }: DevicesProps) {
|
|
138
|
-
if (devices.length === 0)
|
|
139
|
-
return (
|
|
140
|
-
<div className={cn('flex size-full items-center justify-center', className)}>
|
|
141
|
-
<EmptyState
|
|
142
|
-
size="compact"
|
|
143
|
-
icon={Bluetooth}
|
|
144
|
-
title="No Bluetooth devices"
|
|
145
|
-
description="Pair headphones, a keyboard or a mouse to see them here."
|
|
146
|
-
actions={
|
|
147
|
-
onOpenSettings && (
|
|
148
|
-
<Button variant="secondary" size="compact" onClick={onOpenSettings}>
|
|
149
|
-
Open Bluetooth Settings
|
|
150
|
-
</Button>
|
|
151
|
-
)
|
|
152
|
-
}
|
|
153
|
-
/>
|
|
154
|
-
</div>
|
|
155
|
-
)
|
|
156
|
-
|
|
157
|
-
const sorted = [...devices].sort((a, b) => Number(b.connected) - Number(a.connected) || a.name.localeCompare(b.name))
|
|
158
|
-
return (
|
|
159
|
-
<ul className={cn('m-0 grid list-none grid-cols-2 content-start gap-x-8 p-0', className)}>
|
|
160
|
-
{sorted.map(device => (
|
|
161
|
-
<Device key={device.id} device={device} />
|
|
162
|
-
))}
|
|
163
|
-
</ul>
|
|
164
|
-
)
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
Devices.Connected = DevicesConnected
|
|
168
|
-
|
|
169
|
-
export default Devices
|
|
170
|
-
|
|
171
|
-
export type { DeviceInfo, DeviceKind, DevicesProps }
|
|
172
|
-
export { Devices, DevicesConnected }
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import PowerAlert from './index'
|
|
2
|
-
import { FlashIsland } from '../../../mock/island-content'
|
|
3
|
-
|
|
4
|
-
# Charging
|
|
5
|
-
|
|
6
|
-
A charger plugs in: the figure and the battery in the success hue, and how long until full.
|
|
7
|
-
|
|
8
|
-
<FlashIsland>
|
|
9
|
-
<PowerAlert kind="charging" level={82} minutes={38} />
|
|
10
|
-
</FlashIsland>
|
|
11
|
-
|
|
12
|
-
# On battery
|
|
13
|
-
|
|
14
|
-
<FlashIsland>
|
|
15
|
-
<PowerAlert kind="unplugged" level={82} minutes={252} />
|
|
16
|
-
</FlashIsland>
|
|
17
|
-
|
|
18
|
-
# Low
|
|
19
|
-
|
|
20
|
-
Once on the way down through 20%.
|
|
21
|
-
|
|
22
|
-
<FlashIsland>
|
|
23
|
-
<PowerAlert kind="low" level={19} />
|
|
24
|
-
</FlashIsland>
|
|
25
|
-
|
|
26
|
-
# Critical
|
|
27
|
-
|
|
28
|
-
Once on the way down through 10%.
|
|
29
|
-
|
|
30
|
-
<FlashIsland>
|
|
31
|
-
<PowerAlert kind="critical" level={8} />
|
|
32
|
-
</FlashIsland>
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Local addition: a notch app's power alerts. Rebuilt from Just Notch's
|
|
3
|
-
* power plugin (`Charging`, `Unplugged`, `Low`, `Critical`) as one
|
|
4
|
-
* presentational flash: the battery comes in as props.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
'use client'
|
|
8
|
-
|
|
9
|
-
import { BatteryLow, BatteryWarning, Unplug, Zap } from 'lucide-react'
|
|
10
|
-
import type { ReactNode } from 'react'
|
|
11
|
-
import BatteryGlyph, { type BatteryTone } from '../../../components/indicators/battery-glyph'
|
|
12
|
-
import IslandFlash, { type IslandFlashTone } from '../../../components/island/island-flash'
|
|
13
|
-
|
|
14
|
-
type PowerAlertKind = 'charging' | 'unplugged' | 'low' | 'critical'
|
|
15
|
-
|
|
16
|
-
interface PowerAlertProps {
|
|
17
|
-
/** What happened: a charger plugged in or out, or the battery crossing 20% or 10%. */
|
|
18
|
-
kind: PowerAlertKind
|
|
19
|
-
/** The charge, in percent (0 to 100). */
|
|
20
|
-
level: number
|
|
21
|
-
/** Minutes until full while charging, or of battery left on battery: the caption says it. */
|
|
22
|
-
minutes?: number
|
|
23
|
-
/** Replaces the caption the kind and `minutes` give. */
|
|
24
|
-
caption?: ReactNode
|
|
25
|
-
/** Classes for the row. */
|
|
26
|
-
className?: string
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const ALERT: Record<
|
|
30
|
-
PowerAlertKind,
|
|
31
|
-
{ title: string; tone: IslandFlashTone & BatteryTone; icon: ReactNode; verb?: string; caption?: string }
|
|
32
|
-
> = {
|
|
33
|
-
charging: {
|
|
34
|
-
title: 'Charging',
|
|
35
|
-
tone: 'success',
|
|
36
|
-
icon: <Zap size={18} strokeWidth={1.5} fill="currentColor" />,
|
|
37
|
-
verb: 'until full',
|
|
38
|
-
},
|
|
39
|
-
unplugged: { title: 'On battery', tone: 'default', icon: <Unplug size={18} strokeWidth={1.5} />, verb: 'remaining' },
|
|
40
|
-
low: {
|
|
41
|
-
title: 'Low battery',
|
|
42
|
-
tone: 'warning',
|
|
43
|
-
icon: <BatteryLow size={18} strokeWidth={1.5} />,
|
|
44
|
-
caption: 'Plug in soon',
|
|
45
|
-
},
|
|
46
|
-
critical: {
|
|
47
|
-
title: 'Battery critically low',
|
|
48
|
-
tone: 'error',
|
|
49
|
-
icon: <BatteryWarning size={18} strokeWidth={1.5} />,
|
|
50
|
-
caption: 'Plug in now',
|
|
51
|
-
},
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** Minutes as `38 min` or `4 h 12 min`. */
|
|
55
|
-
const span = (minutes: number) =>
|
|
56
|
-
minutes >= 60 ? `${Math.floor(minutes / 60)} h ${Math.round(minutes % 60)} min` : `${Math.round(minutes)} min`
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* A notch app's power alert: a charger plugged in or out, or the battery
|
|
60
|
-
* running low, as the island's flash.
|
|
61
|
-
*
|
|
62
|
-
* Each kind brings its icon, title and status hue: charging in success,
|
|
63
|
-
* unplugged in the text color, low in warning (at 20%), critical in error
|
|
64
|
-
* (at 10%). The level shows as a figure in that hue and as a BatteryGlyph
|
|
65
|
-
* that fills up from empty as the flash opens. With `minutes`, the caption
|
|
66
|
-
* says how long until full or how much is left; low and critical say to plug
|
|
67
|
-
* in. Pass it as the Island's `flash`, keyed by kind, so one alert replacing
|
|
68
|
-
* another swaps instead of updating in place.
|
|
69
|
-
*
|
|
70
|
-
* @example {@include ./examples.mdx}
|
|
71
|
-
*/
|
|
72
|
-
export default function PowerAlert({ kind, level, minutes, caption, className }: PowerAlertProps) {
|
|
73
|
-
const alert = ALERT[kind]
|
|
74
|
-
const detail = minutes !== undefined && alert.verb ? `${span(minutes)} ${alert.verb}` : alert.caption
|
|
75
|
-
return (
|
|
76
|
-
<IslandFlash
|
|
77
|
-
className={className}
|
|
78
|
-
icon={alert.icon}
|
|
79
|
-
tone={alert.tone}
|
|
80
|
-
title={alert.title}
|
|
81
|
-
caption={caption ?? detail}
|
|
82
|
-
value={`${Math.round(level)}%`}
|
|
83
|
-
trailing={<BatteryGlyph level={level} charging={kind === 'charging'} tone={alert.tone} />}
|
|
84
|
-
/>
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export type { PowerAlertKind, PowerAlertProps }
|
|
89
|
-
export { PowerAlert }
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import BatteryGlyph from './index'
|
|
2
|
-
|
|
3
|
-
# Levels
|
|
4
|
-
|
|
5
|
-
The fill takes the warning hue from 20% down and the error hue from 10%.
|
|
6
|
-
|
|
7
|
-
<div className="flex items-center gap-6">
|
|
8
|
-
<BatteryGlyph level={82} />
|
|
9
|
-
<BatteryGlyph level={46} />
|
|
10
|
-
<BatteryGlyph level={18} />
|
|
11
|
-
<BatteryGlyph level={6} />
|
|
12
|
-
</div>
|
|
13
|
-
|
|
14
|
-
# Charging
|
|
15
|
-
|
|
16
|
-
A bolt, and the success hue.
|
|
17
|
-
|
|
18
|
-
<div className="dark flex items-center gap-6 rounded-box bg-ink px-5 py-3 text-foreground">
|
|
19
|
-
<BatteryGlyph level={82} charging />
|
|
20
|
-
<BatteryGlyph level={12} charging />
|
|
21
|
-
<BatteryGlyph level={100} tone="default" />
|
|
22
|
-
</div>
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Local addition: a battery that fills to its level, for a notch app's power
|
|
3
|
-
* alerts. Rebuilt from Just Notch's power plugin (`Battery`).
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
'use client'
|
|
7
|
-
|
|
8
|
-
import { useReduceMotion } from '@justanarthur/modo-ui/lib/reduced-motion'
|
|
9
|
-
import { spring } from '@justanarthur/modo-ui/lib/springs'
|
|
10
|
-
import { cn } from '@justanarthur/modo-ui/lib/utils'
|
|
11
|
-
import { motion } from 'motion/react'
|
|
12
|
-
|
|
13
|
-
type BatteryTone = 'default' | 'success' | 'warning' | 'error'
|
|
14
|
-
|
|
15
|
-
// Literal table: UnoCSS only generates the classes it can read whole.
|
|
16
|
-
const FILL: Record<BatteryTone, string> = {
|
|
17
|
-
default: 'bg-foreground',
|
|
18
|
-
success: 'bg-status-success',
|
|
19
|
-
warning: 'bg-status-warning',
|
|
20
|
-
error: 'bg-status-error',
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
interface BatteryGlyphProps {
|
|
24
|
-
/** The charge, in percent (0 to 100). */
|
|
25
|
-
level: number
|
|
26
|
-
/** A charger is connected: the bolt shows and the tone turns to success. Defaults to `false`. */
|
|
27
|
-
charging?: boolean
|
|
28
|
-
/** The fill's hue. Defaults to success while charging, error at 10% and below, warning at 20% and below, else the text color. */
|
|
29
|
-
tone?: BatteryTone
|
|
30
|
-
/** Fill up from empty when it first shows, as a flash opens. Defaults to `true`. */
|
|
31
|
-
fillIn?: boolean
|
|
32
|
-
/** What screen readers hear. Defaults to the level, and "charging" while it charges. */
|
|
33
|
-
label?: string
|
|
34
|
-
/** Classes for the glyph. */
|
|
35
|
-
className?: string
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** The tone a battery at `level` takes on its own. */
|
|
39
|
-
function batteryTone(level: number, charging: boolean): BatteryTone {
|
|
40
|
-
if (charging) return 'success'
|
|
41
|
-
if (level <= 10) return 'error'
|
|
42
|
-
if (level <= 20) return 'warning'
|
|
43
|
-
return 'default'
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* A battery at a glance: a case that fills to the charge, a bolt while it
|
|
48
|
-
* charges.
|
|
49
|
-
*
|
|
50
|
-
* The fill turns to the success hue while charging and to the warning and
|
|
51
|
-
* error hues as the charge runs low, unless `tone` pins one. It fills up from
|
|
52
|
-
* empty when it first shows, on the slow spring, the way a power alert opens;
|
|
53
|
-
* a later change of level springs from where it was. A sliver always shows,
|
|
54
|
-
* so an empty battery still reads as one.
|
|
55
|
-
*
|
|
56
|
-
* @example {@include ./examples.mdx}
|
|
57
|
-
*/
|
|
58
|
-
export default function BatteryGlyph({
|
|
59
|
-
level,
|
|
60
|
-
charging = false,
|
|
61
|
-
tone,
|
|
62
|
-
fillIn = true,
|
|
63
|
-
label,
|
|
64
|
-
className,
|
|
65
|
-
}: BatteryGlyphProps) {
|
|
66
|
-
const reduced = useReduceMotion()
|
|
67
|
-
const share = Math.max(0.06, Math.min(1, level / 100))
|
|
68
|
-
const name = label ?? `${Math.round(level)}%${charging ? ', charging' : ''}`
|
|
69
|
-
|
|
70
|
-
return (
|
|
71
|
-
<span role="img" aria-label={name} className={cn('inline-flex shrink-0 items-center gap-px', className)}>
|
|
72
|
-
<span className="relative h-3.5 w-7 overflow-hidden rounded-box bg-active p-0.5">
|
|
73
|
-
<motion.span
|
|
74
|
-
className={cn('block h-full w-full origin-left rounded-glyph', FILL[tone ?? batteryTone(level, charging)])}
|
|
75
|
-
initial={fillIn && !reduced ? { scaleX: 0 } : false}
|
|
76
|
-
animate={{ scaleX: share }}
|
|
77
|
-
transition={reduced ? { duration: 0 } : spring.slow}
|
|
78
|
-
/>
|
|
79
|
-
{charging && (
|
|
80
|
-
<svg aria-hidden viewBox="0 0 24 24" className="absolute inset-0 m-auto size-3 fill-foreground">
|
|
81
|
-
<path d="M13 2 4.5 13.5H11L10 22l8.5-11.5H12z" />
|
|
82
|
-
</svg>
|
|
83
|
-
)}
|
|
84
|
-
</span>
|
|
85
|
-
<span className="h-1.5 w-0.5 rounded-r-full bg-active" />
|
|
86
|
-
</span>
|
|
87
|
-
)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export type { BatteryGlyphProps, BatteryTone }
|
|
91
|
-
export { BatteryGlyph, batteryTone }
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { ShelfFile2, ShelfProps2, ShelfLeading2, ShelfTrailing2, ShelfDropProps2, ShelfDrop2, Shelf2 } from "../../../shared/chunk-50ffk4r7.js";
|
|
2
|
-
export { Shelf2 as Shelf, ShelfDrop2 as ShelfDrop, ShelfDropProps2 as ShelfDropProps, ShelfFile2 as ShelfFile, ShelfLeading2 as ShelfLeading, ShelfProps2 as ShelfProps, ShelfTrailing2 as ShelfTrailing, Shelf2 as default };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ShelfLeading2,
|
|
3
|
-
ShelfTrailing2,
|
|
4
|
-
ShelfDrop2,
|
|
5
|
-
Shelf2,
|
|
6
|
-
shelf_default
|
|
7
|
-
} from "../../../shared/chunk-phb53x1f.js";
|
|
8
|
-
export {
|
|
9
|
-
Shelf2 as Shelf,
|
|
10
|
-
ShelfDrop2 as ShelfDrop,
|
|
11
|
-
ShelfLeading2 as ShelfLeading,
|
|
12
|
-
ShelfTrailing2 as ShelfTrailing,
|
|
13
|
-
shelf_default as default
|
|
14
|
-
};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { TimerKind2, TimerRun2, TimerProps2, TimerLeading2, TimerTrailing2, TimerMinimal2, TimerDoneProps2, TimerDone2, Timer2 } from "../../../shared/chunk-e3e4s4ds.js";
|
|
2
|
-
export { Timer2 as Timer, TimerDone2 as TimerDone, TimerDoneProps2 as TimerDoneProps, TimerKind2 as TimerKind, TimerLeading2 as TimerLeading, TimerMinimal2 as TimerMinimal, TimerProps2 as TimerProps, TimerRun2 as TimerRun, TimerTrailing2 as TimerTrailing, Timer2 as default };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TimerLeading2,
|
|
3
|
-
TimerTrailing2,
|
|
4
|
-
TimerMinimal2,
|
|
5
|
-
TimerDone2,
|
|
6
|
-
Timer2,
|
|
7
|
-
timer_default
|
|
8
|
-
} from "../../../shared/chunk-rx9sphz2.js";
|
|
9
|
-
import"../../../shared/chunk-502rmtap.js";
|
|
10
|
-
import"../../../shared/chunk-gb56m10p.js";
|
|
11
|
-
import"../../../shared/chunk-78w7qwp0.js";
|
|
12
|
-
export {
|
|
13
|
-
Timer2 as Timer,
|
|
14
|
-
TimerDone2 as TimerDone,
|
|
15
|
-
TimerLeading2 as TimerLeading,
|
|
16
|
-
TimerMinimal2 as TimerMinimal,
|
|
17
|
-
TimerTrailing2 as TimerTrailing,
|
|
18
|
-
timer_default as default
|
|
19
|
-
};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { ControlKind2, ControlLevels2, ControlsProps2, ControlsLevelProps2, ControlsLevel2, Controls2 } from "../../../shared/chunk-xdeek16r.js";
|
|
2
|
-
export { ControlKind2 as ControlKind, ControlLevels2 as ControlLevels, Controls2 as Controls, ControlsLevel2 as ControlsLevel, ControlsLevelProps2 as ControlsLevelProps, ControlsProps2 as ControlsProps, Controls2 as default };
|