@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,16 +1,30 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Local addition: a notch app's system load,
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Local addition: a notch app's system load, the busiest figure as the hero
|
|
3
|
+
* with its trend, the rest as facts and the busiest processes beside it.
|
|
4
|
+
* Rebuilt from Just Notch's stats plugin (`System`, `Tile`, `Measuring`,
|
|
5
|
+
* `CpuLoad`) on the kit's Widget frame and modo-ui's Sparkline and Meter:
|
|
6
|
+
* the readings come in as props.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
'use client'
|
|
9
10
|
|
|
10
|
-
import Sparkline from '@justanarthur/modo-ui/components/data-display/sparkline'
|
|
11
|
+
import Sparkline, { type SparklineTone } from '@justanarthur/modo-ui/components/data-display/sparkline'
|
|
12
|
+
import Meter from '@justanarthur/modo-ui/components/feedback/meter'
|
|
13
|
+
import type { SizeVariant } from '@justanarthur/modo-ui/lib/size-context'
|
|
11
14
|
import { cn } from '@justanarthur/modo-ui/lib/utils'
|
|
12
|
-
import {
|
|
13
|
-
|
|
15
|
+
import {
|
|
16
|
+
Activity,
|
|
17
|
+
ArrowDown,
|
|
18
|
+
ArrowUp,
|
|
19
|
+
BatteryCharging,
|
|
20
|
+
BatteryFull,
|
|
21
|
+
BatteryLow,
|
|
22
|
+
BatteryMedium,
|
|
23
|
+
Cpu,
|
|
24
|
+
HardDrive,
|
|
25
|
+
MemoryStick,
|
|
26
|
+
} from 'lucide-react'
|
|
27
|
+
import Widget from '../../../components/island/widget'
|
|
14
28
|
|
|
15
29
|
/** One reading of the system. */
|
|
16
30
|
interface StatsSample {
|
|
@@ -20,21 +34,74 @@ interface StatsSample {
|
|
|
20
34
|
memoryUsed: number
|
|
21
35
|
/** All the memory, in bytes. */
|
|
22
36
|
memoryTotal: number
|
|
37
|
+
/** Memory pressure, from 0 to 1, as the system judges it; without it the share in use stands in. */
|
|
38
|
+
memoryPressure?: number
|
|
23
39
|
/** Network in, in bytes per second. */
|
|
24
40
|
netIn: number
|
|
25
41
|
/** Network out, in bytes per second. */
|
|
26
42
|
netOut: number
|
|
27
43
|
}
|
|
28
44
|
|
|
45
|
+
interface StatsBattery {
|
|
46
|
+
/** The charge, in percent (0 to 100). */
|
|
47
|
+
level: number
|
|
48
|
+
/** A charger is connected. */
|
|
49
|
+
charging?: boolean
|
|
50
|
+
/** Minutes until full while charging, else until empty. */
|
|
51
|
+
minutesLeft?: number
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface StatsDisk {
|
|
55
|
+
/** Free space on the startup disk, in bytes. */
|
|
56
|
+
free: number
|
|
57
|
+
/** The disk's size, in bytes. */
|
|
58
|
+
total: number
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface StatsProcess {
|
|
62
|
+
/** What tells it apart: its pid. */
|
|
63
|
+
id: string
|
|
64
|
+
/** The app or process name. */
|
|
65
|
+
name: string
|
|
66
|
+
/** Its share of the CPU, from 0 to 1. */
|
|
67
|
+
cpu: number
|
|
68
|
+
/** The memory it holds, in bytes. */
|
|
69
|
+
memory?: number
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
type StatsHero = 'cpu' | 'memory'
|
|
73
|
+
|
|
29
74
|
interface SystemStatsProps {
|
|
30
75
|
/** The readings so far, oldest first; the latest is the figure, all of them the trend. Without any, it is still measuring. */
|
|
31
76
|
samples: StatsSample[]
|
|
77
|
+
/** Which figure is the hero: the CPU load, or memory pressure when memory is what's tight. Defaults to `'cpu'`. */
|
|
78
|
+
hero?: StatsHero
|
|
79
|
+
/** The battery, on a laptop. */
|
|
80
|
+
battery?: StatsBattery
|
|
81
|
+
/** The startup disk's free space. */
|
|
82
|
+
disk?: StatsDisk
|
|
83
|
+
/** Seconds since the last boot. */
|
|
84
|
+
uptime?: number
|
|
85
|
+
/** The busiest processes, in any order: the top three list beside the hero, by CPU. */
|
|
86
|
+
processes?: StatsProcess[]
|
|
87
|
+
/** Step on the size ladder. Omitted, it follows the surrounding SizeProvider. */
|
|
88
|
+
size?: SizeVariant
|
|
32
89
|
/** Classes for the root, which fills its container. */
|
|
33
90
|
className?: string
|
|
34
91
|
}
|
|
35
92
|
|
|
93
|
+
/** Processes listed before the count of the rest. */
|
|
94
|
+
const ROWS = 3
|
|
95
|
+
|
|
36
96
|
const percent = (v: number) => `${Math.round(v * 100)}%`
|
|
37
|
-
const
|
|
97
|
+
const share = (v: number) => (v < 0.1 ? `${(v * 100).toFixed(1)}%` : percent(v))
|
|
98
|
+
|
|
99
|
+
/** Bytes as `11.4 GB`, `640 MB` or `212 GB`. */
|
|
100
|
+
function bytes(n: number) {
|
|
101
|
+
if (n >= 100e9) return `${Math.round(n / 1e9)} GB`
|
|
102
|
+
if (n >= 1e9) return `${(n / 1e9).toFixed(1)} GB`
|
|
103
|
+
return `${Math.round(n / 1e6)} MB`
|
|
104
|
+
}
|
|
38
105
|
|
|
39
106
|
/** Bytes per second as `2.4 MB/s`, `512 KB/s` or `80 B/s`. */
|
|
40
107
|
function rate(bps: number) {
|
|
@@ -43,43 +110,102 @@ function rate(bps: number) {
|
|
|
43
110
|
return `${Math.round(bps)} B/s`
|
|
44
111
|
}
|
|
45
112
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
113
|
+
/** Seconds as `3 d 4 h`, `5 h 12 min` or `12 min`. */
|
|
114
|
+
function span(seconds: number) {
|
|
115
|
+
const minutes = Math.floor(seconds / 60)
|
|
116
|
+
const hours = Math.floor(minutes / 60)
|
|
117
|
+
const days = Math.floor(hours / 24)
|
|
118
|
+
if (days) return `${days} d ${hours % 24} h`
|
|
119
|
+
if (hours) return `${hours} h ${minutes % 60} min`
|
|
120
|
+
return `${minutes} min`
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Minutes as `3:40`. */
|
|
124
|
+
const clock = (minutes: number) => `${Math.floor(minutes / 60)}:${String(Math.round(minutes % 60)).padStart(2, '0')}`
|
|
125
|
+
|
|
126
|
+
/** The status a load reads as: calm, then the warning hue, then the error hue. */
|
|
127
|
+
function toneOf(load: number): SparklineTone {
|
|
128
|
+
if (load >= 0.9) return 'error'
|
|
129
|
+
if (load >= 0.75) return 'warning'
|
|
130
|
+
return 'current'
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function verdict(load: number) {
|
|
134
|
+
if (load >= 0.9) return 'Under strain'
|
|
135
|
+
if (load >= 0.6) return 'Busy'
|
|
136
|
+
if (load >= 0.2) return 'Steady'
|
|
137
|
+
return 'Idle'
|
|
51
138
|
}
|
|
52
139
|
|
|
53
|
-
|
|
140
|
+
const pressureOf = (sample: StatsSample) => sample.memoryPressure ?? sample.memoryUsed / sample.memoryTotal
|
|
141
|
+
|
|
142
|
+
function batteryIcon({ level, charging }: StatsBattery) {
|
|
143
|
+
if (charging) return BatteryCharging
|
|
144
|
+
if (level <= 20) return BatteryLow
|
|
145
|
+
if (level <= 70) return BatteryMedium
|
|
146
|
+
return BatteryFull
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function BatteryItem({ battery }: { battery: StatsBattery }) {
|
|
150
|
+
const left = battery.minutesLeft === undefined ? undefined : clock(battery.minutesLeft)
|
|
54
151
|
return (
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
152
|
+
<Widget.MetaItem icon={batteryIcon(battery)}>
|
|
153
|
+
{battery.level}%{left && ` · ${left} ${battery.charging ? 'to full' : 'left'}`}
|
|
154
|
+
</Widget.MetaItem>
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
interface FactsProps {
|
|
159
|
+
last?: StatsSample
|
|
160
|
+
hero: StatsHero
|
|
161
|
+
battery?: StatsBattery
|
|
162
|
+
disk?: StatsDisk
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Everything but the hero, as two rows of glyph and words. */
|
|
166
|
+
function Facts({ last, hero, battery, disk }: FactsProps) {
|
|
167
|
+
const dash = '–'
|
|
168
|
+
return (
|
|
169
|
+
<div className="flex min-w-0 flex-col gap-1">
|
|
170
|
+
<Widget.Meta>
|
|
171
|
+
{hero === 'cpu' ? (
|
|
172
|
+
<Widget.MetaItem icon={MemoryStick}>
|
|
173
|
+
{last ? `${bytes(last.memoryUsed)} of ${bytes(last.memoryTotal)}` : dash}
|
|
174
|
+
</Widget.MetaItem>
|
|
175
|
+
) : (
|
|
176
|
+
<Widget.MetaItem icon={Cpu}>{last ? `${percent(last.cpu)} CPU` : dash}</Widget.MetaItem>
|
|
177
|
+
)}
|
|
178
|
+
<Widget.MetaItem icon={ArrowDown}>{last ? rate(last.netIn) : dash}</Widget.MetaItem>
|
|
179
|
+
<Widget.MetaItem icon={ArrowUp}>{last ? rate(last.netOut) : dash}</Widget.MetaItem>
|
|
180
|
+
</Widget.Meta>
|
|
181
|
+
{(battery || disk) && (
|
|
182
|
+
<Widget.Meta>
|
|
183
|
+
{battery && <BatteryItem battery={battery} />}
|
|
184
|
+
{disk && <Widget.MetaItem icon={HardDrive}>{bytes(disk.free)} free</Widget.MetaItem>}
|
|
185
|
+
</Widget.Meta>
|
|
186
|
+
)}
|
|
64
187
|
</div>
|
|
65
188
|
)
|
|
66
189
|
}
|
|
67
190
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
{ icon: Cpu, label: 'CPU' },
|
|
72
|
-
{ icon: MemoryStick, label: 'Memory' },
|
|
73
|
-
{ icon: Network, label: 'Network' },
|
|
74
|
-
]
|
|
191
|
+
function Processes({ processes }: { processes: StatsProcess[] }) {
|
|
192
|
+
const top = [...processes].sort((a, b) => b.cpu - a.cpu)
|
|
193
|
+
const more = top.length - ROWS
|
|
75
194
|
return (
|
|
76
|
-
<
|
|
77
|
-
{
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
195
|
+
<Widget.Section label="Top processes" trailing={<span>CPU · memory</span>}>
|
|
196
|
+
{top.slice(0, ROWS).map(process => (
|
|
197
|
+
<Widget.Row
|
|
198
|
+
key={process.id}
|
|
199
|
+
leading={share(process.cpu)}
|
|
200
|
+
trailing={process.memory !== undefined && bytes(process.memory)}
|
|
201
|
+
>
|
|
202
|
+
{process.name}
|
|
203
|
+
</Widget.Row>
|
|
81
204
|
))}
|
|
82
|
-
|
|
205
|
+
{more > 0 && (
|
|
206
|
+
<span className="flex h-6 items-center pl-17.5 text-caption text-muted-foreground">{more} more</span>
|
|
207
|
+
)}
|
|
208
|
+
</Widget.Section>
|
|
83
209
|
)
|
|
84
210
|
}
|
|
85
211
|
|
|
@@ -94,85 +220,93 @@ function SystemStatsTrailing({ sample }: { sample?: StatsSample }) {
|
|
|
94
220
|
return <span className="text-caption weight-semibold tabular-nums text-foreground">{percent(sample.cpu)}</span>
|
|
95
221
|
}
|
|
96
222
|
|
|
223
|
+
/** The split island's bubble: the CPU load as a ring, in the warning hue from 75% and the error hue from 90%. */
|
|
224
|
+
function SystemStatsMinimal({ sample }: { sample?: StatsSample }) {
|
|
225
|
+
const load = sample?.cpu ?? 0
|
|
226
|
+
return (
|
|
227
|
+
<Meter
|
|
228
|
+
variant="ring"
|
|
229
|
+
className="size-5.5"
|
|
230
|
+
size="compact"
|
|
231
|
+
value={load}
|
|
232
|
+
label={sample ? `CPU, ${percent(load)}` : 'CPU, measuring'}
|
|
233
|
+
/>
|
|
234
|
+
)
|
|
235
|
+
}
|
|
236
|
+
|
|
97
237
|
/**
|
|
98
|
-
* A notch app's system load:
|
|
99
|
-
*
|
|
238
|
+
* A notch app's system load: the busiest figure as the hero with its trend,
|
|
239
|
+
* the rest as facts, and the processes behind it.
|
|
100
240
|
*
|
|
101
|
-
* The
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
241
|
+
* The hero is the CPU load, set large, with every reading so far as a
|
|
242
|
+
* modo-ui Sparkline beside it (it spans the width however many readings
|
|
243
|
+
* there are: the island stays open for seconds, too short to fill a fixed
|
|
244
|
+
* window). The line turns to the warning hue from 75% and the error hue
|
|
245
|
+
* from 90%, so the color comes from the load. When memory is what's tight,
|
|
246
|
+
* `hero="memory"` makes memory pressure the figure and its trend instead.
|
|
247
|
+
* Under it one word for how the machine is doing and who's busiest, then
|
|
248
|
+
* the facts: memory in use of all of it (or the CPU), the network's in and
|
|
249
|
+
* out rates, and, when given, the battery with its time left and the
|
|
250
|
+
* startup disk's free space. The uptime sits on the context line.
|
|
251
|
+
*
|
|
252
|
+
* Beside it, past a hairline, the busiest processes by CPU with the memory
|
|
253
|
+
* they hold, three at most and a count of the rest.
|
|
254
|
+
*
|
|
255
|
+
* CPU and network are rates between two readings, so before the first one
|
|
256
|
+
* lands (about a second after opening) the figures are dashes over the
|
|
257
|
+
* Sparkline's baseline.
|
|
107
258
|
*
|
|
108
259
|
* `SystemStats.Leading` and `SystemStats.Trailing` show the CPU load in the
|
|
109
|
-
* compact island's wings.
|
|
260
|
+
* compact island's wings, `SystemStats.Minimal` as a ring in the split
|
|
261
|
+
* island's bubble.
|
|
110
262
|
*
|
|
111
263
|
* @example {@include ./examples.mdx}
|
|
112
264
|
*/
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const netOut = samples.map(s => s.netOut)
|
|
121
|
-
return (
|
|
122
|
-
<div className={cn('grid size-full grid-cols-3 content-center gap-3', className)}>
|
|
123
|
-
<Tile icon={Cpu} label="CPU" value={percent(last.cpu)}>
|
|
124
|
-
<Sparkline values={cpu} max={1} label={`CPU, ${percent(last.cpu)}`} className="h-10" />
|
|
125
|
-
</Tile>
|
|
126
|
-
<Tile
|
|
127
|
-
icon={MemoryStick}
|
|
128
|
-
label="Memory"
|
|
129
|
-
value={
|
|
130
|
-
<>
|
|
131
|
-
{gigabytes(last.memoryUsed)}
|
|
132
|
-
<span className="truncate text-caption weight-normal text-muted-foreground">
|
|
133
|
-
of {gigabytes(last.memoryTotal)}
|
|
134
|
-
</span>
|
|
135
|
-
</>
|
|
136
|
-
}
|
|
137
|
-
>
|
|
138
|
-
<Sparkline
|
|
139
|
-
values={memory}
|
|
140
|
-
max={last.memoryTotal}
|
|
141
|
-
label={`Memory, ${gigabytes(last.memoryUsed)}`}
|
|
142
|
-
className="h-10"
|
|
143
|
-
/>
|
|
144
|
-
</Tile>
|
|
145
|
-
<Tile
|
|
146
|
-
icon={Network}
|
|
147
|
-
label="Network"
|
|
148
|
-
value={
|
|
149
|
-
<>
|
|
150
|
-
<span className="flex items-center gap-0.5">
|
|
151
|
-
<ArrowDown size={12} strokeWidth={2} aria-label="In" />
|
|
152
|
-
{rate(last.netIn)}
|
|
153
|
-
</span>
|
|
154
|
-
<span className="flex min-w-0 items-center gap-0.5 truncate text-caption weight-normal text-muted-foreground">
|
|
155
|
-
<ArrowUp size={12} strokeWidth={2} aria-label="Out" />
|
|
156
|
-
{rate(last.netOut)}
|
|
157
|
-
</span>
|
|
158
|
-
</>
|
|
159
|
-
}
|
|
160
|
-
>
|
|
161
|
-
<Sparkline
|
|
162
|
-
values={netIn}
|
|
163
|
-
secondary={netOut}
|
|
164
|
-
label={`Network, ${rate(last.netIn)} in, ${rate(last.netOut)} out`}
|
|
165
|
-
className="h-10"
|
|
166
|
-
/>
|
|
167
|
-
</Tile>
|
|
168
|
-
</div>
|
|
169
|
-
)
|
|
170
|
-
}
|
|
265
|
+
const SystemStats = Object.assign(
|
|
266
|
+
function SystemStats({ samples, hero = 'cpu', battery, disk, uptime, processes, size, className }: SystemStatsProps) {
|
|
267
|
+
const last = samples.at(-1)
|
|
268
|
+
const series = hero === 'cpu' ? samples.map(s => s.cpu) : samples.map(pressureOf)
|
|
269
|
+
const load = last ? (hero === 'cpu' ? last.cpu : pressureOf(last)) : 0
|
|
270
|
+
const name = hero === 'cpu' ? 'CPU' : 'Memory pressure'
|
|
271
|
+
const busiest = processes?.length ? processes.reduce((a, b) => (b.cpu > a.cpu ? b : a)).name : undefined
|
|
171
272
|
|
|
172
|
-
|
|
173
|
-
|
|
273
|
+
return (
|
|
274
|
+
<Widget
|
|
275
|
+
size={size}
|
|
276
|
+
className={cn('h-full', className)}
|
|
277
|
+
aside={processes?.length ? <Processes processes={processes} /> : undefined}
|
|
278
|
+
>
|
|
279
|
+
<Widget.Header icon={Activity}>{uptime === undefined ? 'System' : `System · up ${span(uptime)}`}</Widget.Header>
|
|
280
|
+
<div className="flex min-w-0 items-end gap-4" aria-busy={!last}>
|
|
281
|
+
<Widget.Figure
|
|
282
|
+
value={last ? percent(load) : '–'}
|
|
283
|
+
unit={hero === 'cpu' ? 'CPU' : 'pressure'}
|
|
284
|
+
className="shrink-0"
|
|
285
|
+
/>
|
|
286
|
+
<Sparkline
|
|
287
|
+
values={series}
|
|
288
|
+
max={1}
|
|
289
|
+
area
|
|
290
|
+
tone={toneOf(load)}
|
|
291
|
+
label={last ? `${name}, ${percent(load)}` : `${name}, measuring`}
|
|
292
|
+
className={cn('mb-1.5 h-9 min-w-0 flex-1', !last && 'text-muted-foreground')}
|
|
293
|
+
/>
|
|
294
|
+
</div>
|
|
295
|
+
<Widget.Subtitle className="mb-1">
|
|
296
|
+
{last ? [verdict(load), busiest && `${busiest} is busiest`].filter(Boolean).join(' · ') : 'Measuring…'}
|
|
297
|
+
</Widget.Subtitle>
|
|
298
|
+
<Facts last={last} hero={hero} battery={battery} disk={disk} />
|
|
299
|
+
</Widget>
|
|
300
|
+
)
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
Leading: SystemStatsLeading,
|
|
304
|
+
Trailing: SystemStatsTrailing,
|
|
305
|
+
Minimal: SystemStatsMinimal,
|
|
306
|
+
},
|
|
307
|
+
)
|
|
174
308
|
|
|
175
309
|
export default SystemStats
|
|
176
310
|
|
|
177
|
-
export type { StatsSample, SystemStatsProps }
|
|
178
|
-
export { SystemStats, SystemStatsLeading, SystemStatsTrailing }
|
|
311
|
+
export type { StatsBattery, StatsDisk, StatsHero, StatsProcess, StatsSample, SystemStatsProps }
|
|
312
|
+
export { SystemStats, SystemStatsLeading, SystemStatsMinimal, SystemStatsTrailing }
|
|
@@ -19,3 +19,11 @@ Elapsed, the scrubber and the time remaining, running on a second at a time. Dra
|
|
|
19
19
|
<div className="w-full max-w-md">
|
|
20
20
|
<MediaScrubber position={12} duration={330} size="default" />
|
|
21
21
|
</div>
|
|
22
|
+
|
|
23
|
+
# Quiet
|
|
24
|
+
|
|
25
|
+
`quiet` shows a thin line of progress at rest; hover or focus it and the scrubber fades in to seek. Touch always gets the scrubber.
|
|
26
|
+
|
|
27
|
+
<div className="dark w-full max-w-md rounded-box bg-ink px-5 py-4 text-foreground">
|
|
28
|
+
<MediaScrubber position={71} duration={243} playing quiet />
|
|
29
|
+
</div>
|
|
@@ -27,6 +27,8 @@ interface MediaScrubberProps {
|
|
|
27
27
|
label?: string
|
|
28
28
|
/** No seeking. Defaults to `false`. */
|
|
29
29
|
disabled?: boolean
|
|
30
|
+
/** At rest a thin line of progress; the scrubber fades in on hover and focus, and always shows on touch. Defaults to `false`. */
|
|
31
|
+
quiet?: boolean
|
|
30
32
|
/** Classes for the row. */
|
|
31
33
|
className?: string
|
|
32
34
|
}
|
|
@@ -41,6 +43,10 @@ interface MediaScrubberProps {
|
|
|
41
43
|
* press ends, and playback runs on from the seek until the player reports
|
|
42
44
|
* its next `position`, so the thumb never jumps back to the stale one.
|
|
43
45
|
*
|
|
46
|
+
* `quiet` is the player's form: at rest a thin line of progress, so the
|
|
47
|
+
* track reads before the control; the scrubber fades in on hover or focus,
|
|
48
|
+
* and always shows on touch.
|
|
49
|
+
*
|
|
44
50
|
* @example {@include ./examples.mdx}
|
|
45
51
|
*/
|
|
46
52
|
export default function MediaScrubber({
|
|
@@ -51,6 +57,7 @@ export default function MediaScrubber({
|
|
|
51
57
|
size = 'compact',
|
|
52
58
|
label = 'Position',
|
|
53
59
|
disabled = false,
|
|
60
|
+
quiet = false,
|
|
54
61
|
className,
|
|
55
62
|
}: MediaScrubberProps) {
|
|
56
63
|
// Where it runs on from: the last position the player reported, or the last seek.
|
|
@@ -74,19 +81,36 @@ export default function MediaScrubber({
|
|
|
74
81
|
// biome-ignore lint/a11y/noStaticElementInteractions: commits the Slider's drag or key press when it ends
|
|
75
82
|
<div className={cn('flex items-center gap-3', className)} onPointerUp={commit} onKeyUp={commit}>
|
|
76
83
|
<span className="w-9 shrink-0 text-micro tabular-nums text-muted-foreground">{formatClock(value)}</span>
|
|
77
|
-
<
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
<span className="group/scrub relative flex min-w-0 flex-1 items-center">
|
|
85
|
+
<Slider
|
|
86
|
+
className={cn(
|
|
87
|
+
'mb-0 min-w-0 flex-1',
|
|
88
|
+
quiet &&
|
|
89
|
+
'opacity-0 transition-[opacity] duration-fast group-hover/scrub:opacity-100 group-focus-within/scrub:opacity-100 pointer-coarse:opacity-100',
|
|
90
|
+
)}
|
|
91
|
+
size={size}
|
|
92
|
+
label={label}
|
|
93
|
+
showValue={false}
|
|
94
|
+
formatValue={formatClock}
|
|
95
|
+
min={0}
|
|
96
|
+
max={Math.max(1, duration)}
|
|
97
|
+
step={1}
|
|
98
|
+
value={value}
|
|
99
|
+
disabled={disabled}
|
|
100
|
+
onValueChange={v => setDragged(v as number)}
|
|
101
|
+
/>
|
|
102
|
+
{quiet && (
|
|
103
|
+
<span
|
|
104
|
+
aria-hidden
|
|
105
|
+
className="pointer-events-none absolute inset-x-0 h-1 overflow-hidden rounded-full bg-active transition-[opacity] duration-fast group-hover/scrub:opacity-0 group-focus-within/scrub:opacity-0 pointer-coarse:opacity-0"
|
|
106
|
+
>
|
|
107
|
+
<span
|
|
108
|
+
className="block size-full rounded-full bg-foreground"
|
|
109
|
+
style={{ transform: `translateX(${(value / Math.max(1, duration) - 1) * 100}%)` }}
|
|
110
|
+
/>
|
|
111
|
+
</span>
|
|
112
|
+
)}
|
|
113
|
+
</span>
|
|
90
114
|
<span className="w-9 shrink-0 text-right text-micro tabular-nums text-muted-foreground">
|
|
91
115
|
-{formatClock(Math.max(0, duration - value))}
|
|
92
116
|
</span>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Island from './index'
|
|
2
|
-
import { ArtworkTile,
|
|
2
|
+
import { ArtworkTile, DemoIsland, DownloadedFlash, ExpandedPanel, IslandPlayground, PomodoroBubble, ScreenEdge } from '../../../mock/island-content'
|
|
3
3
|
import Equalizer from '../../indicators/equalizer'
|
|
4
4
|
|
|
5
5
|
# States
|
|
@@ -29,7 +29,7 @@ An activity in the wings: its glyph on the left, its live value on the right.
|
|
|
29
29
|
A second activity in a bubble off the right end; it melts off and back through the goo.
|
|
30
30
|
|
|
31
31
|
<ScreenEdge height={64}>
|
|
32
|
-
<Island defaultState="split" leading={<ArtworkTile />} trailing={<Equalizer />} minimal={<
|
|
32
|
+
<Island defaultState="split" leading={<ArtworkTile />} trailing={<Equalizer />} minimal={<PomodoroBubble />} />
|
|
33
33
|
</ScreenEdge>
|
|
34
34
|
|
|
35
35
|
# Flash
|
|
@@ -37,14 +37,14 @@ A second activity in a bubble off the right end; it melts off and back through t
|
|
|
37
37
|
A moment's alert below the notch.
|
|
38
38
|
|
|
39
39
|
<ScreenEdge height={112}>
|
|
40
|
-
<Island defaultState="flash" flash={<
|
|
40
|
+
<Island defaultState="flash" flash={<DownloadedFlash />} />
|
|
41
41
|
</ScreenEdge>
|
|
42
42
|
|
|
43
43
|
# Expanded
|
|
44
44
|
|
|
45
45
|
The open panel: tabs in the wings around the notch, the tab's title and its widget.
|
|
46
46
|
|
|
47
|
-
<ScreenEdge height={
|
|
47
|
+
<ScreenEdge height={260}>
|
|
48
48
|
<Island defaultState="expanded" collapsedState="compact" leading={<ArtworkTile />} trailing={<Equalizer />} expanded={<ExpandedPanel />} />
|
|
49
49
|
</ScreenEdge>
|
|
50
50
|
|
|
@@ -63,7 +63,7 @@ interface IslandProps {
|
|
|
63
63
|
notchHeight?: number
|
|
64
64
|
/** The open island's width in px; it shrinks to the room it has. Defaults to `720`. */
|
|
65
65
|
panelWidth?: number
|
|
66
|
-
/** The open island's height in px. Defaults to `
|
|
66
|
+
/** The open island's height in px. Defaults to `240`. */
|
|
67
67
|
panelHeight?: number
|
|
68
68
|
/** The compact left wing: the activity's glyph (`compact` and `split`). */
|
|
69
69
|
leading?: ReactNode
|
|
@@ -157,7 +157,7 @@ export default function Island({
|
|
|
157
157
|
notchWidth = 185,
|
|
158
158
|
notchHeight = 32,
|
|
159
159
|
panelWidth = 720,
|
|
160
|
-
panelHeight =
|
|
160
|
+
panelHeight = 240,
|
|
161
161
|
leading,
|
|
162
162
|
trailing,
|
|
163
163
|
minimal,
|
|
@@ -1,34 +1,31 @@
|
|
|
1
1
|
import IslandFlash from './index'
|
|
2
|
-
import BatteryGlyph from '../../indicators/battery-glyph'
|
|
3
2
|
import Equalizer from '../../indicators/equalizer'
|
|
4
3
|
import Button from '@justanarthur/modo-ui/components/actions/button'
|
|
5
|
-
import {
|
|
4
|
+
import { ClipboardCheck, CloudRain, Music, Target } from 'lucide-react'
|
|
6
5
|
|
|
7
|
-
#
|
|
6
|
+
# Focus done
|
|
8
7
|
|
|
9
8
|
The icon and the figure take the tone's hue.
|
|
10
9
|
|
|
11
10
|
<div className="dark w-full max-w-md rounded-box bg-ink px-5 py-4 text-foreground">
|
|
12
11
|
<IslandFlash
|
|
13
|
-
icon={<
|
|
12
|
+
icon={<Target size={18} strokeWidth={1.5} />}
|
|
14
13
|
tone="success"
|
|
15
|
-
title="
|
|
16
|
-
caption="
|
|
17
|
-
value="
|
|
18
|
-
trailing={<BatteryGlyph level={82} charging />}
|
|
14
|
+
title="Focus done"
|
|
15
|
+
caption="Round 2 of 4 · a short break next"
|
|
16
|
+
value="5 min"
|
|
19
17
|
/>
|
|
20
18
|
</div>
|
|
21
19
|
|
|
22
|
-
#
|
|
20
|
+
# Rain soon
|
|
23
21
|
|
|
24
22
|
<div className="dark w-full max-w-md rounded-box bg-ink px-5 py-4 text-foreground">
|
|
25
23
|
<IslandFlash
|
|
26
|
-
icon={<
|
|
24
|
+
icon={<CloudRain size={18} strokeWidth={1.5} />}
|
|
27
25
|
tone="warning"
|
|
28
|
-
title="
|
|
29
|
-
caption="
|
|
30
|
-
value="
|
|
31
|
-
trailing={<BatteryGlyph level={18} />}
|
|
26
|
+
title="Rain soon"
|
|
27
|
+
caption="Light rain for about an hour"
|
|
28
|
+
value="15 min"
|
|
32
29
|
/>
|
|
33
30
|
</div>
|
|
34
31
|
|
|
@@ -36,10 +33,10 @@ The icon and the figure take the tone's hue.
|
|
|
36
33
|
|
|
37
34
|
<div className="dark w-full max-w-md rounded-box bg-ink px-5 py-4 text-foreground">
|
|
38
35
|
<IslandFlash
|
|
39
|
-
icon={<
|
|
40
|
-
title="
|
|
41
|
-
caption="
|
|
42
|
-
action={<Button variant="ghost" size="compact">
|
|
36
|
+
icon={<ClipboardCheck size={18} strokeWidth={1.5} />}
|
|
37
|
+
title="Copied"
|
|
38
|
+
caption="bun run build && bun run check"
|
|
39
|
+
action={<Button variant="ghost" size="compact">Pin</Button>}
|
|
43
40
|
/>
|
|
44
41
|
</div>
|
|
45
42
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Local addition: the layout of a notch app's transient alert, the island's
|
|
3
3
|
* `flash` content. Generalised from Just Notch's power, HUD and now-playing
|
|
4
|
-
* flashes.
|
|
4
|
+
* flashes; the kit's blocks build their own on it.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { cn } from '@justanarthur/modo-ui/lib/utils'
|
|
@@ -27,9 +27,9 @@ interface IslandFlashProps {
|
|
|
27
27
|
icon?: ReactNode
|
|
28
28
|
/** The hue of the icon and the `value`. Defaults to `'default'`. */
|
|
29
29
|
tone?: IslandFlashTone
|
|
30
|
-
/** A figure at the end, in the tone's hue: `
|
|
30
|
+
/** A figure at the end, in the tone's hue: `15 min`, a level. */
|
|
31
31
|
value?: ReactNode
|
|
32
|
-
/** Content after it, such as
|
|
32
|
+
/** Content after it, such as an Equalizer. */
|
|
33
33
|
trailing?: ReactNode
|
|
34
34
|
/** One control at the far end, such as a ghost Button. */
|
|
35
35
|
action?: ReactNode
|
|
@@ -44,7 +44,7 @@ interface IslandFlashProps {
|
|
|
44
44
|
* It lays out one row the height of the island's flash: the icon in a fixed
|
|
45
45
|
* square, the title and caption truncating beside it, then the `value`, any
|
|
46
46
|
* `trailing` glyph and an `action`. The icon and the value take the tone's
|
|
47
|
-
* status hue (a
|
|
47
|
+
* status hue (a focus round done in success, rain coming in warning); everything else
|
|
48
48
|
* keeps the two text colors. Pass it as the Island's `flash`.
|
|
49
49
|
*
|
|
50
50
|
* @example {@include ./examples.mdx}
|