@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.
Files changed (148) hide show
  1. package/README.md +11 -11
  2. package/blocks/activities/agenda/examples.mdx +21 -5
  3. package/blocks/activities/agenda/index.tsx +291 -182
  4. package/blocks/activities/clock/examples.mdx +73 -0
  5. package/blocks/activities/clock/index.tsx +619 -0
  6. package/blocks/activities/now-playing/examples.mdx +32 -13
  7. package/blocks/activities/now-playing/index.tsx +319 -126
  8. package/blocks/activities/weather/examples.mdx +115 -0
  9. package/blocks/activities/weather/index.tsx +634 -0
  10. package/blocks/app/expanded-island/examples.mdx +8 -7
  11. package/blocks/app/expanded-island/index.tsx +19 -3
  12. package/blocks/app/settings-window/examples.mdx +6 -2
  13. package/blocks/app/settings-window/index.tsx +25 -7
  14. package/blocks/system/clipboard/examples.mdx +83 -0
  15. package/blocks/system/clipboard/index.tsx +563 -0
  16. package/blocks/system/recent-files/examples.mdx +66 -0
  17. package/blocks/system/recent-files/index.tsx +542 -0
  18. package/blocks/system/system-stats/examples.mdx +38 -9
  19. package/blocks/system/system-stats/index.tsx +241 -107
  20. package/components/indicators/media-scrubber/examples.mdx +8 -0
  21. package/components/indicators/media-scrubber/index.tsx +37 -13
  22. package/components/island/island/examples.mdx +4 -4
  23. package/components/island/island/index.tsx +2 -2
  24. package/components/island/island-flash/examples.mdx +15 -18
  25. package/components/island/island-flash/index.tsx +4 -4
  26. package/components/island/island-tabs/examples.mdx +5 -5
  27. package/components/island/widget/examples.mdx +76 -0
  28. package/components/island/widget/index.tsx +431 -0
  29. package/dist/blocks/activities/agenda/index.d.ts +1 -1
  30. package/dist/blocks/activities/agenda/index.js +3 -3
  31. package/dist/blocks/activities/clock/index.d.ts +2 -0
  32. package/dist/blocks/activities/clock/index.js +25 -0
  33. package/dist/blocks/activities/now-playing/index.d.ts +3 -2
  34. package/dist/blocks/activities/now-playing/index.js +5 -3
  35. package/dist/blocks/activities/weather/index.d.ts +2 -0
  36. package/dist/blocks/activities/weather/index.js +21 -0
  37. package/dist/blocks/app/expanded-island/index.d.ts +1 -1
  38. package/dist/blocks/app/expanded-island/index.js +4 -3
  39. package/dist/blocks/app/settings-window/index.d.ts +1 -1
  40. package/dist/blocks/app/settings-window/index.js +1 -1
  41. package/dist/blocks/system/clipboard/index.d.ts +2 -0
  42. package/dist/blocks/system/clipboard/index.js +17 -0
  43. package/dist/blocks/system/recent-files/index.d.ts +2 -0
  44. package/dist/blocks/system/recent-files/index.js +19 -0
  45. package/dist/blocks/system/system-stats/index.d.ts +2 -2
  46. package/dist/blocks/system/system-stats/index.js +4 -1
  47. package/dist/components/indicators/media-scrubber/index.d.ts +1 -1
  48. package/dist/components/indicators/media-scrubber/index.js +1 -1
  49. package/dist/components/island/island/index.d.ts +1 -1
  50. package/dist/components/island/island/index.js +2 -2
  51. package/dist/components/island/island-flash/index.d.ts +1 -1
  52. package/dist/components/island/island-flash/index.js +1 -1
  53. package/dist/components/island/island-tabs/index.js +2 -2
  54. package/dist/components/island/widget/index.d.ts +2 -0
  55. package/dist/components/island/widget/index.js +30 -0
  56. package/dist/index.d.ts +15 -15
  57. package/dist/index.js +102 -58
  58. package/dist/lib/artwork.d.ts +2 -0
  59. package/dist/lib/artwork.js +8 -0
  60. package/dist/lib/geometry.js +1 -1
  61. package/dist/shared/chunk-2818esrq.d.ts +140 -0
  62. package/dist/shared/{chunk-yngkkxz2.d.ts → chunk-2m5dz8nf.d.ts} +4 -4
  63. package/dist/shared/chunk-3thgcfcq.d.ts +151 -0
  64. package/dist/shared/chunk-416tsgbc.d.ts +175 -0
  65. package/dist/shared/{chunk-zvh0d3qb.js → chunk-61t2dfte.js} +1 -1
  66. package/dist/shared/chunk-7fvnrtz4.d.ts +105 -0
  67. package/dist/shared/{chunk-hpsabfsd.d.ts → chunk-81fpptwp.d.ts} +1 -1
  68. package/dist/shared/chunk-9c7ewvkk.js +381 -0
  69. package/dist/shared/{chunk-mp1nx0ez.js → chunk-9m0xbg5v.js} +14 -3
  70. package/dist/shared/{chunk-wwjxs75m.js → chunk-9xtcv3sy.js} +26 -12
  71. package/dist/shared/chunk-bvtyjcce.d.ts +123 -0
  72. package/dist/shared/{chunk-s33y1pcq.js → chunk-cc9nwbtf.js} +20 -10
  73. package/dist/shared/chunk-da177e8r.d.ts +114 -0
  74. package/dist/shared/{chunk-6c1jbefs.d.ts → chunk-fexwzycv.d.ts} +3 -3
  75. package/dist/shared/chunk-gejenfap.d.ts +25 -0
  76. package/dist/shared/{chunk-rr5e0g15.d.ts → chunk-j755a1a5.d.ts} +7 -1
  77. package/dist/shared/chunk-j77cx8dp.js +498 -0
  78. package/dist/shared/chunk-mt0k6v8x.js +474 -0
  79. package/dist/shared/{chunk-78w7qwp0.js → chunk-ndf79pv5.js} +1 -1
  80. package/dist/shared/{chunk-9nhpg9t8.d.ts → chunk-pfhy5e4q.d.ts} +7 -1
  81. package/dist/shared/chunk-qdzemt2v.js +477 -0
  82. package/dist/shared/{chunk-rpfwv3pz.js → chunk-r471sknr.js} +1 -1
  83. package/dist/shared/chunk-s2jeqqan.js +243 -0
  84. package/dist/shared/chunk-t0hcxh89.d.ts +124 -0
  85. package/dist/shared/chunk-w5h6ay93.js +72 -0
  86. package/dist/shared/chunk-wkg17nxs.d.ts +101 -0
  87. package/dist/shared/chunk-x7f3g82r.js +285 -0
  88. package/dist/shared/chunk-xq5hc5gv.js +333 -0
  89. package/dist/shared/{chunk-sbnrhy5m.js → chunk-y0188bbn.js} +2 -2
  90. package/dist/shared/chunk-ym0xbses.js +518 -0
  91. package/dist/styles.css +97 -55
  92. package/index.ts +7 -6
  93. package/lib/artwork.ts +112 -0
  94. package/lib/geometry.ts +1 -1
  95. package/mock/activities.tsx +9 -32
  96. package/mock/artwork.tsx +13 -1
  97. package/mock/clipboard.tsx +79 -0
  98. package/mock/clock.tsx +77 -0
  99. package/mock/data.ts +30 -44
  100. package/mock/files.tsx +70 -0
  101. package/mock/island-content.tsx +43 -118
  102. package/mock/screen.tsx +76 -0
  103. package/mock/settings.tsx +370 -91
  104. package/mock/system.ts +46 -0
  105. package/mock/weather.tsx +105 -0
  106. package/package.json +7 -2
  107. package/blocks/activities/shelf/examples.mdx +0 -33
  108. package/blocks/activities/shelf/index.tsx +0 -289
  109. package/blocks/activities/timer/examples.mdx +0 -52
  110. package/blocks/activities/timer/index.tsx +0 -292
  111. package/blocks/system/controls/examples.mdx +0 -34
  112. package/blocks/system/controls/index.tsx +0 -167
  113. package/blocks/system/devices/examples.mdx +0 -25
  114. package/blocks/system/devices/index.tsx +0 -172
  115. package/blocks/system/power-alert/examples.mdx +0 -32
  116. package/blocks/system/power-alert/index.tsx +0 -89
  117. package/components/indicators/battery-glyph/examples.mdx +0 -22
  118. package/components/indicators/battery-glyph/index.tsx +0 -91
  119. package/dist/blocks/activities/shelf/index.d.ts +0 -2
  120. package/dist/blocks/activities/shelf/index.js +0 -14
  121. package/dist/blocks/activities/timer/index.d.ts +0 -2
  122. package/dist/blocks/activities/timer/index.js +0 -19
  123. package/dist/blocks/system/controls/index.d.ts +0 -2
  124. package/dist/blocks/system/controls/index.js +0 -10
  125. package/dist/blocks/system/devices/index.d.ts +0 -2
  126. package/dist/blocks/system/devices/index.js +0 -12
  127. package/dist/blocks/system/power-alert/index.d.ts +0 -2
  128. package/dist/blocks/system/power-alert/index.js +0 -9
  129. package/dist/components/indicators/battery-glyph/index.d.ts +0 -2
  130. package/dist/components/indicators/battery-glyph/index.js +0 -9
  131. package/dist/shared/chunk-2qpcsv5h.d.ts +0 -45
  132. package/dist/shared/chunk-45gytfr1.d.ts +0 -84
  133. package/dist/shared/chunk-50ffk4r7.d.ts +0 -69
  134. package/dist/shared/chunk-5w0yck07.d.ts +0 -32
  135. package/dist/shared/chunk-7hr53mby.js +0 -116
  136. package/dist/shared/chunk-b8jb1w72.js +0 -145
  137. package/dist/shared/chunk-cpewy6yg.js +0 -178
  138. package/dist/shared/chunk-e3e4s4ds.d.ts +0 -77
  139. package/dist/shared/chunk-enm6td0p.js +0 -280
  140. package/dist/shared/chunk-fvedaas2.d.ts +0 -33
  141. package/dist/shared/chunk-gex38j8x.d.ts +0 -82
  142. package/dist/shared/chunk-hwtxpzg0.js +0 -69
  143. package/dist/shared/chunk-phb53x1f.js +0 -252
  144. package/dist/shared/chunk-r8esmjfs.d.ts +0 -42
  145. package/dist/shared/chunk-rcp1g9ca.js +0 -70
  146. package/dist/shared/chunk-rx9sphz2.js +0 -266
  147. package/dist/shared/chunk-xdeek16r.d.ts +0 -58
  148. package/dist/shared/chunk-xkzjk1tq.js +0 -206
