@justanarthur/modo-ui-notch 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +75 -2
  3. package/blocks/activities/agenda/examples.mdx +58 -0
  4. package/blocks/activities/agenda/index.tsx +332 -0
  5. package/blocks/activities/now-playing/examples.mdx +49 -0
  6. package/blocks/activities/now-playing/index.tsx +218 -0
  7. package/blocks/activities/shelf/examples.mdx +33 -0
  8. package/blocks/activities/shelf/index.tsx +289 -0
  9. package/blocks/activities/timer/examples.mdx +52 -0
  10. package/blocks/activities/timer/index.tsx +292 -0
  11. package/blocks/app/expanded-island/examples.mdx +45 -0
  12. package/blocks/app/expanded-island/index.tsx +127 -0
  13. package/blocks/app/settings-window/examples.mdx +30 -0
  14. package/blocks/app/settings-window/index.tsx +357 -0
  15. package/blocks/system/controls/examples.mdx +34 -0
  16. package/blocks/system/controls/index.tsx +167 -0
  17. package/blocks/system/devices/examples.mdx +25 -0
  18. package/blocks/system/devices/index.tsx +172 -0
  19. package/blocks/system/power-alert/examples.mdx +32 -0
  20. package/blocks/system/power-alert/index.tsx +89 -0
  21. package/blocks/system/system-stats/examples.mdx +23 -0
  22. package/blocks/system/system-stats/index.tsx +178 -0
  23. package/components/indicators/battery-glyph/examples.mdx +22 -0
  24. package/components/indicators/battery-glyph/index.tsx +91 -0
  25. package/components/indicators/countdown/examples.mdx +25 -0
  26. package/components/indicators/countdown/index.tsx +83 -0
  27. package/components/indicators/equalizer/examples.mdx +20 -0
  28. package/components/indicators/equalizer/index.tsx +116 -0
  29. package/components/indicators/media-scrubber/examples.mdx +21 -0
  30. package/components/indicators/media-scrubber/index.tsx +98 -0
  31. package/components/island/island/examples.mdx +57 -0
  32. package/components/island/island/index.tsx +415 -0
  33. package/components/island/island-flash/examples.mdx +55 -0
  34. package/components/island/island-flash/index.tsx +79 -0
  35. package/components/island/island-tabs/examples.mdx +53 -0
  36. package/components/island/island-tabs/index.tsx +285 -0
  37. package/dist/blocks/activities/agenda/index.d.ts +2 -0
  38. package/dist/blocks/activities/agenda/index.js +21 -0
  39. package/dist/blocks/activities/now-playing/index.d.ts +2 -0
  40. package/dist/blocks/activities/now-playing/index.js +22 -0
  41. package/dist/blocks/activities/shelf/index.d.ts +2 -0
  42. package/dist/blocks/activities/shelf/index.js +14 -0
  43. package/dist/blocks/activities/timer/index.d.ts +2 -0
  44. package/dist/blocks/activities/timer/index.js +19 -0
  45. package/dist/blocks/app/expanded-island/index.d.ts +3 -0
  46. package/dist/blocks/app/expanded-island/index.js +10 -0
  47. package/dist/blocks/app/settings-window/index.d.ts +2 -0
  48. package/dist/blocks/app/settings-window/index.js +7 -0
  49. package/dist/blocks/system/controls/index.d.ts +2 -0
  50. package/dist/blocks/system/controls/index.js +10 -0
  51. package/dist/blocks/system/devices/index.d.ts +2 -0
  52. package/dist/blocks/system/devices/index.js +12 -0
  53. package/dist/blocks/system/power-alert/index.d.ts +2 -0
  54. package/dist/blocks/system/power-alert/index.js +9 -0
  55. package/dist/blocks/system/system-stats/index.d.ts +2 -0
  56. package/dist/blocks/system/system-stats/index.js +12 -0
  57. package/dist/components/indicators/battery-glyph/index.d.ts +2 -0
  58. package/dist/components/indicators/battery-glyph/index.js +9 -0
  59. package/dist/components/indicators/countdown/index.d.ts +2 -0
  60. package/dist/components/indicators/countdown/index.js +8 -0
  61. package/dist/components/indicators/equalizer/index.d.ts +2 -0
  62. package/dist/components/indicators/equalizer/index.js +7 -0
  63. package/dist/components/indicators/media-scrubber/index.d.ts +2 -0
  64. package/dist/components/indicators/media-scrubber/index.js +8 -0
  65. package/dist/components/island/island/index.d.ts +3 -0
  66. package/dist/components/island/island/index.js +10 -0
  67. package/dist/components/island/island-flash/index.d.ts +2 -0
  68. package/dist/components/island/island-flash/index.js +7 -0
  69. package/dist/components/island/island-tabs/index.d.ts +2 -0
  70. package/dist/components/island/island-tabs/index.js +9 -0
  71. package/dist/index.d.ts +21 -0
  72. package/dist/index.js +151 -0
  73. package/dist/lib/clock.d.ts +2 -0
  74. package/dist/lib/clock.js +14 -0
  75. package/dist/lib/geometry.d.ts +2 -0
  76. package/dist/lib/geometry.js +24 -0
  77. package/dist/lib/island-context.d.ts +3 -0
  78. package/dist/lib/island-context.js +8 -0
  79. package/dist/lib/motion.d.ts +21 -0
  80. package/dist/lib/motion.js +16 -0
  81. package/dist/shared/chunk-152gpyq3.d.ts +13 -0
  82. package/dist/shared/chunk-2f7zxrbk.js +65 -0
  83. package/dist/shared/chunk-2qpcsv5h.d.ts +45 -0
  84. package/dist/shared/chunk-2s4q6mt0.js +27 -0
  85. package/dist/shared/chunk-45gytfr1.d.ts +84 -0
  86. package/dist/shared/chunk-502rmtap.js +54 -0
  87. package/dist/shared/chunk-50ffk4r7.d.ts +69 -0
  88. package/dist/shared/chunk-52gb3g6r.d.ts +12 -0
  89. package/dist/shared/chunk-5en5aaj1.d.ts +33 -0
  90. package/dist/shared/chunk-5w0yck07.d.ts +32 -0
  91. package/dist/shared/chunk-6c1jbefs.d.ts +36 -0
  92. package/dist/shared/chunk-78w7qwp0.js +58 -0
  93. package/dist/shared/chunk-7hr53mby.js +116 -0
  94. package/dist/shared/chunk-9nhpg9t8.d.ts +47 -0
  95. package/dist/shared/chunk-b8jb1w72.js +145 -0
  96. package/dist/shared/chunk-cfzmfnyh.d.ts +63 -0
  97. package/dist/shared/chunk-cpewy6yg.js +178 -0
  98. package/dist/shared/chunk-d5qm9cps.js +10 -0
  99. package/dist/shared/chunk-e3e4s4ds.d.ts +77 -0
  100. package/dist/shared/chunk-enm6td0p.js +280 -0
  101. package/dist/shared/chunk-fvedaas2.d.ts +33 -0
  102. package/dist/shared/chunk-gb56m10p.js +39 -0
  103. package/dist/shared/chunk-gex38j8x.d.ts +82 -0
  104. package/dist/shared/chunk-hpsabfsd.d.ts +75 -0
  105. package/dist/shared/chunk-hrpxbqmx.d.ts +28 -0
  106. package/dist/shared/chunk-hwtxpzg0.js +69 -0
  107. package/dist/shared/chunk-mp1nx0ez.js +101 -0
  108. package/dist/shared/chunk-phb53x1f.js +252 -0
  109. package/dist/shared/chunk-r8esmjfs.d.ts +42 -0
  110. package/dist/shared/chunk-rcp1g9ca.js +70 -0
  111. package/dist/shared/chunk-rpfwv3pz.js +209 -0
  112. package/dist/shared/chunk-rr5e0g15.d.ts +35 -0
  113. package/dist/shared/chunk-rx9sphz2.js +266 -0
  114. package/dist/shared/chunk-s33y1pcq.js +305 -0
  115. package/dist/shared/chunk-sbnrhy5m.js +331 -0
  116. package/dist/shared/chunk-w48eyvfr.d.ts +56 -0
  117. package/dist/shared/chunk-wwjxs75m.js +74 -0
  118. package/dist/shared/chunk-xdeek16r.d.ts +58 -0
  119. package/dist/shared/chunk-xkzjk1tq.js +206 -0
  120. package/dist/shared/chunk-yngkkxz2.d.ts +88 -0
  121. package/dist/shared/chunk-zvh0d3qb.js +63 -0
  122. package/dist/styles.css +222 -0
  123. package/index.ts +21 -0
  124. package/lib/clock.ts +53 -0
  125. package/lib/geometry.ts +130 -0
  126. package/lib/island-context.tsx +24 -0
  127. package/lib/motion.ts +42 -0
  128. package/mock/activities.tsx +100 -0
  129. package/mock/artwork.tsx +25 -0
  130. package/mock/data.ts +153 -0
  131. package/mock/desktop.tsx +83 -0
  132. package/mock/fit.ts +26 -0
  133. package/mock/island-content.tsx +217 -0
  134. package/mock/scene.tsx +52 -0
  135. package/mock/settings.tsx +210 -0
  136. package/package.json +117 -4
