@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.
- package/LICENSE +21 -0
- package/README.md +75 -2
- package/blocks/activities/agenda/examples.mdx +58 -0
- package/blocks/activities/agenda/index.tsx +332 -0
- package/blocks/activities/now-playing/examples.mdx +49 -0
- package/blocks/activities/now-playing/index.tsx +218 -0
- package/blocks/activities/shelf/examples.mdx +33 -0
- package/blocks/activities/shelf/index.tsx +289 -0
- package/blocks/activities/timer/examples.mdx +52 -0
- package/blocks/activities/timer/index.tsx +292 -0
- package/blocks/app/expanded-island/examples.mdx +45 -0
- package/blocks/app/expanded-island/index.tsx +127 -0
- package/blocks/app/settings-window/examples.mdx +30 -0
- package/blocks/app/settings-window/index.tsx +357 -0
- package/blocks/system/controls/examples.mdx +34 -0
- package/blocks/system/controls/index.tsx +167 -0
- package/blocks/system/devices/examples.mdx +25 -0
- package/blocks/system/devices/index.tsx +172 -0
- package/blocks/system/power-alert/examples.mdx +32 -0
- package/blocks/system/power-alert/index.tsx +89 -0
- package/blocks/system/system-stats/examples.mdx +23 -0
- package/blocks/system/system-stats/index.tsx +178 -0
- package/components/indicators/battery-glyph/examples.mdx +22 -0
- package/components/indicators/battery-glyph/index.tsx +91 -0
- package/components/indicators/countdown/examples.mdx +25 -0
- package/components/indicators/countdown/index.tsx +83 -0
- package/components/indicators/equalizer/examples.mdx +20 -0
- package/components/indicators/equalizer/index.tsx +116 -0
- package/components/indicators/media-scrubber/examples.mdx +21 -0
- package/components/indicators/media-scrubber/index.tsx +98 -0
- package/components/island/island/examples.mdx +57 -0
- package/components/island/island/index.tsx +415 -0
- package/components/island/island-flash/examples.mdx +55 -0
- package/components/island/island-flash/index.tsx +79 -0
- package/components/island/island-tabs/examples.mdx +53 -0
- package/components/island/island-tabs/index.tsx +285 -0
- package/dist/blocks/activities/agenda/index.d.ts +2 -0
- package/dist/blocks/activities/agenda/index.js +21 -0
- package/dist/blocks/activities/now-playing/index.d.ts +2 -0
- package/dist/blocks/activities/now-playing/index.js +22 -0
- package/dist/blocks/activities/shelf/index.d.ts +2 -0
- package/dist/blocks/activities/shelf/index.js +14 -0
- package/dist/blocks/activities/timer/index.d.ts +2 -0
- package/dist/blocks/activities/timer/index.js +19 -0
- package/dist/blocks/app/expanded-island/index.d.ts +3 -0
- package/dist/blocks/app/expanded-island/index.js +10 -0
- package/dist/blocks/app/settings-window/index.d.ts +2 -0
- package/dist/blocks/app/settings-window/index.js +7 -0
- package/dist/blocks/system/controls/index.d.ts +2 -0
- package/dist/blocks/system/controls/index.js +10 -0
- package/dist/blocks/system/devices/index.d.ts +2 -0
- package/dist/blocks/system/devices/index.js +12 -0
- package/dist/blocks/system/power-alert/index.d.ts +2 -0
- package/dist/blocks/system/power-alert/index.js +9 -0
- package/dist/blocks/system/system-stats/index.d.ts +2 -0
- package/dist/blocks/system/system-stats/index.js +12 -0
- package/dist/components/indicators/battery-glyph/index.d.ts +2 -0
- package/dist/components/indicators/battery-glyph/index.js +9 -0
- package/dist/components/indicators/countdown/index.d.ts +2 -0
- package/dist/components/indicators/countdown/index.js +8 -0
- package/dist/components/indicators/equalizer/index.d.ts +2 -0
- package/dist/components/indicators/equalizer/index.js +7 -0
- package/dist/components/indicators/media-scrubber/index.d.ts +2 -0
- package/dist/components/indicators/media-scrubber/index.js +8 -0
- package/dist/components/island/island/index.d.ts +3 -0
- package/dist/components/island/island/index.js +10 -0
- package/dist/components/island/island-flash/index.d.ts +2 -0
- package/dist/components/island/island-flash/index.js +7 -0
- package/dist/components/island/island-tabs/index.d.ts +2 -0
- package/dist/components/island/island-tabs/index.js +9 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +151 -0
- package/dist/lib/clock.d.ts +2 -0
- package/dist/lib/clock.js +14 -0
- package/dist/lib/geometry.d.ts +2 -0
- package/dist/lib/geometry.js +24 -0
- package/dist/lib/island-context.d.ts +3 -0
- package/dist/lib/island-context.js +8 -0
- package/dist/lib/motion.d.ts +21 -0
- package/dist/lib/motion.js +16 -0
- package/dist/shared/chunk-152gpyq3.d.ts +13 -0
- package/dist/shared/chunk-2f7zxrbk.js +65 -0
- package/dist/shared/chunk-2qpcsv5h.d.ts +45 -0
- package/dist/shared/chunk-2s4q6mt0.js +27 -0
- package/dist/shared/chunk-45gytfr1.d.ts +84 -0
- package/dist/shared/chunk-502rmtap.js +54 -0
- package/dist/shared/chunk-50ffk4r7.d.ts +69 -0
- package/dist/shared/chunk-52gb3g6r.d.ts +12 -0
- package/dist/shared/chunk-5en5aaj1.d.ts +33 -0
- package/dist/shared/chunk-5w0yck07.d.ts +32 -0
- package/dist/shared/chunk-6c1jbefs.d.ts +36 -0
- package/dist/shared/chunk-78w7qwp0.js +58 -0
- package/dist/shared/chunk-7hr53mby.js +116 -0
- package/dist/shared/chunk-9nhpg9t8.d.ts +47 -0
- package/dist/shared/chunk-b8jb1w72.js +145 -0
- package/dist/shared/chunk-cfzmfnyh.d.ts +63 -0
- package/dist/shared/chunk-cpewy6yg.js +178 -0
- package/dist/shared/chunk-d5qm9cps.js +10 -0
- package/dist/shared/chunk-e3e4s4ds.d.ts +77 -0
- package/dist/shared/chunk-enm6td0p.js +280 -0
- package/dist/shared/chunk-fvedaas2.d.ts +33 -0
- package/dist/shared/chunk-gb56m10p.js +39 -0
- package/dist/shared/chunk-gex38j8x.d.ts +82 -0
- package/dist/shared/chunk-hpsabfsd.d.ts +75 -0
- package/dist/shared/chunk-hrpxbqmx.d.ts +28 -0
- package/dist/shared/chunk-hwtxpzg0.js +69 -0
- package/dist/shared/chunk-mp1nx0ez.js +101 -0
- package/dist/shared/chunk-phb53x1f.js +252 -0
- package/dist/shared/chunk-r8esmjfs.d.ts +42 -0
- package/dist/shared/chunk-rcp1g9ca.js +70 -0
- package/dist/shared/chunk-rpfwv3pz.js +209 -0
- package/dist/shared/chunk-rr5e0g15.d.ts +35 -0
- package/dist/shared/chunk-rx9sphz2.js +266 -0
- package/dist/shared/chunk-s33y1pcq.js +305 -0
- package/dist/shared/chunk-sbnrhy5m.js +331 -0
- package/dist/shared/chunk-w48eyvfr.d.ts +56 -0
- package/dist/shared/chunk-wwjxs75m.js +74 -0
- package/dist/shared/chunk-xdeek16r.d.ts +58 -0
- package/dist/shared/chunk-xkzjk1tq.js +206 -0
- package/dist/shared/chunk-yngkkxz2.d.ts +88 -0
- package/dist/shared/chunk-zvh0d3qb.js +63 -0
- package/dist/styles.css +222 -0
- package/index.ts +21 -0
- package/lib/clock.ts +53 -0
- package/lib/geometry.ts +130 -0
- package/lib/island-context.tsx +24 -0
- package/lib/motion.ts +42 -0
- package/mock/activities.tsx +100 -0
- package/mock/artwork.tsx +25 -0
- package/mock/data.ts +153 -0
- package/mock/desktop.tsx +83 -0
- package/mock/fit.ts +26 -0
- package/mock/island-content.tsx +217 -0
- package/mock/scene.tsx +52 -0
- package/mock/settings.tsx +210 -0
- package/package.json +117 -4
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
SECOND2,
|
|
5
|
+
formatClock2,
|
|
6
|
+
useEdgeClock2
|
|
7
|
+
} from "./chunk-gb56m10p.js";
|
|
8
|
+
|
|
9
|
+
// components/indicators/media-scrubber/index.tsx
|
|
10
|
+
import Slider from "@justanarthur/modo-ui/components/inputs/slider";
|
|
11
|
+
import { cn } from "@justanarthur/modo-ui/lib/utils";
|
|
12
|
+
import { useEffect, useState } from "react";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
/*!
|
|
15
|
+
* Local addition: the playback position of a notch app's now-playing view,
|
|
16
|
+
* on modo-ui's Slider. Rebuilt from Just Notch's now-playing plugin
|
|
17
|
+
* (`Scrubber`).
|
|
18
|
+
*/
|
|
19
|
+
function MediaScrubber2({
|
|
20
|
+
position,
|
|
21
|
+
duration,
|
|
22
|
+
playing = false,
|
|
23
|
+
onSeek,
|
|
24
|
+
size = "compact",
|
|
25
|
+
label = "Position",
|
|
26
|
+
disabled = false,
|
|
27
|
+
className
|
|
28
|
+
}) {
|
|
29
|
+
const [base, setBase] = useState(() => ({ seconds: position, since: Date.now() }));
|
|
30
|
+
const [dragged, setDragged] = useState();
|
|
31
|
+
useEffect(() => setBase({ seconds: position, since: Date.now() }), [position]);
|
|
32
|
+
const now = useEdgeClock2(base.since, playing && dragged === undefined);
|
|
33
|
+
const live = Math.min(duration, base.seconds + (playing ? Math.max(0, now - base.since) / SECOND2 : 0));
|
|
34
|
+
const value = dragged ?? live;
|
|
35
|
+
const commit = () => {
|
|
36
|
+
if (dragged === undefined)
|
|
37
|
+
return;
|
|
38
|
+
setBase({ seconds: dragged, since: Date.now() });
|
|
39
|
+
setDragged(undefined);
|
|
40
|
+
onSeek?.(dragged);
|
|
41
|
+
};
|
|
42
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
43
|
+
className: cn("flex items-center gap-3", className),
|
|
44
|
+
onPointerUp: commit,
|
|
45
|
+
onKeyUp: commit,
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsx("span", {
|
|
48
|
+
className: "w-9 shrink-0 text-micro tabular-nums text-muted-foreground",
|
|
49
|
+
children: formatClock2(value)
|
|
50
|
+
}),
|
|
51
|
+
/* @__PURE__ */ jsx(Slider, {
|
|
52
|
+
className: "mb-0 min-w-0 flex-1",
|
|
53
|
+
size,
|
|
54
|
+
label,
|
|
55
|
+
showValue: false,
|
|
56
|
+
formatValue: formatClock2,
|
|
57
|
+
min: 0,
|
|
58
|
+
max: Math.max(1, duration),
|
|
59
|
+
step: 1,
|
|
60
|
+
value,
|
|
61
|
+
disabled,
|
|
62
|
+
onValueChange: (v) => setDragged(v)
|
|
63
|
+
}),
|
|
64
|
+
/* @__PURE__ */ jsxs("span", {
|
|
65
|
+
className: "w-9 shrink-0 text-right text-micro tabular-nums text-muted-foreground",
|
|
66
|
+
children: [
|
|
67
|
+
"-",
|
|
68
|
+
formatClock2(Math.max(0, duration - value))
|
|
69
|
+
]
|
|
70
|
+
})
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export { MediaScrubber2 };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { JSX as JSX_1kxb } from "react";
|
|
2
|
+
type ControlKind2 = "volume" | "brightness" | "keyboard";
|
|
3
|
+
/** The levels, from 0 to 1. A missing brightness or keyboard level hides its row (no built-in display, no backlight). */
|
|
4
|
+
interface ControlLevels2 {
|
|
5
|
+
volume: number;
|
|
6
|
+
muted?: boolean;
|
|
7
|
+
brightness?: number;
|
|
8
|
+
keyboard?: number;
|
|
9
|
+
}
|
|
10
|
+
interface ControlsProps2 {
|
|
11
|
+
/** The levels (controlled). */
|
|
12
|
+
value?: ControlLevels2;
|
|
13
|
+
/** The levels at first (uncontrolled). Defaults to the volume at half. */
|
|
14
|
+
defaultValue?: ControlLevels2;
|
|
15
|
+
/** Called with every level when a slider moves one; moving volume unmutes it. */
|
|
16
|
+
onValueChange?: (levels: ControlLevels2) => void;
|
|
17
|
+
/** The audio output's name, on a muted row under the sliders. */
|
|
18
|
+
output?: string;
|
|
19
|
+
/** Classes for the root, which fills its container. */
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
interface ControlsLevelProps2 {
|
|
23
|
+
/** What it sets. */
|
|
24
|
+
kind: ControlKind2;
|
|
25
|
+
/** The level, from 0 to 1 (controlled). */
|
|
26
|
+
value?: number;
|
|
27
|
+
/** The level at first (uncontrolled). Defaults to `0`. */
|
|
28
|
+
defaultValue?: number;
|
|
29
|
+
/** Called with the level, from 0 to 1, as the slider moves. */
|
|
30
|
+
onValueChange?: (value: number) => void;
|
|
31
|
+
/** Volume only: it is muted, so it reads 0 and shows the crossed speaker until moved. */
|
|
32
|
+
muted?: boolean;
|
|
33
|
+
/** Classes for the row. */
|
|
34
|
+
className?: string;
|
|
35
|
+
}
|
|
36
|
+
type Element_12xgc = JSX_1kxb["Element"];
|
|
37
|
+
/** One level as a row: a glyph that follows it, a compact slider and the percent. Pass it as the HUD's flash, keyed by kind. */
|
|
38
|
+
declare function ControlsLevel2({ kind, value: valueProp, defaultValue, onValueChange, muted, className }: ControlsLevelProps2): Element_12xgc;
|
|
39
|
+
/**
|
|
40
|
+
* A notch app's system controls: volume, display brightness and keyboard
|
|
41
|
+
* backlight as sliders, and the audio output.
|
|
42
|
+
*
|
|
43
|
+
* Each row is a glyph that follows its level (the speaker's waves, a muted
|
|
44
|
+
* cross, the sun's rays, the backlight off), modo-ui's compact Slider and the
|
|
45
|
+
* level in percent. A display without a brightness reading, or a keyboard
|
|
46
|
+
* without a backlight, leaves its level out and so its row. The levels are
|
|
47
|
+
* one value from 0 to 1 each (`value` / `onValueChange`, or kept here from
|
|
48
|
+
* `defaultValue`); moving the volume unmutes it.
|
|
49
|
+
*
|
|
50
|
+
* `Controls.Level` is one row on its own: the HUD flash that replaces the
|
|
51
|
+
* system's overlay when a volume or brightness key is pressed. Key it by
|
|
52
|
+
* kind, so pressing a brightness key while the volume shows swaps the flash
|
|
53
|
+
* instead of repainting it.
|
|
54
|
+
*
|
|
55
|
+
* @example {@include ./examples.mdx}
|
|
56
|
+
*/
|
|
57
|
+
declare function Controls2({ value, defaultValue, onValueChange, output, className }: ControlsProps2): Element_12xgc;
|
|
58
|
+
export { ControlKind2, ControlLevels2, ControlsProps2, ControlsLevelProps2, ControlsLevel2, Controls2 };
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Equalizer2
|
|
5
|
+
} from "./chunk-2f7zxrbk.js";
|
|
6
|
+
import {
|
|
7
|
+
MediaScrubber2
|
|
8
|
+
} from "./chunk-wwjxs75m.js";
|
|
9
|
+
import {
|
|
10
|
+
IslandFlash2
|
|
11
|
+
} from "./chunk-78w7qwp0.js";
|
|
12
|
+
|
|
13
|
+
// blocks/activities/now-playing/index.tsx
|
|
14
|
+
import Button from "@justanarthur/modo-ui/components/actions/button";
|
|
15
|
+
import EmptyState from "@justanarthur/modo-ui/components/feedback/empty-state";
|
|
16
|
+
import { useControllableState } from "@justanarthur/modo-ui/lib/use-controllable-state";
|
|
17
|
+
import { cn } from "@justanarthur/modo-ui/lib/utils";
|
|
18
|
+
import { Music, Pause, Play, SkipBack, SkipForward } from "lucide-react";
|
|
19
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
+
/*!
|
|
21
|
+
* Local addition: what's playing, in every form a notch app shows it.
|
|
22
|
+
* Rebuilt from Just Notch's now-playing plugin (`Player`, `Artwork`,
|
|
23
|
+
* `TrackFlash`) as presentational parts: the track and the commands come in
|
|
24
|
+
* as props.
|
|
25
|
+
*/
|
|
26
|
+
var GLYPH = { strokeWidth: 1.5, fill: "currentColor", strokeLinejoin: "round" };
|
|
27
|
+
function NowPlayingArtwork2({ artwork, glyph = 14, className }) {
|
|
28
|
+
return /* @__PURE__ */ jsx("span", {
|
|
29
|
+
className: cn("flex shrink-0 items-center justify-center overflow-hidden bg-surface-3 text-muted-foreground", className),
|
|
30
|
+
children: typeof artwork === "string" ? /* @__PURE__ */ jsx("img", {
|
|
31
|
+
alt: "",
|
|
32
|
+
src: artwork,
|
|
33
|
+
draggable: false,
|
|
34
|
+
className: "size-full object-cover"
|
|
35
|
+
}) : artwork ?? /* @__PURE__ */ jsx(Music, {
|
|
36
|
+
size: glyph,
|
|
37
|
+
strokeWidth: 1.5
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function NowPlayingLeading2({ track }) {
|
|
42
|
+
return /* @__PURE__ */ jsx(NowPlayingArtwork2, {
|
|
43
|
+
artwork: track?.artwork,
|
|
44
|
+
glyph: 12,
|
|
45
|
+
className: "size-5.5 rounded-md"
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function NowPlayingTrailing2({ playing = true }) {
|
|
49
|
+
return /* @__PURE__ */ jsx(Equalizer2, {
|
|
50
|
+
playing,
|
|
51
|
+
label: playing ? "Playing" : "Paused"
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function NowPlayingMinimal2({ track }) {
|
|
55
|
+
return /* @__PURE__ */ jsx(NowPlayingArtwork2, {
|
|
56
|
+
artwork: track?.artwork,
|
|
57
|
+
glyph: 12,
|
|
58
|
+
className: "size-6 rounded-full"
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function NowPlayingFlash2({ track, playing = true }) {
|
|
62
|
+
return /* @__PURE__ */ jsx(IslandFlash2, {
|
|
63
|
+
icon: /* @__PURE__ */ jsx(NowPlayingArtwork2, {
|
|
64
|
+
artwork: track.artwork,
|
|
65
|
+
className: "size-8 rounded-lg"
|
|
66
|
+
}),
|
|
67
|
+
title: track.title || "Unknown title",
|
|
68
|
+
caption: track.artist || track.album || track.source,
|
|
69
|
+
trailing: /* @__PURE__ */ jsx(Equalizer2, {
|
|
70
|
+
playing
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function Controls({ playing, onToggle, onPrevious, onNext }) {
|
|
75
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
76
|
+
className: "flex items-center gap-2",
|
|
77
|
+
children: [
|
|
78
|
+
/* @__PURE__ */ jsx(Button, {
|
|
79
|
+
variant: "ghost",
|
|
80
|
+
size: "icon",
|
|
81
|
+
"aria-label": "Previous",
|
|
82
|
+
onClick: onPrevious,
|
|
83
|
+
children: /* @__PURE__ */ jsx(SkipBack, {
|
|
84
|
+
...GLYPH,
|
|
85
|
+
size: 16
|
|
86
|
+
})
|
|
87
|
+
}),
|
|
88
|
+
/* @__PURE__ */ jsx(Button, {
|
|
89
|
+
variant: "ghost",
|
|
90
|
+
size: "icon",
|
|
91
|
+
className: "text-foreground",
|
|
92
|
+
"aria-label": playing ? "Pause" : "Play",
|
|
93
|
+
onClick: onToggle,
|
|
94
|
+
children: playing ? /* @__PURE__ */ jsx(Pause, {
|
|
95
|
+
...GLYPH,
|
|
96
|
+
size: 18
|
|
97
|
+
}) : /* @__PURE__ */ jsx(Play, {
|
|
98
|
+
...GLYPH,
|
|
99
|
+
size: 18
|
|
100
|
+
})
|
|
101
|
+
}),
|
|
102
|
+
/* @__PURE__ */ jsx(Button, {
|
|
103
|
+
variant: "ghost",
|
|
104
|
+
size: "icon",
|
|
105
|
+
"aria-label": "Next",
|
|
106
|
+
onClick: onNext,
|
|
107
|
+
children: /* @__PURE__ */ jsx(SkipForward, {
|
|
108
|
+
...GLYPH,
|
|
109
|
+
size: 16
|
|
110
|
+
})
|
|
111
|
+
})
|
|
112
|
+
]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function NowPlaying2({
|
|
116
|
+
track,
|
|
117
|
+
playing: playingProp,
|
|
118
|
+
defaultPlaying = true,
|
|
119
|
+
onPlayingChange,
|
|
120
|
+
onPrevious,
|
|
121
|
+
onNext,
|
|
122
|
+
onSeek,
|
|
123
|
+
emptyDescription = "Play something in Music, Spotify or a browser.",
|
|
124
|
+
className
|
|
125
|
+
}) {
|
|
126
|
+
const [playing, setPlaying] = useControllableState(playingProp, defaultPlaying, onPlayingChange);
|
|
127
|
+
if (!track)
|
|
128
|
+
return /* @__PURE__ */ jsx("div", {
|
|
129
|
+
className: cn("flex size-full items-center justify-center", className),
|
|
130
|
+
children: /* @__PURE__ */ jsx(EmptyState, {
|
|
131
|
+
size: "compact",
|
|
132
|
+
icon: Music,
|
|
133
|
+
title: "Nothing playing",
|
|
134
|
+
description: emptyDescription
|
|
135
|
+
})
|
|
136
|
+
});
|
|
137
|
+
const art = track.artwork !== undefined;
|
|
138
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
139
|
+
className: cn("flex size-full items-center gap-5", className),
|
|
140
|
+
children: [
|
|
141
|
+
art && /* @__PURE__ */ jsx(NowPlayingArtwork2, {
|
|
142
|
+
artwork: track.artwork,
|
|
143
|
+
className: "size-30 rounded-2xl"
|
|
144
|
+
}),
|
|
145
|
+
/* @__PURE__ */ jsxs("div", {
|
|
146
|
+
className: "flex min-w-0 flex-1 flex-col gap-2",
|
|
147
|
+
children: [
|
|
148
|
+
/* @__PURE__ */ jsxs("div", {
|
|
149
|
+
className: "flex items-center gap-3",
|
|
150
|
+
children: [
|
|
151
|
+
!art && /* @__PURE__ */ jsx(NowPlayingArtwork2, {
|
|
152
|
+
glyph: 18,
|
|
153
|
+
className: "size-10 rounded-xl"
|
|
154
|
+
}),
|
|
155
|
+
/* @__PURE__ */ jsxs("div", {
|
|
156
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
157
|
+
children: [
|
|
158
|
+
/* @__PURE__ */ jsx("span", {
|
|
159
|
+
className: "truncate text-subtitle weight-semibold text-foreground",
|
|
160
|
+
children: track.title || "Unknown title"
|
|
161
|
+
}),
|
|
162
|
+
(track.artist || track.album) && /* @__PURE__ */ jsx("span", {
|
|
163
|
+
className: "truncate text-caption text-muted-foreground",
|
|
164
|
+
children: track.artist || track.album
|
|
165
|
+
})
|
|
166
|
+
]
|
|
167
|
+
}),
|
|
168
|
+
/* @__PURE__ */ jsx(Equalizer2, {
|
|
169
|
+
playing
|
|
170
|
+
})
|
|
171
|
+
]
|
|
172
|
+
}),
|
|
173
|
+
track.duration > 0 && /* @__PURE__ */ jsx(MediaScrubber2, {
|
|
174
|
+
position: track.position,
|
|
175
|
+
duration: track.duration,
|
|
176
|
+
playing,
|
|
177
|
+
onSeek
|
|
178
|
+
}),
|
|
179
|
+
/* @__PURE__ */ jsxs("div", {
|
|
180
|
+
className: "grid grid-cols-[1fr_auto_1fr] items-center gap-3",
|
|
181
|
+
children: [
|
|
182
|
+
/* @__PURE__ */ jsx("span", {
|
|
183
|
+
className: "truncate text-caption text-muted-foreground",
|
|
184
|
+
children: track.source
|
|
185
|
+
}),
|
|
186
|
+
/* @__PURE__ */ jsx(Controls, {
|
|
187
|
+
playing,
|
|
188
|
+
onToggle: () => setPlaying(!playing),
|
|
189
|
+
onPrevious,
|
|
190
|
+
onNext
|
|
191
|
+
}),
|
|
192
|
+
/* @__PURE__ */ jsx("span", {})
|
|
193
|
+
]
|
|
194
|
+
})
|
|
195
|
+
]
|
|
196
|
+
})
|
|
197
|
+
]
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
NowPlaying2.Artwork = NowPlayingArtwork2;
|
|
201
|
+
NowPlaying2.Leading = NowPlayingLeading2;
|
|
202
|
+
NowPlaying2.Trailing = NowPlayingTrailing2;
|
|
203
|
+
NowPlaying2.Minimal = NowPlayingMinimal2;
|
|
204
|
+
NowPlaying2.Flash = NowPlayingFlash2;
|
|
205
|
+
var now_playing_default = NowPlaying2;
|
|
206
|
+
export { NowPlayingArtwork2, NowPlayingLeading2, NowPlayingTrailing2, NowPlayingMinimal2, NowPlayingFlash2, NowPlaying2, now_playing_default };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { IconComponent } from "@justanarthur/modo-ui/lib/icon-context";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { JSX as JSX_1kxb } from "react";
|
|
4
|
+
type ScreensPreference2 = "notched" | "all";
|
|
5
|
+
interface AppPreferences2 {
|
|
6
|
+
/** Start the app when the user logs in. */
|
|
7
|
+
launchAtLogin: boolean;
|
|
8
|
+
/** Where the island shows: on the notched screen only, or on every screen. */
|
|
9
|
+
screens: ScreensPreference2;
|
|
10
|
+
}
|
|
11
|
+
interface SettingsPlugin2 {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
/** One line on what it adds. */
|
|
15
|
+
description?: string;
|
|
16
|
+
/** Its glyph in the Plugins list. */
|
|
17
|
+
icon?: IconComponent;
|
|
18
|
+
/** Its settings, on a page of its own under Plugin settings. */
|
|
19
|
+
settings?: ReactNode;
|
|
20
|
+
}
|
|
21
|
+
interface SettingsPermission2 {
|
|
22
|
+
id: string;
|
|
23
|
+
label: string;
|
|
24
|
+
/** What the app does with it. */
|
|
25
|
+
description: string;
|
|
26
|
+
/** Whether macOS granted it; unset while it's being read. */
|
|
27
|
+
granted?: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface AboutRow2 {
|
|
30
|
+
label: string;
|
|
31
|
+
value: ReactNode;
|
|
32
|
+
}
|
|
33
|
+
interface SettingsWindowProps2 {
|
|
34
|
+
/** The app's name, over the sidebar. Defaults to `'Notch'`. */
|
|
35
|
+
name?: string;
|
|
36
|
+
/** The page shown: `general`, `plugins`, `permissions`, `about` or `plugin:<id>` (controlled). */
|
|
37
|
+
value?: string;
|
|
38
|
+
/** The page shown at first (uncontrolled). Defaults to `'general'`. */
|
|
39
|
+
defaultValue?: string;
|
|
40
|
+
/** Called with the page a sidebar row opens. */
|
|
41
|
+
onValueChange?: (value: string) => void;
|
|
42
|
+
/** The General page's preferences (controlled). */
|
|
43
|
+
preferences?: AppPreferences2;
|
|
44
|
+
/** The preferences at first (uncontrolled). Defaults to launching at login on the notched screen only. */
|
|
45
|
+
defaultPreferences?: AppPreferences2;
|
|
46
|
+
/** Called with every preference when one changes. */
|
|
47
|
+
onPreferencesChange?: (preferences: AppPreferences2) => void;
|
|
48
|
+
/** The installed plugins. Defaults to `[]`. */
|
|
49
|
+
plugins?: SettingsPlugin2[];
|
|
50
|
+
/** Which plugins are on, by id (controlled). */
|
|
51
|
+
enabled?: Record<string, boolean>;
|
|
52
|
+
/** Which plugins are on at first (uncontrolled). Defaults to every plugin. */
|
|
53
|
+
defaultEnabled?: Record<string, boolean>;
|
|
54
|
+
/** Called with every plugin's state when a switch changes one. */
|
|
55
|
+
onEnabledChange?: (enabled: Record<string, boolean>) => void;
|
|
56
|
+
/** What macOS lets the app read and control. Defaults to `[]`. */
|
|
57
|
+
permissions?: SettingsPermission2[];
|
|
58
|
+
/** Called by Open Settings on a permission that isn't granted. */
|
|
59
|
+
onOpenPermission?: (id: string) => void;
|
|
60
|
+
/** The About page's rows: version, mode, screen. Defaults to `[]`. */
|
|
61
|
+
about?: AboutRow2[];
|
|
62
|
+
/** Classes for the window's content, which fills its container. */
|
|
63
|
+
className?: string;
|
|
64
|
+
}
|
|
65
|
+
type Element_12xgc = JSX_1kxb["Element"];
|
|
66
|
+
/**
|
|
67
|
+
* A notch app's settings window: General, Plugins, Permissions and About,
|
|
68
|
+
* and a page for each plugin's own settings.
|
|
69
|
+
*
|
|
70
|
+
* A modo-ui Sidebar pinned open (the window is small, about 760 × 520, so
|
|
71
|
+
* it never folds into a drawer) lists the pages under the app's `name`, then
|
|
72
|
+
* the plugins that bring settings. General holds the launch at login Switch
|
|
73
|
+
* and a ChoiceList of the screens the island shows on. Plugins lists each
|
|
74
|
+
* installed plugin with its glyph, its line and a Switch that turns it on or
|
|
75
|
+
* off. Permissions shows what macOS granted as a StatusDot per row, with
|
|
76
|
+
* Open Settings beside one that isn't granted, and a spinner while it's
|
|
77
|
+
* being read. About lists the `about` rows. A plugin's page shows its
|
|
78
|
+
* `settings` node under its name.
|
|
79
|
+
*
|
|
80
|
+
* The page, the preferences and the plugins' states each run both ways
|
|
81
|
+
* (`value`, `preferences`, `enabled` with their `default*` and `on*Change`),
|
|
82
|
+
* so the window works on its own or on a host's store. It fills its
|
|
83
|
+
* container; the window's frame and title bar are the host's.
|
|
84
|
+
*
|
|
85
|
+
* @example {@include ./examples.mdx}
|
|
86
|
+
*/
|
|
87
|
+
declare function SettingsWindow2({ name, value, defaultValue, onValueChange, preferences: preferencesProp, defaultPreferences, onPreferencesChange, plugins, enabled: enabledProp, defaultEnabled, onEnabledChange, permissions, onOpenPermission, about, className }: SettingsWindowProps2): Element_12xgc;
|
|
88
|
+
export { ScreensPreference2, AppPreferences2, SettingsPlugin2, SettingsPermission2, AboutRow2, SettingsWindowProps2, SettingsWindow2 };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// lib/geometry.ts
|
|
2
|
+
var ISLAND_STATES2 = ["idle", "compact", "split", "expanded", "flash"];
|
|
3
|
+
var DEFAULT_NOTCH2 = { width: 185, height: 32 };
|
|
4
|
+
var DEFAULT_PANEL2 = { width: 720, height: 320 };
|
|
5
|
+
var INSET2 = 20;
|
|
6
|
+
var NOTCH_GAP2 = 8;
|
|
7
|
+
var FLASH_REACH = 64;
|
|
8
|
+
var FLASH_DROP = 48;
|
|
9
|
+
var slotWidth2 = (notch) => notch.height + 8;
|
|
10
|
+
function shapeFor2(state, { notch, panel }, room = Number.POSITIVE_INFINITY) {
|
|
11
|
+
const slot = slotWidth2(notch);
|
|
12
|
+
if (state === "idle")
|
|
13
|
+
return { w: notch.width, h: notch.height, radius: 10, shoulder: 6 };
|
|
14
|
+
if (state === "compact" || state === "split")
|
|
15
|
+
return { w: notch.width + 2 * slot, h: notch.height, radius: 13, shoulder: 8 };
|
|
16
|
+
if (state === "flash")
|
|
17
|
+
return {
|
|
18
|
+
w: Math.min(notch.width + 2 * (slot + FLASH_REACH), room - 20),
|
|
19
|
+
h: notch.height + FLASH_DROP,
|
|
20
|
+
radius: 24,
|
|
21
|
+
shoulder: 10
|
|
22
|
+
};
|
|
23
|
+
return { w: Math.max(notch.width, Math.min(panel.width, room - 28)), h: panel.height, radius: 32, shoulder: 14 };
|
|
24
|
+
}
|
|
25
|
+
function bubbleFor2(shape, notch, detached) {
|
|
26
|
+
const r = notch.height / 2 - 1;
|
|
27
|
+
return detached ? { x: shape.w / 2 + shape.shoulder + 14 + r, r } : { x: shape.w / 2 - r, r: r * 0.5 };
|
|
28
|
+
}
|
|
29
|
+
var CIRCLE = 0.5523;
|
|
30
|
+
var SMOOTH_SPAN = 1.28;
|
|
31
|
+
var SMOOTH_HANDLE = 0.64;
|
|
32
|
+
function islandPath2(cx, { w, h, radius, shoulder }) {
|
|
33
|
+
const s = Math.max(0, Math.min(shoulder, h / 2));
|
|
34
|
+
const span = Math.max(0, Math.min(radius * SMOOTH_SPAN, h - s, w / 2));
|
|
35
|
+
const k = span * (1 - SMOOTH_HANDLE);
|
|
36
|
+
const q = s * (1 - CIRCLE);
|
|
37
|
+
const l = cx - w / 2;
|
|
38
|
+
const r = cx + w / 2;
|
|
39
|
+
return [
|
|
40
|
+
`M${l - s} -1`,
|
|
41
|
+
`L${l - s} 0`,
|
|
42
|
+
`C${l - q} 0 ${l} ${q} ${l} ${s}`,
|
|
43
|
+
`L${l} ${h - span}`,
|
|
44
|
+
`C${l} ${h - k} ${l + k} ${h} ${l + span} ${h}`,
|
|
45
|
+
`L${r - span} ${h}`,
|
|
46
|
+
`C${r - k} ${h} ${r} ${h - k} ${r} ${h - span}`,
|
|
47
|
+
`L${r} ${s}`,
|
|
48
|
+
`C${r} ${q} ${r + q} 0 ${r + s} 0`,
|
|
49
|
+
`L${r + s} -1`,
|
|
50
|
+
"Z"
|
|
51
|
+
].join("");
|
|
52
|
+
}
|
|
53
|
+
function stripLayout2(count, width, notchWidth, tab, reserve = 0) {
|
|
54
|
+
const left = Math.max(0, (width - notchWidth) / 2 - NOTCH_GAP2);
|
|
55
|
+
const leftCap = Math.floor(left / tab);
|
|
56
|
+
const rightCap = Math.max(0, Math.floor((left - reserve) / tab));
|
|
57
|
+
const overflow = count > leftCap + rightCap;
|
|
58
|
+
const before = overflow ? leftCap : Math.min(leftCap, Math.max(Math.ceil(count / 2), count - rightCap));
|
|
59
|
+
const hole = { start: left, end: width - left };
|
|
60
|
+
return { before, overflow, hole, spacer: hole.end - before * tab };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { ISLAND_STATES2, DEFAULT_NOTCH2, DEFAULT_PANEL2, INSET2, NOTCH_GAP2, slotWidth2, shapeFor2, bubbleFor2, islandPath2, stripLayout2 };
|