@@ -1,16 +1,30 @@
1
1
  /*!
2
- * Local addition: a notch app's system load, CPU, memory and network as
3
- * tiles with their trends. Rebuilt from Just Notch's stats plugin (`System`,
4
- * `Tile`, `Measuring`, `CpuLoad`) on modo-ui's Sparkline: the samples come
5
- * in as props.
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 { ArrowDown, ArrowUp, Cpu, type LucideIcon, MemoryStick, Network } from 'lucide-react'
13
- import type { ReactNode } from 'react'
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 gigabytes = (bytes: number) => `${(bytes / 1e9).toFixed(1)} GB`
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
- interface TileProps {
47
- icon: LucideIcon
48
- label: string
49
- value: ReactNode
50
- children: ReactNode
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
- function Tile({ icon: Icon, label, value, children }: TileProps) {
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
- <div className="flex min-w-0 flex-col gap-2 rounded-xl bg-surface-2 p-3">
56
- <span className="flex items-center gap-1.5 text-caption text-muted-foreground">
57
- <Icon size={14} strokeWidth={1.5} />
58
- {label}
59
- </span>
60
- <div className="flex min-w-0 items-baseline gap-2 text-subtitle weight-semibold tabular-nums text-foreground">
61
- {value}
62
- </div>
63
- <div className="mt-auto">{children}</div>
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
- /** CPU and network are rates between two readings: the first lands about a second after opening. */
69
- function Measuring({ className }: { className?: string }) {
70
- const tiles = [
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
- <div className={cn('grid size-full grid-cols-3 content-center gap-3', className)} aria-busy>
77
- {tiles.map(({ icon, label }) => (
78
- <Tile key={label} icon={icon} label={label} value={<span className="text-muted-foreground">–</span>}>
79
- <Sparkline values={[]} label={`${label}, measuring`} className="h-10" />
80
- </Tile>
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
- </div>
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: CPU, memory and network, each a tile with its
99
- * figure and its trend.
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 latest reading is the figure: the CPU load, the memory in use of all
102
- * of it, and the network's in and out rates. Every reading so far is the
103
- * trend, a modo-ui Sparkline that spans the tile however many readings there
104
- * are, since the island stays open for seconds, too short to fill a fixed
105
- * window; network out runs muted under network in, on one scale. Before the
106
- * first reading the tiles show a dash over the Sparkline's baseline.
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
- function SystemStats({ samples, className }: SystemStatsProps) {
114
- const last = samples.at(-1)
115
- if (!last) return <Measuring className={className} />
116
-
117
- const cpu = samples.map(s => s.cpu)
118
- const memory = samples.map(s => s.memoryUsed)
119
- const netIn = samples.map(s => s.netIn)
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
- SystemStats.Leading = SystemStatsLeading
173
- SystemStats.Trailing = SystemStatsTrailing
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
- <Slider
78
- className="mb-0 min-w-0 flex-1"
79
- size={size}
80
- label={label}
81
- showValue={false}
82
- formatValue={formatClock}
83
- min={0}
84
- max={Math.max(1, duration)}
85
- step={1}
86
- value={value}
87
- disabled={disabled}
88
- onValueChange={v => setDragged(v as number)}
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, ChargingFlash, DemoIsland, ExpandedPanel, IslandPlayground, ScreenEdge, TimerBubble } from '../../../mock/island-content'
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={<TimerBubble />} />
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={<ChargingFlash />} />
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={340}>
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 `320`. */
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 = 320,
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 { BatteryLow, Headphones, Music, Zap } from 'lucide-react'
4
+ import { ClipboardCheck, CloudRain, Music, Target } from 'lucide-react'
6
5
 
7
- # Charging
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={<Zap size={18} strokeWidth={1.5} fill="currentColor" />}
12
+ icon={<Target size={18} strokeWidth={1.5} />}
14
13
  tone="success"
15
- title="Charging"
16
- caption="38 min until full"
17
- value="82%"
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
- # Low battery
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={<BatteryLow size={18} strokeWidth={1.5} />}
24
+ icon={<CloudRain size={18} strokeWidth={1.5} />}
27
25
  tone="warning"
28
- title="Low battery"
29
- caption="Plug in soon"
30
- value="18%"
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={<Headphones size={18} strokeWidth={1.5} />}
40
- title="AirPods Pro"
41
- caption="Connected"
42
- action={<Button variant="ghost" size="compact">Settings</Button>}
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: `82%`, a level. */
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 a BatteryGlyph or an Equalizer. */
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 charge in success, a low battery in warning); everything else
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}