@@ -0,0 +1,32 @@
1
+ import { ReactNode } from "react";
2
+ import { JSX as JSX_1kxb } from "react";
3
+ type PowerAlertKind2 = "charging" | "unplugged" | "low" | "critical";
4
+ interface PowerAlertProps2 {
5
+ /** What happened: a charger plugged in or out, or the battery crossing 20% or 10%. */
6
+ kind: PowerAlertKind2;
7
+ /** The charge, in percent (0 to 100). */
8
+ level: number;
9
+ /** Minutes until full while charging, or of battery left on battery: the caption says it. */
10
+ minutes?: number;
11
+ /** Replaces the caption the kind and `minutes` give. */
12
+ caption?: ReactNode;
13
+ /** Classes for the row. */
14
+ className?: string;
15
+ }
16
+ type Element_12xgc = JSX_1kxb["Element"];
17
+ /**
18
+ * A notch app's power alert: a charger plugged in or out, or the battery
19
+ * running low, as the island's flash.
20
+ *
21
+ * Each kind brings its icon, title and status hue: charging in success,
22
+ * unplugged in the text color, low in warning (at 20%), critical in error
23
+ * (at 10%). The level shows as a figure in that hue and as a BatteryGlyph
24
+ * that fills up from empty as the flash opens. With `minutes`, the caption
25
+ * says how long until full or how much is left; low and critical say to plug
26
+ * in. Pass it as the Island's `flash`, keyed by kind, so one alert replacing
27
+ * another swaps instead of updating in place.
28
+ *
29
+ * @example {@include ./examples.mdx}
30
+ */
31
+ declare function PowerAlert2({ kind, level, minutes, caption, className }: PowerAlertProps2): Element_12xgc;
32
+ export { PowerAlertKind2, PowerAlertProps2, PowerAlert2 };
@@ -0,0 +1,36 @@
1
+ import { ReactNode } from "react";
2
+ import { JSX as JSX_1kxb } from "react";
3
+ type IslandFlashTone2 = "default" | "success" | "warning" | "error" | "info";
4
+ interface IslandFlashProps2 {
5
+ /** What happened, in a few words. */
6
+ title: ReactNode;
7
+ /** One line more: how long, what to do. */
8
+ caption?: ReactNode;
9
+ /** The glyph at the start: an icon, an artwork tile. It takes the tone's hue. */
10
+ icon?: ReactNode;
11
+ /** The hue of the icon and the `value`. Defaults to `'default'`. */
12
+ tone?: IslandFlashTone2;
13
+ /** A figure at the end, in the tone's hue: `82%`, a level. */
14
+ value?: ReactNode;
15
+ /** Content after it, such as a BatteryGlyph or an Equalizer. */
16
+ trailing?: ReactNode;
17
+ /** One control at the far end, such as a ghost Button. */
18
+ action?: ReactNode;
19
+ /** Classes for the row. */
20
+ className?: string;
21
+ }
22
+ type Element_12xgc = JSX_1kxb["Element"];
23
+ /**
24
+ * A moment's alert in the island: an icon, what happened, a line more, and
25
+ * the figure or control it's about.
26
+ *
27
+ * It lays out one row the height of the island's flash: the icon in a fixed
28
+ * square, the title and caption truncating beside it, then the `value`, any
29
+ * `trailing` glyph and an `action`. The icon and the value take the tone's
30
+ * status hue (a charge in success, a low battery in warning); everything else
31
+ * keeps the two text colors. Pass it as the Island's `flash`.
32
+ *
33
+ * @example {@include ./examples.mdx}
34
+ */
35
+ declare function IslandFlash2({ title, caption, icon, tone, value, trailing, action, className }: IslandFlashProps2): Element_12xgc;
36
+ export { IslandFlashTone2, IslandFlashProps2, IslandFlash2 };
@@ -0,0 +1,58 @@
1
+ // components/island/island-flash/index.tsx
2
+ import { cn } from "@justanarthur/modo-ui/lib/utils";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ /*!
5
+ * Local addition: the layout of a notch app's transient alert, the island's
6
+ * `flash` content. Generalised from Just Notch's power, HUD and now-playing
7
+ * flashes.
8
+ */
9
+ var TONE = {
10
+ default: "text-foreground",
11
+ success: "text-status-success",
12
+ warning: "text-status-warning",
13
+ error: "text-status-error",
14
+ info: "text-status-info"
15
+ };
16
+ function IslandFlash2({
17
+ title,
18
+ caption,
19
+ icon,
20
+ tone = "default",
21
+ value,
22
+ trailing,
23
+ action,
24
+ className
25
+ }) {
26
+ return /* @__PURE__ */ jsxs("div", {
27
+ className: cn("flex min-w-0 items-center gap-3", className),
28
+ children: [
29
+ icon && /* @__PURE__ */ jsx("span", {
30
+ className: cn("flex size-8 shrink-0 items-center justify-center", TONE[tone]),
31
+ children: icon
32
+ }),
33
+ /* @__PURE__ */ jsxs("div", {
34
+ className: "flex min-w-0 flex-1 flex-col",
35
+ children: [
36
+ /* @__PURE__ */ jsx("span", {
37
+ className: "truncate text-body weight-semibold text-foreground",
38
+ children: title
39
+ }),
40
+ caption && /* @__PURE__ */ jsx("span", {
41
+ className: "truncate text-caption text-muted-foreground",
42
+ children: caption
43
+ })
44
+ ]
45
+ }),
46
+ value !== undefined && /* @__PURE__ */ jsx("span", {
47
+ className: cn("shrink-0 text-subtitle weight-semibold tabular-nums", TONE[tone]),
48
+ children: value
49
+ }),
50
+ trailing,
51
+ action && /* @__PURE__ */ jsx("span", {
52
+ className: "flex shrink-0 items-center",
53
+ children: action
54
+ })
55
+ ]
56
+ });
57
+ }
58
+ export { IslandFlash2 };
@@ -0,0 +1,116 @@
1
+ "use client";
2
+
3
+ // blocks/system/controls/index.tsx
4
+ import Slider from "@justanarthur/modo-ui/components/inputs/slider";
5
+ import { useControllableState } from "@justanarthur/modo-ui/lib/use-controllable-state";
6
+ import { cn } from "@justanarthur/modo-ui/lib/utils";
7
+ import {
8
+ Keyboard,
9
+ KeyboardOff,
10
+ Speaker,
11
+ Sun,
12
+ SunDim,
13
+ SunMedium,
14
+ Volume,
15
+ Volume1,
16
+ Volume2,
17
+ VolumeX
18
+ } from "lucide-react";
19
+ import { jsx, jsxs } from "react/jsx-runtime";
20
+ /*!
21
+ * Local addition: a notch app's system controls and their HUD, the level the
22
+ * island shows in place of the system's volume and brightness overlay.
23
+ * Rebuilt from Just Notch's HUD plugin (`Level`, `Controls`, `Flash`) as
24
+ * presentational parts: the levels come in as values.
25
+ */
26
+ var LABEL = {
27
+ volume: "Volume",
28
+ brightness: "Brightness",
29
+ keyboard: "Keyboard brightness"
30
+ };
31
+ function glyph(kind, value, muted) {
32
+ if (kind === "volume") {
33
+ if (muted || value === 0)
34
+ return VolumeX;
35
+ return value < 0.34 ? Volume : value < 0.67 ? Volume1 : Volume2;
36
+ }
37
+ if (kind === "brightness")
38
+ return value < 0.34 ? SunDim : value < 0.67 ? SunMedium : Sun;
39
+ return value === 0 ? KeyboardOff : Keyboard;
40
+ }
41
+ function ControlsLevel2({
42
+ kind,
43
+ value: valueProp,
44
+ defaultValue = 0,
45
+ onValueChange,
46
+ muted,
47
+ className
48
+ }) {
49
+ const [value, setValue] = useControllableState(valueProp, defaultValue, onValueChange);
50
+ const shown = muted ? 0 : value;
51
+ const Icon = glyph(kind, shown, muted);
52
+ const percent = Math.round(shown * 100);
53
+ return /* @__PURE__ */ jsxs("div", {
54
+ className: cn("flex h-7 items-center gap-3", className),
55
+ children: [
56
+ /* @__PURE__ */ jsx(Icon, {
57
+ size: 16,
58
+ strokeWidth: 1.5,
59
+ className: "shrink-0 text-foreground"
60
+ }),
61
+ /* @__PURE__ */ jsx(Slider, {
62
+ className: "mb-0 min-w-0 flex-1",
63
+ size: "compact",
64
+ label: LABEL[kind],
65
+ showValue: false,
66
+ value: percent,
67
+ onValueChange: (v) => setValue(v / 100)
68
+ }),
69
+ /* @__PURE__ */ jsx("span", {
70
+ className: "w-7 shrink-0 text-right text-caption tabular-nums text-muted-foreground",
71
+ children: percent
72
+ })
73
+ ]
74
+ });
75
+ }
76
+ function Controls2({ value, defaultValue = { volume: 0.5 }, onValueChange, output, className }) {
77
+ const [levels, setLevels] = useControllableState(value, defaultValue, onValueChange);
78
+ return /* @__PURE__ */ jsxs("div", {
79
+ className: cn("flex size-full flex-col justify-center gap-1", className),
80
+ children: [
81
+ /* @__PURE__ */ jsx(ControlsLevel2, {
82
+ kind: "volume",
83
+ value: levels.volume,
84
+ muted: levels.muted,
85
+ onValueChange: (volume) => setLevels({ ...levels, volume, muted: false })
86
+ }),
87
+ levels.brightness !== undefined && /* @__PURE__ */ jsx(ControlsLevel2, {
88
+ kind: "brightness",
89
+ value: levels.brightness,
90
+ onValueChange: (brightness) => setLevels({ ...levels, brightness })
91
+ }),
92
+ levels.keyboard !== undefined && /* @__PURE__ */ jsx(ControlsLevel2, {
93
+ kind: "keyboard",
94
+ value: levels.keyboard,
95
+ onValueChange: (keyboard) => setLevels({ ...levels, keyboard })
96
+ }),
97
+ output && /* @__PURE__ */ jsxs("div", {
98
+ className: "flex h-7 items-center gap-3",
99
+ children: [
100
+ /* @__PURE__ */ jsx(Speaker, {
101
+ size: 16,
102
+ strokeWidth: 1.5,
103
+ className: "shrink-0 text-muted-foreground"
104
+ }),
105
+ /* @__PURE__ */ jsx("span", {
106
+ className: "min-w-0 truncate text-caption text-muted-foreground",
107
+ children: output
108
+ })
109
+ ]
110
+ })
111
+ ]
112
+ });
113
+ }
114
+ Controls2.Level = ControlsLevel2;
115
+ var controls_default = Controls2;
116
+ export { ControlsLevel2, Controls2, controls_default };
@@ -0,0 +1,47 @@
1
+ import { IslandTab2 } from "./chunk-w48eyvfr.js";
2
+ import { ReactNode } from "react";
3
+ import { JSX as JSX_1kxb } from "react";
4
+ interface ExpandedIslandTab2 extends IslandTab2 {
5
+ /** The tab's view, in the content area. */
6
+ content: ReactNode;
7
+ }
8
+ interface ExpandedIslandProps2 {
9
+ /** The tabs, in order, each with its view. */
10
+ tabs: ExpandedIslandTab2[];
11
+ /** The selected tab's value (controlled). */
12
+ value?: string;
13
+ /** The tab selected at first (uncontrolled). Defaults to the first tab. */
14
+ defaultValue?: string;
15
+ /** Called with the value of the tab a press or an arrow key selects. */
16
+ onValueChange?: (value: string) => void;
17
+ /** Called by the settings button at the right wing's far end; without it the button hides. */
18
+ onSettings?: () => void;
19
+ /** The settings button's accessible name. Defaults to `'Settings'`. */
20
+ settingsLabel?: string;
21
+ /** What the content area says without tabs. Defaults to `'Nothing here yet'`. */
22
+ empty?: ReactNode;
23
+ /** Classes for the root, which fills the open island. */
24
+ className?: string;
25
+ }
26
+ type Element_12xgc = JSX_1kxb["Element"];
27
+ /**
28
+ * The open island's layout: icon tabs in the wings around the notch, the
29
+ * tab's title under them, and its view in a content area of fixed height.
30
+ *
31
+ * The header is the notch's height, so the tabs sit in the wings beside the
32
+ * hardware notch: the kit's IslandTabs at the compact step, with a settings
33
+ * button at the right wing's far end when `onSettings` is given. Under it
34
+ * the selected tab's title, or the hovered tab's as a preview. The view
35
+ * fills the rest: the area keeps its height whatever the view holds, and a
36
+ * taller view scrolls inside it, its edges fading with `scroll-fade` (a
37
+ * modo-ui ScrollArea), back at the top on each new tab. Every part starts at
38
+ * the island's one inset, clear of its rounded bottom corners.
39
+ *
40
+ * Pass it as the Island's `expanded`; it reads the notch from the Island.
41
+ * Selection runs through `value` / `onValueChange`, or is kept here from
42
+ * `defaultValue`.
43
+ *
44
+ * @example {@include ./examples.mdx}
45
+ */
46
+ declare function ExpandedIsland2({ tabs, value: valueProp, defaultValue, onValueChange, onSettings, settingsLabel, empty, className }: ExpandedIslandProps2): Element_12xgc;
47
+ export { ExpandedIslandTab2, ExpandedIslandProps2, ExpandedIsland2 };
@@ -0,0 +1,145 @@
1
+ "use client";
2
+
3
+ import {
4
+ BatteryGlyph2
5
+ } from "./chunk-hwtxpzg0.js";
6
+ import {
7
+ IslandFlash2
8
+ } from "./chunk-78w7qwp0.js";
9
+
10
+ // blocks/system/devices/index.tsx
11
+ import Button from "@justanarthur/modo-ui/components/actions/button";
12
+ import EmptyState from "@justanarthur/modo-ui/components/feedback/empty-state";
13
+ import StatusDot from "@justanarthur/modo-ui/components/feedback/status-dot";
14
+ import { cn } from "@justanarthur/modo-ui/lib/utils";
15
+ import {
16
+ Bluetooth,
17
+ Gamepad2,
18
+ Headphones,
19
+ Keyboard,
20
+ Mouse,
21
+ Smartphone,
22
+ Speaker,
23
+ Watch
24
+ } from "lucide-react";
25
+ import { jsx, jsxs } from "react/jsx-runtime";
26
+ /*!
27
+ * Local addition: a notch app's Bluetooth devices and their batteries.
28
+ * Rebuilt from Just Notch's devices plugin (`Devices`, `Device`, `Connected`)
29
+ * as presentational parts: the devices come in as props.
30
+ */
31
+ var KIND = {
32
+ headphones: Headphones,
33
+ keyboard: Keyboard,
34
+ mouse: Mouse,
35
+ speaker: Speaker,
36
+ gamepad: Gamepad2,
37
+ phone: Smartphone,
38
+ watch: Watch,
39
+ other: Bluetooth
40
+ };
41
+ function Charge({ device }) {
42
+ if (device.battery === undefined)
43
+ return null;
44
+ return /* @__PURE__ */ jsxs("span", {
45
+ className: "flex shrink-0 items-center gap-2 text-caption tabular-nums text-muted-foreground",
46
+ children: [
47
+ device.battery,
48
+ "%",
49
+ /* @__PURE__ */ jsx(BatteryGlyph2, {
50
+ level: device.battery,
51
+ charging: device.charging,
52
+ fillIn: false
53
+ })
54
+ ]
55
+ });
56
+ }
57
+ function Glyph({ device }) {
58
+ const Icon = KIND[device.kind];
59
+ return /* @__PURE__ */ jsx("span", {
60
+ className: cn("flex size-8 shrink-0 items-center justify-center rounded-full", device.connected ? "bg-surface-3 text-foreground" : "bg-surface-2 text-muted-foreground"),
61
+ children: /* @__PURE__ */ jsx(Icon, {
62
+ size: 16,
63
+ strokeWidth: 1.5
64
+ })
65
+ });
66
+ }
67
+ function Device({ device }) {
68
+ return /* @__PURE__ */ jsxs("li", {
69
+ className: "flex h-11 min-w-0 items-center gap-3",
70
+ children: [
71
+ /* @__PURE__ */ jsx(Glyph, {
72
+ device
73
+ }),
74
+ /* @__PURE__ */ jsxs("div", {
75
+ className: "flex min-w-0 flex-1 flex-col",
76
+ children: [
77
+ /* @__PURE__ */ jsx("span", {
78
+ className: cn("truncate text-body", device.connected ? "text-foreground" : "text-muted-foreground"),
79
+ children: device.name
80
+ }),
81
+ /* @__PURE__ */ jsxs("span", {
82
+ className: "flex items-center gap-1.5 text-caption text-muted-foreground",
83
+ children: [
84
+ /* @__PURE__ */ jsx(StatusDot, {
85
+ status: device.connected ? "success" : "idle",
86
+ size: "compact"
87
+ }),
88
+ device.connected ? "Connected" : "Not connected"
89
+ ]
90
+ })
91
+ ]
92
+ }),
93
+ device.connected && /* @__PURE__ */ jsx(Charge, {
94
+ device
95
+ })
96
+ ]
97
+ });
98
+ }
99
+ function DevicesConnected2({ device }) {
100
+ const Icon = KIND[device.kind];
101
+ return /* @__PURE__ */ jsx(IslandFlash2, {
102
+ icon: /* @__PURE__ */ jsx("span", {
103
+ className: "flex size-8 items-center justify-center rounded-full bg-surface-3 text-foreground",
104
+ children: /* @__PURE__ */ jsx(Icon, {
105
+ size: 16,
106
+ strokeWidth: 1.5
107
+ })
108
+ }),
109
+ title: device.name,
110
+ caption: "Connected",
111
+ value: device.battery === undefined ? undefined : `${device.battery}%`,
112
+ trailing: device.battery === undefined ? undefined : /* @__PURE__ */ jsx(BatteryGlyph2, {
113
+ level: device.battery,
114
+ charging: device.charging
115
+ })
116
+ });
117
+ }
118
+ function Devices2({ devices, onOpenSettings, className }) {
119
+ if (devices.length === 0)
120
+ return /* @__PURE__ */ jsx("div", {
121
+ className: cn("flex size-full items-center justify-center", className),
122
+ children: /* @__PURE__ */ jsx(EmptyState, {
123
+ size: "compact",
124
+ icon: Bluetooth,
125
+ title: "No Bluetooth devices",
126
+ description: "Pair headphones, a keyboard or a mouse to see them here.",
127
+ actions: onOpenSettings && /* @__PURE__ */ jsx(Button, {
128
+ variant: "secondary",
129
+ size: "compact",
130
+ onClick: onOpenSettings,
131
+ children: "Open Bluetooth Settings"
132
+ })
133
+ })
134
+ });
135
+ const sorted = [...devices].sort((a, b) => Number(b.connected) - Number(a.connected) || a.name.localeCompare(b.name));
136
+ return /* @__PURE__ */ jsx("ul", {
137
+ className: cn("m-0 grid list-none grid-cols-2 content-start gap-x-8 p-0", className),
138
+ children: sorted.map((device) => /* @__PURE__ */ jsx(Device, {
139
+ device
140
+ }, device.id))
141
+ });
142
+ }
143
+ Devices2.Connected = DevicesConnected2;
144
+ var devices_default = Devices2;
145
+ export { DevicesConnected2, Devices2, devices_default };
@@ -0,0 +1,63 @@
1
+ /** What the island shows: the bare notch, an activity in the wings, two activities, the open panel, or an alert. */
2
+ type IslandState2 = "idle" | "compact" | "split" | "expanded" | "flash";
3
+ declare const ISLAND_STATES2: IslandState2[];
4
+ /** A width and a height in px. */
5
+ interface Size2 {
6
+ width: number;
7
+ height: number;
8
+ }
9
+ /** The sizes the island grows between: the hardware notch and the open panel. */
10
+ interface IslandGeometry2 {
11
+ notch: Size2;
12
+ panel: Size2;
13
+ }
14
+ /** The island's outline: a body of `w` × `h` hanging from the top edge, `radius` below, concave `shoulder`s into the edge. */
15
+ interface Shape2 {
16
+ w: number;
17
+ h: number;
18
+ radius: number;
19
+ shoulder: number;
20
+ }
21
+ declare const DEFAULT_NOTCH2: Size2;
22
+ declare const DEFAULT_PANEL2: Size2;
23
+ /** The open island's one content inset: header, title and content all start here, clear of the bottom corners. */
24
+ declare const INSET2 = 20;
25
+ /** Kept free on each side of the notch. */
26
+ declare const NOTCH_GAP2 = 8;
27
+ /** Room for one compact slot beside the notch: about as wide as the notch is tall. */
28
+ declare const slotWidth2: (notch: Size2) => number;
29
+ /**
30
+ * The outline for `state`. `room` is the width the island may take (its
31
+ * container's); the open panel and the flash shrink to fit it, shoulders included.
32
+ */
33
+ declare function shapeFor2(state: IslandState2, { notch, panel }: IslandGeometry2, room?: number): Shape2;
34
+ /** The detached bubble of `split`: a circle as tall as the compact island, its center `x` from the island's center. */
35
+ declare function bubbleFor2(shape: Shape2, notch: Size2, detached: boolean): {
36
+ x: number;
37
+ r: number;
38
+ };
39
+ /**
40
+ * The outline as one SVG path, centered on `cx`. It starts a point above the
41
+ * top edge so no hairline shows where it meets the screen.
42
+ */
43
+ declare function islandPath2(cx: number, { w, h, radius, shoulder }: Shape2): string;
44
+ interface StripLayout2 {
45
+ /** Tabs in the left wing; the rest follow in the right one. */
46
+ before: number;
47
+ /** More tabs than both wings hold: the strip scrolls, behind the notch. */
48
+ overflow: boolean;
49
+ /** The notch and its gaps in the strip's coordinates. */
50
+ hole: {
51
+ start: number;
52
+ end: number;
53
+ };
54
+ /** Least width of the gap between the wings, so the right wing starts past the notch. */
55
+ spacer: number;
56
+ }
57
+ /**
58
+ * Tabs of `tab` px across a strip of `width` centered under a notch of
59
+ * `notchWidth`, flowing from the left wing into the right one, balanced.
60
+ * `reserve` is kept free at the right wing's far end (a settings button).
61
+ */
62
+ declare function stripLayout2(count: number, width: number, notchWidth: number, tab: number, reserve?: number): StripLayout2;
63
+ export { IslandState2, ISLAND_STATES2, Size2, IslandGeometry2, Shape2, DEFAULT_NOTCH2, DEFAULT_PANEL2, INSET2, NOTCH_GAP2, slotWidth2, shapeFor2, bubbleFor2, islandPath2, StripLayout2, stripLayout2 };
@@ -0,0 +1,178 @@
1
+ "use client";
2
+
3
+ // blocks/system/system-stats/index.tsx
4
+ import Sparkline from "@justanarthur/modo-ui/components/data-display/sparkline";
5
+ import { cn } from "@justanarthur/modo-ui/lib/utils";
6
+ import { ArrowDown, ArrowUp, Cpu, MemoryStick, Network } from "lucide-react";
7
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
8
+ /*!
9
+ * Local addition: a notch app's system load, CPU, memory and network as
10
+ * tiles with their trends. Rebuilt from Just Notch's stats plugin (`System`,
11
+ * `Tile`, `Measuring`, `CpuLoad`) on modo-ui's Sparkline: the samples come
12
+ * in as props.
13
+ */
14
+ var percent = (v) => `${Math.round(v * 100)}%`;
15
+ var gigabytes = (bytes) => `${(bytes / 1e9).toFixed(1)} GB`;
16
+ function rate(bps) {
17
+ if (bps >= 1e6)
18
+ return `${(bps / 1e6).toFixed(1)} MB/s`;
19
+ if (bps >= 1000)
20
+ return `${Math.round(bps / 1000)} KB/s`;
21
+ return `${Math.round(bps)} B/s`;
22
+ }
23
+ function Tile({ icon: Icon, label, value, children }) {
24
+ return /* @__PURE__ */ jsxs("div", {
25
+ className: "flex min-w-0 flex-col gap-2 rounded-xl bg-surface-2 p-3",
26
+ children: [
27
+ /* @__PURE__ */ jsxs("span", {
28
+ className: "flex items-center gap-1.5 text-caption text-muted-foreground",
29
+ children: [
30
+ /* @__PURE__ */ jsx(Icon, {
31
+ size: 14,
32
+ strokeWidth: 1.5
33
+ }),
34
+ label
35
+ ]
36
+ }),
37
+ /* @__PURE__ */ jsx("div", {
38
+ className: "flex min-w-0 items-baseline gap-2 text-subtitle weight-semibold tabular-nums text-foreground",
39
+ children: value
40
+ }),
41
+ /* @__PURE__ */ jsx("div", {
42
+ className: "mt-auto",
43
+ children
44
+ })
45
+ ]
46
+ });
47
+ }
48
+ function Measuring({ className }) {
49
+ const tiles = [
50
+ { icon: Cpu, label: "CPU" },
51
+ { icon: MemoryStick, label: "Memory" },
52
+ { icon: Network, label: "Network" }
53
+ ];
54
+ return /* @__PURE__ */ jsx("div", {
55
+ className: cn("grid size-full grid-cols-3 content-center gap-3", className),
56
+ "aria-busy": true,
57
+ children: tiles.map(({ icon, label }) => /* @__PURE__ */ jsx(Tile, {
58
+ icon,
59
+ label,
60
+ value: /* @__PURE__ */ jsx("span", {
61
+ className: "text-muted-foreground",
62
+ children: "–"
63
+ }),
64
+ children: /* @__PURE__ */ jsx(Sparkline, {
65
+ values: [],
66
+ label: `${label}, measuring`,
67
+ className: "h-10"
68
+ })
69
+ }, label))
70
+ });
71
+ }
72
+ function SystemStatsLeading2() {
73
+ return /* @__PURE__ */ jsx(Cpu, {
74
+ size: 16,
75
+ strokeWidth: 1.5,
76
+ className: "text-muted-foreground"
77
+ });
78
+ }
79
+ function SystemStatsTrailing2({ sample }) {
80
+ if (!sample)
81
+ return /* @__PURE__ */ jsx("span", {
82
+ className: "text-caption weight-semibold text-muted-foreground",
83
+ children: "–"
84
+ });
85
+ return /* @__PURE__ */ jsx("span", {
86
+ className: "text-caption weight-semibold tabular-nums text-foreground",
87
+ children: percent(sample.cpu)
88
+ });
89
+ }
90
+ function SystemStats2({ samples, className }) {
91
+ const last = samples.at(-1);
92
+ if (!last)
93
+ return /* @__PURE__ */ jsx(Measuring, {
94
+ className
95
+ });
96
+ const cpu = samples.map((s) => s.cpu);
97
+ const memory = samples.map((s) => s.memoryUsed);
98
+ const netIn = samples.map((s) => s.netIn);
99
+ const netOut = samples.map((s) => s.netOut);
100
+ return /* @__PURE__ */ jsxs("div", {
101
+ className: cn("grid size-full grid-cols-3 content-center gap-3", className),
102
+ children: [
103
+ /* @__PURE__ */ jsx(Tile, {
104
+ icon: Cpu,
105
+ label: "CPU",
106
+ value: percent(last.cpu),
107
+ children: /* @__PURE__ */ jsx(Sparkline, {
108
+ values: cpu,
109
+ max: 1,
110
+ label: `CPU, ${percent(last.cpu)}`,
111
+ className: "h-10"
112
+ })
113
+ }),
114
+ /* @__PURE__ */ jsx(Tile, {
115
+ icon: MemoryStick,
116
+ label: "Memory",
117
+ value: /* @__PURE__ */ jsxs(Fragment, {
118
+ children: [
119
+ gigabytes(last.memoryUsed),
120
+ /* @__PURE__ */ jsxs("span", {
121
+ className: "truncate text-caption weight-normal text-muted-foreground",
122
+ children: [
123
+ "of ",
124
+ gigabytes(last.memoryTotal)
125
+ ]
126
+ })
127
+ ]
128
+ }),
129
+ children: /* @__PURE__ */ jsx(Sparkline, {
130
+ values: memory,
131
+ max: last.memoryTotal,
132
+ label: `Memory, ${gigabytes(last.memoryUsed)}`,
133
+ className: "h-10"
134
+ })
135
+ }),
136
+ /* @__PURE__ */ jsx(Tile, {
137
+ icon: Network,
138
+ label: "Network",
139
+ value: /* @__PURE__ */ jsxs(Fragment, {
140
+ children: [
141
+ /* @__PURE__ */ jsxs("span", {
142
+ className: "flex items-center gap-0.5",
143
+ children: [
144
+ /* @__PURE__ */ jsx(ArrowDown, {
145
+ size: 12,
146
+ strokeWidth: 2,
147
+ "aria-label": "In"
148
+ }),
149
+ rate(last.netIn)
150
+ ]
151
+ }),
152
+ /* @__PURE__ */ jsxs("span", {
153
+ className: "flex min-w-0 items-center gap-0.5 truncate text-caption weight-normal text-muted-foreground",
154
+ children: [
155
+ /* @__PURE__ */ jsx(ArrowUp, {
156
+ size: 12,
157
+ strokeWidth: 2,
158
+ "aria-label": "Out"
159
+ }),
160
+ rate(last.netOut)
161
+ ]
162
+ })
163
+ ]
164
+ }),
165
+ children: /* @__PURE__ */ jsx(Sparkline, {
166
+ values: netIn,
167
+ secondary: netOut,
168
+ label: `Network, ${rate(last.netIn)} in, ${rate(last.netOut)} out`,
169
+ className: "h-10"
170
+ })
171
+ })
172
+ ]
173
+ });
174
+ }
175
+ SystemStats2.Leading = SystemStatsLeading2;
176
+ SystemStats2.Trailing = SystemStatsTrailing2;
177
+ var system_stats_default = SystemStats2;
178
+ export { SystemStatsLeading2, SystemStatsTrailing2, SystemStats2, system_stats_default };
@@ -0,0 +1,10 @@
1
+ "use client";
2
+
3
+ // lib/island-context.tsx
4
+ import { createContext, useContext } from "react";
5
+ var IslandContext2 = createContext(null);
6
+ function useIsland2() {
7
+ return useContext(IslandContext2);
8
+ }
9
+
10
+ export { IslandContext2, useIsland2 };