@justanarthur/modo-ui-notch 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +75 -2
- package/blocks/activities/agenda/examples.mdx +74 -0
- package/blocks/activities/agenda/index.tsx +441 -0
- package/blocks/activities/clock/examples.mdx +73 -0
- package/blocks/activities/clock/index.tsx +619 -0
- package/blocks/activities/now-playing/examples.mdx +68 -0
- package/blocks/activities/now-playing/index.tsx +411 -0
- package/blocks/activities/weather/examples.mdx +115 -0
- package/blocks/activities/weather/index.tsx +634 -0
- package/blocks/app/expanded-island/examples.mdx +46 -0
- package/blocks/app/expanded-island/index.tsx +143 -0
- package/blocks/app/settings-window/examples.mdx +34 -0
- package/blocks/app/settings-window/index.tsx +375 -0
- package/blocks/system/clipboard/examples.mdx +83 -0
- package/blocks/system/clipboard/index.tsx +563 -0
- package/blocks/system/recent-files/examples.mdx +66 -0
- package/blocks/system/recent-files/index.tsx +542 -0
- package/blocks/system/system-stats/examples.mdx +52 -0
- package/blocks/system/system-stats/index.tsx +312 -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 +29 -0
- package/components/indicators/media-scrubber/index.tsx +122 -0
- package/components/island/island/examples.mdx +57 -0
- package/components/island/island/index.tsx +415 -0
- package/components/island/island-flash/examples.mdx +52 -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/components/island/widget/examples.mdx +76 -0
- package/components/island/widget/index.tsx +431 -0
- package/dist/blocks/activities/agenda/index.d.ts +2 -0
- package/dist/blocks/activities/agenda/index.js +21 -0
- package/dist/blocks/activities/clock/index.d.ts +2 -0
- package/dist/blocks/activities/clock/index.js +25 -0
- package/dist/blocks/activities/now-playing/index.d.ts +3 -0
- package/dist/blocks/activities/now-playing/index.js +24 -0
- package/dist/blocks/activities/weather/index.d.ts +2 -0
- package/dist/blocks/activities/weather/index.js +21 -0
- package/dist/blocks/app/expanded-island/index.d.ts +3 -0
- package/dist/blocks/app/expanded-island/index.js +11 -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/clipboard/index.d.ts +2 -0
- package/dist/blocks/system/clipboard/index.js +17 -0
- package/dist/blocks/system/recent-files/index.d.ts +2 -0
- package/dist/blocks/system/recent-files/index.js +19 -0
- package/dist/blocks/system/system-stats/index.d.ts +2 -0
- package/dist/blocks/system/system-stats/index.js +15 -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/components/island/widget/index.d.ts +2 -0
- package/dist/components/island/widget/index.js +30 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +195 -0
- package/dist/lib/artwork.d.ts +2 -0
- package/dist/lib/artwork.js +8 -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-2818esrq.d.ts +140 -0
- package/dist/shared/chunk-2f7zxrbk.js +65 -0
- package/dist/shared/chunk-2m5dz8nf.d.ts +88 -0
- package/dist/shared/chunk-2s4q6mt0.js +27 -0
- package/dist/shared/chunk-3thgcfcq.d.ts +151 -0
- package/dist/shared/chunk-416tsgbc.d.ts +175 -0
- package/dist/shared/chunk-502rmtap.js +54 -0
- package/dist/shared/chunk-52gb3g6r.d.ts +12 -0
- package/dist/shared/chunk-5en5aaj1.d.ts +33 -0
- package/dist/shared/chunk-61t2dfte.js +63 -0
- package/dist/shared/chunk-7fvnrtz4.d.ts +105 -0
- package/dist/shared/chunk-81fpptwp.d.ts +75 -0
- package/dist/shared/chunk-9c7ewvkk.js +381 -0
- package/dist/shared/chunk-9m0xbg5v.js +112 -0
- package/dist/shared/chunk-9xtcv3sy.js +88 -0
- package/dist/shared/chunk-bvtyjcce.d.ts +123 -0
- package/dist/shared/chunk-cc9nwbtf.js +315 -0
- package/dist/shared/chunk-cfzmfnyh.d.ts +63 -0
- package/dist/shared/chunk-d5qm9cps.js +10 -0
- package/dist/shared/chunk-da177e8r.d.ts +114 -0
- package/dist/shared/chunk-fexwzycv.d.ts +36 -0
- package/dist/shared/chunk-gb56m10p.js +39 -0
- package/dist/shared/chunk-gejenfap.d.ts +25 -0
- package/dist/shared/chunk-hrpxbqmx.d.ts +28 -0
- package/dist/shared/chunk-j755a1a5.d.ts +41 -0
- package/dist/shared/chunk-j77cx8dp.js +498 -0
- package/dist/shared/chunk-mt0k6v8x.js +474 -0
- package/dist/shared/chunk-ndf79pv5.js +58 -0
- package/dist/shared/chunk-pfhy5e4q.d.ts +53 -0
- package/dist/shared/chunk-qdzemt2v.js +477 -0
- package/dist/shared/chunk-r471sknr.js +209 -0
- package/dist/shared/chunk-s2jeqqan.js +243 -0
- package/dist/shared/chunk-t0hcxh89.d.ts +124 -0
- package/dist/shared/chunk-w48eyvfr.d.ts +56 -0
- package/dist/shared/chunk-w5h6ay93.js +72 -0
- package/dist/shared/chunk-wkg17nxs.d.ts +101 -0
- package/dist/shared/chunk-x7f3g82r.js +285 -0
- package/dist/shared/chunk-xq5hc5gv.js +333 -0
- package/dist/shared/chunk-y0188bbn.js +331 -0
- package/dist/shared/chunk-ym0xbses.js +518 -0
- package/dist/styles.css +264 -0
- package/index.ts +22 -0
- package/lib/artwork.ts +112 -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 +77 -0
- package/mock/artwork.tsx +37 -0
- package/mock/clipboard.tsx +79 -0
- package/mock/clock.tsx +77 -0
- package/mock/data.ts +139 -0
- package/mock/desktop.tsx +83 -0
- package/mock/files.tsx +70 -0
- package/mock/fit.ts +26 -0
- package/mock/island-content.tsx +142 -0
- package/mock/scene.tsx +52 -0
- package/mock/screen.tsx +76 -0
- package/mock/settings.tsx +489 -0
- package/mock/system.ts +46 -0
- package/mock/weather.tsx +105 -0
- package/package.json +122 -4
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// components/island/widget/index.tsx
|
|
4
|
+
import Button from "@justanarthur/modo-ui/components/actions/button";
|
|
5
|
+
import Tooltip from "@justanarthur/modo-ui/components/overlays/tooltip";
|
|
6
|
+
import { useSize } from "@justanarthur/modo-ui/lib/size-context";
|
|
7
|
+
import { SURFACE_BG } from "@justanarthur/modo-ui/lib/surface-classes";
|
|
8
|
+
import { useLift } from "@justanarthur/modo-ui/lib/surface-context";
|
|
9
|
+
import { cn } from "@justanarthur/modo-ui/lib/utils";
|
|
10
|
+
import { SizeScope } from "@justanarthur/modo-ui/primitives/systems/sizes";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
/*!
|
|
13
|
+
* Local addition: the open island's widget vocabulary, one frame and the few
|
|
14
|
+
* parts every widget is built from, so Now Playing, Calendar and the rest
|
|
15
|
+
* read as one system.
|
|
16
|
+
*/
|
|
17
|
+
var TITLE = { default: "text-title", compact: "text-title-compact" };
|
|
18
|
+
var SUBTITLE = { default: "text-body", compact: "text-body-compact" };
|
|
19
|
+
var CAPTION = { default: "text-caption", compact: "text-caption-compact" };
|
|
20
|
+
var FIGURE = { default: "text-display", compact: "text-display-compact" };
|
|
21
|
+
var GAP = { default: "gap-5", compact: "gap-4" };
|
|
22
|
+
var ASIDE = { default: "pl-5", compact: "pl-4" };
|
|
23
|
+
var META_ICON = { default: 14, compact: 12 };
|
|
24
|
+
var ACTION_GLYPH = { default: 16, compact: 14 };
|
|
25
|
+
var PRIMARY_GLYPH = { default: 22, compact: 18 };
|
|
26
|
+
function WidgetHeader2({ icon: Icon, children, trailing, className }) {
|
|
27
|
+
const size = useSize();
|
|
28
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
29
|
+
className: cn("flex h-6 min-w-0 items-center gap-1.5 text-muted-foreground", CAPTION[size.variant], className),
|
|
30
|
+
children: [
|
|
31
|
+
Icon && /* @__PURE__ */ jsx(Icon, {
|
|
32
|
+
size: META_ICON[size.variant],
|
|
33
|
+
strokeWidth: 1.5,
|
|
34
|
+
className: "shrink-0"
|
|
35
|
+
}),
|
|
36
|
+
/* @__PURE__ */ jsx("span", {
|
|
37
|
+
className: "min-w-0 flex-1 truncate",
|
|
38
|
+
children
|
|
39
|
+
}),
|
|
40
|
+
trailing && /* @__PURE__ */ jsx("span", {
|
|
41
|
+
className: "-mr-1 flex shrink-0 items-center",
|
|
42
|
+
children: trailing
|
|
43
|
+
})
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function WidgetTitle2({ children, leading, className }) {
|
|
48
|
+
const size = useSize();
|
|
49
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
50
|
+
className: cn("flex min-w-0 items-center gap-2", className),
|
|
51
|
+
children: [
|
|
52
|
+
leading,
|
|
53
|
+
/* @__PURE__ */ jsx("span", {
|
|
54
|
+
className: cn("min-w-0 truncate weight-semibold text-foreground", TITLE[size.variant]),
|
|
55
|
+
children
|
|
56
|
+
})
|
|
57
|
+
]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function WidgetSubtitle2({ children, className }) {
|
|
61
|
+
const size = useSize();
|
|
62
|
+
return /* @__PURE__ */ jsx("span", {
|
|
63
|
+
className: cn("block min-w-0 truncate text-muted-foreground", SUBTITLE[size.variant], className),
|
|
64
|
+
children
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function WidgetFigure2({ value, unit, prefix, color, className }) {
|
|
68
|
+
const size = useSize();
|
|
69
|
+
const small = cn("weight-semibold text-muted-foreground", TITLE[size.variant]);
|
|
70
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
71
|
+
className: cn("flex min-w-0 items-baseline gap-1.5 whitespace-nowrap tabular-nums", className),
|
|
72
|
+
children: [
|
|
73
|
+
prefix && /* @__PURE__ */ jsx("span", {
|
|
74
|
+
className: small,
|
|
75
|
+
children: prefix
|
|
76
|
+
}),
|
|
77
|
+
/* @__PURE__ */ jsx("span", {
|
|
78
|
+
className: cn("weight-bold", FIGURE[size.variant], color ? undefined : "text-foreground"),
|
|
79
|
+
style: color ? { color } : undefined,
|
|
80
|
+
children: value
|
|
81
|
+
}),
|
|
82
|
+
unit && /* @__PURE__ */ jsx("span", {
|
|
83
|
+
className: small,
|
|
84
|
+
children: unit
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function WidgetMetaItem2({ icon: Icon, children }) {
|
|
90
|
+
const size = useSize();
|
|
91
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
92
|
+
className: "flex min-w-0 items-center gap-1 last:shrink-[100]",
|
|
93
|
+
children: [
|
|
94
|
+
Icon && /* @__PURE__ */ jsx(Icon, {
|
|
95
|
+
size: META_ICON[size.variant],
|
|
96
|
+
strokeWidth: 1.5,
|
|
97
|
+
className: "shrink-0"
|
|
98
|
+
}),
|
|
99
|
+
/* @__PURE__ */ jsx("span", {
|
|
100
|
+
className: "min-w-0 truncate",
|
|
101
|
+
children
|
|
102
|
+
})
|
|
103
|
+
]
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function WidgetMeta2({ children, className }) {
|
|
107
|
+
const size = useSize();
|
|
108
|
+
return /* @__PURE__ */ jsx("div", {
|
|
109
|
+
className: cn("flex min-w-0 items-center gap-3 whitespace-nowrap text-muted-foreground tabular-nums", CAPTION[size.variant], className),
|
|
110
|
+
children
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function WidgetAction2({
|
|
114
|
+
icon: Icon,
|
|
115
|
+
label,
|
|
116
|
+
onClick,
|
|
117
|
+
pressed,
|
|
118
|
+
emphasis = "default",
|
|
119
|
+
filled = false,
|
|
120
|
+
color,
|
|
121
|
+
disabled = false
|
|
122
|
+
}) {
|
|
123
|
+
const size = useSize();
|
|
124
|
+
const primary = emphasis === "primary";
|
|
125
|
+
const lit = primary || !!pressed;
|
|
126
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
127
|
+
content: label,
|
|
128
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
129
|
+
variant: "ghost",
|
|
130
|
+
size: size.variant === "compact" ? "icon-compact" : "icon",
|
|
131
|
+
"aria-label": label,
|
|
132
|
+
"aria-pressed": pressed,
|
|
133
|
+
disabled,
|
|
134
|
+
className: cn(lit && "text-foreground"),
|
|
135
|
+
style: pressed && color ? { color } : undefined,
|
|
136
|
+
onClick,
|
|
137
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
138
|
+
size: primary ? PRIMARY_GLYPH[size.variant] : ACTION_GLYPH[size.variant],
|
|
139
|
+
strokeWidth: 1.5,
|
|
140
|
+
fill: filled ? "currentColor" : "none",
|
|
141
|
+
strokeLinejoin: "round"
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function WidgetMessage2({ icon: Icon, title, description, actions, className }) {
|
|
147
|
+
const size = useSize();
|
|
148
|
+
const level = useLift(1);
|
|
149
|
+
return /* @__PURE__ */ jsx("div", {
|
|
150
|
+
className: cn("@container flex size-full items-center justify-center", className),
|
|
151
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
152
|
+
className: "flex w-full max-w-120 items-center gap-4",
|
|
153
|
+
children: [
|
|
154
|
+
/* @__PURE__ */ jsx("span", {
|
|
155
|
+
className: cn("flex size-12 shrink-0 items-center justify-center rounded-xl text-muted-foreground", SURFACE_BG[level]),
|
|
156
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
157
|
+
size: 20,
|
|
158
|
+
strokeWidth: 1.5
|
|
159
|
+
})
|
|
160
|
+
}),
|
|
161
|
+
/* @__PURE__ */ jsxs("div", {
|
|
162
|
+
className: "flex min-w-0 flex-1 flex-col gap-0.5",
|
|
163
|
+
children: [
|
|
164
|
+
/* @__PURE__ */ jsx("span", {
|
|
165
|
+
className: cn("weight-semibold text-foreground", SUBTITLE[size.variant]),
|
|
166
|
+
children: title
|
|
167
|
+
}),
|
|
168
|
+
description && /* @__PURE__ */ jsx("span", {
|
|
169
|
+
className: cn("text-pretty text-muted-foreground", CAPTION[size.variant]),
|
|
170
|
+
children: description
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
}),
|
|
174
|
+
actions && /* @__PURE__ */ jsx("div", {
|
|
175
|
+
className: "flex shrink-0 items-center gap-2 @max-[22rem]:hidden",
|
|
176
|
+
children: actions
|
|
177
|
+
})
|
|
178
|
+
]
|
|
179
|
+
})
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function WidgetSection2({ label, trailing, children, className }) {
|
|
183
|
+
const size = useSize();
|
|
184
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
185
|
+
className: cn("flex min-w-0 flex-col", className),
|
|
186
|
+
children: [
|
|
187
|
+
/* @__PURE__ */ jsxs("div", {
|
|
188
|
+
className: cn("flex h-6 min-w-0 items-center gap-2 text-muted-foreground", CAPTION[size.variant]),
|
|
189
|
+
children: [
|
|
190
|
+
/* @__PURE__ */ jsx("span", {
|
|
191
|
+
className: "shrink-0",
|
|
192
|
+
children: label
|
|
193
|
+
}),
|
|
194
|
+
trailing && /* @__PURE__ */ jsx("span", {
|
|
195
|
+
className: "flex min-w-0 flex-1 items-center justify-end gap-1.5",
|
|
196
|
+
children: trailing
|
|
197
|
+
})
|
|
198
|
+
]
|
|
199
|
+
}),
|
|
200
|
+
children
|
|
201
|
+
]
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function WidgetRow2({ leading, color, children, trailing, className }) {
|
|
205
|
+
const size = useSize();
|
|
206
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
207
|
+
className: cn("flex h-7 min-w-0 items-center gap-2.5", SUBTITLE[size.variant], className),
|
|
208
|
+
children: [
|
|
209
|
+
leading !== undefined && /* @__PURE__ */ jsx("span", {
|
|
210
|
+
className: cn("w-15 shrink-0 whitespace-nowrap tabular-nums text-muted-foreground", CAPTION[size.variant]),
|
|
211
|
+
children: leading
|
|
212
|
+
}),
|
|
213
|
+
color && /* @__PURE__ */ jsx("span", {
|
|
214
|
+
"aria-hidden": true,
|
|
215
|
+
className: "h-3.5 w-0.75 shrink-0 rounded-full",
|
|
216
|
+
style: { backgroundColor: color }
|
|
217
|
+
}),
|
|
218
|
+
/* @__PURE__ */ jsx("span", {
|
|
219
|
+
className: "min-w-0 flex-1 truncate text-foreground",
|
|
220
|
+
children
|
|
221
|
+
}),
|
|
222
|
+
trailing && /* @__PURE__ */ jsx("span", {
|
|
223
|
+
className: cn("flex shrink-0 items-center gap-1 text-muted-foreground", CAPTION[size.variant]),
|
|
224
|
+
children: trailing
|
|
225
|
+
})
|
|
226
|
+
]
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
function WidgetChip2({ color, children }) {
|
|
230
|
+
const level = useLift(1);
|
|
231
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
232
|
+
className: cn("inline-flex h-5 min-w-0 items-center gap-1.5 rounded-full px-2 text-micro text-foreground", SURFACE_BG[level]),
|
|
233
|
+
children: [
|
|
234
|
+
color && /* @__PURE__ */ jsx("span", {
|
|
235
|
+
"aria-hidden": true,
|
|
236
|
+
className: "size-1.5 shrink-0 rounded-full",
|
|
237
|
+
style: { backgroundColor: color }
|
|
238
|
+
}),
|
|
239
|
+
/* @__PURE__ */ jsx("span", {
|
|
240
|
+
className: "min-w-0 truncate",
|
|
241
|
+
children
|
|
242
|
+
})
|
|
243
|
+
]
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
var Widget2 = Object.assign(function Widget({ media, aside, children, size, className }) {
|
|
247
|
+
const step = useSize(size);
|
|
248
|
+
return /* @__PURE__ */ jsx(SizeScope, {
|
|
249
|
+
size,
|
|
250
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
251
|
+
className: cn("@container flex w-full min-h-0 flex-col justify-center", className),
|
|
252
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
253
|
+
className: cn("flex w-full min-h-0 items-stretch", GAP[step.variant]),
|
|
254
|
+
children: [
|
|
255
|
+
media && /* @__PURE__ */ jsx("div", {
|
|
256
|
+
className: "flex shrink-0 items-center",
|
|
257
|
+
children: media
|
|
258
|
+
}),
|
|
259
|
+
/* @__PURE__ */ jsx("div", {
|
|
260
|
+
className: "flex min-w-0 flex-1 flex-col justify-center gap-1",
|
|
261
|
+
children
|
|
262
|
+
}),
|
|
263
|
+
aside && /* @__PURE__ */ jsx("div", {
|
|
264
|
+
className: cn("flex w-[42%] min-w-0 shrink-0 flex-col justify-center border-l border-border @max-[30rem]:hidden", ASIDE[step.variant]),
|
|
265
|
+
children: aside
|
|
266
|
+
})
|
|
267
|
+
]
|
|
268
|
+
})
|
|
269
|
+
})
|
|
270
|
+
});
|
|
271
|
+
}, {
|
|
272
|
+
Header: WidgetHeader2,
|
|
273
|
+
Title: WidgetTitle2,
|
|
274
|
+
Subtitle: WidgetSubtitle2,
|
|
275
|
+
Figure: WidgetFigure2,
|
|
276
|
+
Meta: WidgetMeta2,
|
|
277
|
+
MetaItem: WidgetMetaItem2,
|
|
278
|
+
Action: WidgetAction2,
|
|
279
|
+
Message: WidgetMessage2,
|
|
280
|
+
Section: WidgetSection2,
|
|
281
|
+
Row: WidgetRow2,
|
|
282
|
+
Chip: WidgetChip2
|
|
283
|
+
});
|
|
284
|
+
var widget_default = Widget2;
|
|
285
|
+
export { WidgetHeader2, WidgetTitle2, WidgetSubtitle2, WidgetFigure2, WidgetMetaItem2, WidgetMeta2, WidgetAction2, WidgetMessage2, WidgetSection2, WidgetRow2, WidgetChip2, Widget2, widget_default };
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Equalizer2
|
|
5
|
+
} from "./chunk-2f7zxrbk.js";
|
|
6
|
+
import {
|
|
7
|
+
MediaScrubber2
|
|
8
|
+
} from "./chunk-9xtcv3sy.js";
|
|
9
|
+
import {
|
|
10
|
+
IslandFlash2
|
|
11
|
+
} from "./chunk-ndf79pv5.js";
|
|
12
|
+
import {
|
|
13
|
+
widget_default
|
|
14
|
+
} from "./chunk-x7f3g82r.js";
|
|
15
|
+
import {
|
|
16
|
+
useStableArtwork2,
|
|
17
|
+
useArtworkTint2
|
|
18
|
+
} from "./chunk-w5h6ay93.js";
|
|
19
|
+
|
|
20
|
+
// blocks/activities/now-playing/index.tsx
|
|
21
|
+
import { useReduceMotion } from "@justanarthur/modo-ui/lib/reduced-motion";
|
|
22
|
+
import { useSize } from "@justanarthur/modo-ui/lib/size-context";
|
|
23
|
+
import { spring } from "@justanarthur/modo-ui/lib/springs";
|
|
24
|
+
import { SURFACE_BG } from "@justanarthur/modo-ui/lib/surface-classes";
|
|
25
|
+
import { useLift } from "@justanarthur/modo-ui/lib/surface-context";
|
|
26
|
+
import { useControllableState } from "@justanarthur/modo-ui/lib/use-controllable-state";
|
|
27
|
+
import { cn } from "@justanarthur/modo-ui/lib/utils";
|
|
28
|
+
import {
|
|
29
|
+
Airplay,
|
|
30
|
+
Disc3,
|
|
31
|
+
Headphones,
|
|
32
|
+
Heart,
|
|
33
|
+
Laptop,
|
|
34
|
+
Music,
|
|
35
|
+
Pause,
|
|
36
|
+
Play,
|
|
37
|
+
Repeat,
|
|
38
|
+
Repeat1,
|
|
39
|
+
Shuffle,
|
|
40
|
+
SkipBack,
|
|
41
|
+
SkipForward,
|
|
42
|
+
Speaker
|
|
43
|
+
} from "lucide-react";
|
|
44
|
+
import { motion } from "motion/react";
|
|
45
|
+
import { useState } from "react";
|
|
46
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
47
|
+
/*!
|
|
48
|
+
* Local addition: what's playing, in every form a notch app shows it.
|
|
49
|
+
* Rebuilt from Just Notch's now-playing plugin (`Player`, `Artwork`,
|
|
50
|
+
* `TrackFlash`) as presentational parts: the track and the commands come in
|
|
51
|
+
* as props.
|
|
52
|
+
*/
|
|
53
|
+
var OUTPUT_ICON = { "built-in": Laptop, headphones: Headphones, speaker: Speaker, airplay: Airplay };
|
|
54
|
+
var NEXT_REPEAT = { off: "all", all: "one", one: "off" };
|
|
55
|
+
var REPEAT_LABEL = {
|
|
56
|
+
off: "Repeat",
|
|
57
|
+
all: "Repeat all",
|
|
58
|
+
one: "Repeat one"
|
|
59
|
+
};
|
|
60
|
+
var keyOf = (track) => track ? track.id ?? [track.title, track.artist, track.album].join("\x00") : "";
|
|
61
|
+
function useTint(track) {
|
|
62
|
+
const read = useArtworkTint2(track?.tint || typeof track?.artwork !== "string" ? undefined : track.artwork);
|
|
63
|
+
return track?.tint ?? read;
|
|
64
|
+
}
|
|
65
|
+
function Picture({ art, glyph }) {
|
|
66
|
+
const level = useLift(1);
|
|
67
|
+
if (typeof art === "string")
|
|
68
|
+
return /* @__PURE__ */ jsx("img", {
|
|
69
|
+
alt: "",
|
|
70
|
+
src: art,
|
|
71
|
+
draggable: false,
|
|
72
|
+
className: "size-full object-cover"
|
|
73
|
+
});
|
|
74
|
+
if (art != null)
|
|
75
|
+
return art;
|
|
76
|
+
return /* @__PURE__ */ jsx("span", {
|
|
77
|
+
className: cn("flex size-full items-center justify-center text-muted-foreground", SURFACE_BG[level]),
|
|
78
|
+
children: /* @__PURE__ */ jsx(Music, {
|
|
79
|
+
size: glyph,
|
|
80
|
+
strokeWidth: 1.5
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function NowPlayingArtwork2({ track, glyph = 14, className }) {
|
|
85
|
+
const shown = useStableArtwork2(track?.artwork, keyOf(track));
|
|
86
|
+
const reduced = useReduceMotion();
|
|
87
|
+
const [top, setTop] = useState(shown);
|
|
88
|
+
const [under, setUnder] = useState(null);
|
|
89
|
+
if (top.id !== shown.id) {
|
|
90
|
+
setUnder(top);
|
|
91
|
+
setTop(shown);
|
|
92
|
+
}
|
|
93
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
94
|
+
className: cn("relative isolate block shrink-0 overflow-hidden", className),
|
|
95
|
+
children: [
|
|
96
|
+
under && /* @__PURE__ */ jsx("span", {
|
|
97
|
+
className: "absolute inset-0",
|
|
98
|
+
children: /* @__PURE__ */ jsx(Picture, {
|
|
99
|
+
art: under.art,
|
|
100
|
+
glyph
|
|
101
|
+
})
|
|
102
|
+
}, under.id),
|
|
103
|
+
/* @__PURE__ */ jsx(motion.span, {
|
|
104
|
+
className: "absolute inset-0",
|
|
105
|
+
initial: under ? { opacity: 0 } : false,
|
|
106
|
+
animate: { opacity: 1 },
|
|
107
|
+
transition: reduced ? spring.fast : spring.slow,
|
|
108
|
+
onAnimationComplete: () => setUnder(null),
|
|
109
|
+
children: /* @__PURE__ */ jsx(Picture, {
|
|
110
|
+
art: shown.art,
|
|
111
|
+
glyph
|
|
112
|
+
})
|
|
113
|
+
}, shown.id),
|
|
114
|
+
/* @__PURE__ */ jsx("span", {
|
|
115
|
+
"aria-hidden": true,
|
|
116
|
+
className: "pointer-events-none absolute inset-0 rounded-[inherit] ring-1 ring-border ring-inset"
|
|
117
|
+
})
|
|
118
|
+
]
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function TintedBars({ track, playing = true, className }) {
|
|
122
|
+
const tint = useTint(track);
|
|
123
|
+
return /* @__PURE__ */ jsx("span", {
|
|
124
|
+
className: cn("inline-flex text-foreground", className),
|
|
125
|
+
style: tint ? { color: tint } : undefined,
|
|
126
|
+
children: /* @__PURE__ */ jsx(Equalizer2, {
|
|
127
|
+
playing,
|
|
128
|
+
label: playing ? "Playing" : "Paused",
|
|
129
|
+
barClassName: "bg-current"
|
|
130
|
+
})
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function NowPlayingLeading2({ track }) {
|
|
134
|
+
return /* @__PURE__ */ jsx(NowPlayingArtwork2, {
|
|
135
|
+
track,
|
|
136
|
+
glyph: 12,
|
|
137
|
+
className: "size-5.5 rounded-md"
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function NowPlayingTrailing2(props) {
|
|
141
|
+
return /* @__PURE__ */ jsx(TintedBars, {
|
|
142
|
+
...props
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function NowPlayingMinimal2({ track }) {
|
|
146
|
+
return /* @__PURE__ */ jsx(NowPlayingArtwork2, {
|
|
147
|
+
track,
|
|
148
|
+
glyph: 12,
|
|
149
|
+
className: "size-6 rounded-full"
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function NowPlayingFlash2({ track, playing = true }) {
|
|
153
|
+
return /* @__PURE__ */ jsx(IslandFlash2, {
|
|
154
|
+
icon: /* @__PURE__ */ jsx(NowPlayingArtwork2, {
|
|
155
|
+
track,
|
|
156
|
+
className: "size-9 rounded-lg"
|
|
157
|
+
}),
|
|
158
|
+
title: track.title || "Unknown title",
|
|
159
|
+
caption: [track.artist, track.album].filter(Boolean).join(" — ") || track.source,
|
|
160
|
+
trailing: /* @__PURE__ */ jsx(TintedBars, {
|
|
161
|
+
track,
|
|
162
|
+
playing
|
|
163
|
+
})
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
var ART = { default: "size-36 rounded-2xl", compact: "size-28 rounded-xl" };
|
|
167
|
+
var NowPlaying2 = Object.assign(function NowPlaying({
|
|
168
|
+
track,
|
|
169
|
+
playing: playingProp,
|
|
170
|
+
defaultPlaying = true,
|
|
171
|
+
onPlayingChange,
|
|
172
|
+
onPrevious,
|
|
173
|
+
onNext,
|
|
174
|
+
onSeek,
|
|
175
|
+
shuffle: shuffleProp,
|
|
176
|
+
defaultShuffle,
|
|
177
|
+
onShuffleChange,
|
|
178
|
+
repeat: repeatProp,
|
|
179
|
+
defaultRepeat,
|
|
180
|
+
onRepeatChange,
|
|
181
|
+
liked: likedProp,
|
|
182
|
+
defaultLiked,
|
|
183
|
+
onLikedChange,
|
|
184
|
+
emptyDescription = "Play something in Music, Spotify or a browser and it shows up here.",
|
|
185
|
+
emptyActions,
|
|
186
|
+
className
|
|
187
|
+
}) {
|
|
188
|
+
const size = useSize();
|
|
189
|
+
const [playing, setPlaying] = useControllableState(playingProp, defaultPlaying, onPlayingChange);
|
|
190
|
+
const [shuffle, setShuffle] = useControllableState(shuffleProp, defaultShuffle ?? false, onShuffleChange);
|
|
191
|
+
const [repeat, setRepeat] = useControllableState(repeatProp, defaultRepeat ?? "off", onRepeatChange);
|
|
192
|
+
const [liked, setLiked] = useControllableState(likedProp, defaultLiked ?? false, onLikedChange);
|
|
193
|
+
const tint = useTint(track);
|
|
194
|
+
if (!track)
|
|
195
|
+
return /* @__PURE__ */ jsx(widget_default.Message, {
|
|
196
|
+
icon: Music,
|
|
197
|
+
title: "Nothing playing",
|
|
198
|
+
description: emptyDescription,
|
|
199
|
+
actions: emptyActions,
|
|
200
|
+
className
|
|
201
|
+
});
|
|
202
|
+
const showShuffle = shuffleProp !== undefined || defaultShuffle !== undefined || onShuffleChange !== undefined;
|
|
203
|
+
const showRepeat = repeatProp !== undefined || defaultRepeat !== undefined || onRepeatChange !== undefined;
|
|
204
|
+
const showLiked = likedProp !== undefined || defaultLiked !== undefined || onLikedChange !== undefined;
|
|
205
|
+
const byline = [track.artist, track.album].filter(Boolean).join(" — ");
|
|
206
|
+
return /* @__PURE__ */ jsx("div", {
|
|
207
|
+
className: cn("relative isolate flex w-full flex-col justify-center", className),
|
|
208
|
+
children: /* @__PURE__ */ jsxs(widget_default, {
|
|
209
|
+
media: /* @__PURE__ */ jsxs("span", {
|
|
210
|
+
className: "relative flex",
|
|
211
|
+
children: [
|
|
212
|
+
tint && /* @__PURE__ */ jsx("span", {
|
|
213
|
+
"aria-hidden": true,
|
|
214
|
+
className: "absolute -inset-x-8 -inset-y-4 -z-1 opacity-70",
|
|
215
|
+
style: { backgroundImage: `radial-gradient(closest-side, ${tint}, transparent)` }
|
|
216
|
+
}),
|
|
217
|
+
/* @__PURE__ */ jsx(NowPlayingArtwork2, {
|
|
218
|
+
track,
|
|
219
|
+
glyph: 28,
|
|
220
|
+
className: ART[size.variant]
|
|
221
|
+
})
|
|
222
|
+
]
|
|
223
|
+
}),
|
|
224
|
+
children: [
|
|
225
|
+
/* @__PURE__ */ jsxs("div", {
|
|
226
|
+
className: "flex min-w-0 items-start gap-3",
|
|
227
|
+
children: [
|
|
228
|
+
/* @__PURE__ */ jsxs("div", {
|
|
229
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
230
|
+
children: [
|
|
231
|
+
/* @__PURE__ */ jsx(widget_default.Title, {
|
|
232
|
+
children: track.title || "Unknown title"
|
|
233
|
+
}),
|
|
234
|
+
byline && /* @__PURE__ */ jsx(widget_default.Subtitle, {
|
|
235
|
+
children: byline
|
|
236
|
+
})
|
|
237
|
+
]
|
|
238
|
+
}),
|
|
239
|
+
/* @__PURE__ */ jsx(TintedBars, {
|
|
240
|
+
track,
|
|
241
|
+
playing,
|
|
242
|
+
className: "mt-1.5"
|
|
243
|
+
})
|
|
244
|
+
]
|
|
245
|
+
}),
|
|
246
|
+
track.duration > 0 && /* @__PURE__ */ jsx(MediaScrubber2, {
|
|
247
|
+
className: "mt-2",
|
|
248
|
+
quiet: true,
|
|
249
|
+
position: track.position,
|
|
250
|
+
duration: track.duration,
|
|
251
|
+
playing,
|
|
252
|
+
onSeek
|
|
253
|
+
}),
|
|
254
|
+
/* @__PURE__ */ jsxs("div", {
|
|
255
|
+
className: "grid grid-cols-[1fr_auto_1fr] items-center gap-2",
|
|
256
|
+
children: [
|
|
257
|
+
/* @__PURE__ */ jsxs(widget_default.Meta, {
|
|
258
|
+
children: [
|
|
259
|
+
track.source && /* @__PURE__ */ jsx(widget_default.MetaItem, {
|
|
260
|
+
icon: Disc3,
|
|
261
|
+
children: track.source
|
|
262
|
+
}),
|
|
263
|
+
track.output && /* @__PURE__ */ jsx(widget_default.MetaItem, {
|
|
264
|
+
icon: OUTPUT_ICON[track.outputKind ?? "built-in"],
|
|
265
|
+
children: track.output
|
|
266
|
+
})
|
|
267
|
+
]
|
|
268
|
+
}),
|
|
269
|
+
/* @__PURE__ */ jsxs("div", {
|
|
270
|
+
className: "flex items-center gap-1",
|
|
271
|
+
children: [
|
|
272
|
+
/* @__PURE__ */ jsx(widget_default.Action, {
|
|
273
|
+
icon: SkipBack,
|
|
274
|
+
label: "Previous",
|
|
275
|
+
filled: true,
|
|
276
|
+
onClick: onPrevious
|
|
277
|
+
}),
|
|
278
|
+
/* @__PURE__ */ jsx(widget_default.Action, {
|
|
279
|
+
icon: playing ? Pause : Play,
|
|
280
|
+
label: playing ? "Pause" : "Play",
|
|
281
|
+
emphasis: "primary",
|
|
282
|
+
filled: true,
|
|
283
|
+
onClick: () => setPlaying(!playing)
|
|
284
|
+
}),
|
|
285
|
+
/* @__PURE__ */ jsx(widget_default.Action, {
|
|
286
|
+
icon: SkipForward,
|
|
287
|
+
label: "Next",
|
|
288
|
+
filled: true,
|
|
289
|
+
onClick: onNext
|
|
290
|
+
})
|
|
291
|
+
]
|
|
292
|
+
}),
|
|
293
|
+
/* @__PURE__ */ jsxs("div", {
|
|
294
|
+
className: "flex items-center justify-end",
|
|
295
|
+
children: [
|
|
296
|
+
showShuffle && /* @__PURE__ */ jsx(widget_default.Action, {
|
|
297
|
+
icon: Shuffle,
|
|
298
|
+
label: "Shuffle",
|
|
299
|
+
pressed: shuffle,
|
|
300
|
+
color: tint,
|
|
301
|
+
onClick: () => setShuffle(!shuffle)
|
|
302
|
+
}),
|
|
303
|
+
showRepeat && /* @__PURE__ */ jsx(widget_default.Action, {
|
|
304
|
+
icon: repeat === "one" ? Repeat1 : Repeat,
|
|
305
|
+
label: REPEAT_LABEL[repeat],
|
|
306
|
+
pressed: repeat !== "off",
|
|
307
|
+
color: tint,
|
|
308
|
+
onClick: () => setRepeat(NEXT_REPEAT[repeat])
|
|
309
|
+
}),
|
|
310
|
+
showLiked && /* @__PURE__ */ jsx(widget_default.Action, {
|
|
311
|
+
icon: Heart,
|
|
312
|
+
label: liked ? "Remove from library" : "Add to library",
|
|
313
|
+
pressed: liked,
|
|
314
|
+
filled: liked,
|
|
315
|
+
color: tint,
|
|
316
|
+
onClick: () => setLiked(!liked)
|
|
317
|
+
})
|
|
318
|
+
]
|
|
319
|
+
})
|
|
320
|
+
]
|
|
321
|
+
})
|
|
322
|
+
]
|
|
323
|
+
})
|
|
324
|
+
});
|
|
325
|
+
}, {
|
|
326
|
+
Artwork: NowPlayingArtwork2,
|
|
327
|
+
Leading: NowPlayingLeading2,
|
|
328
|
+
Trailing: NowPlayingTrailing2,
|
|
329
|
+
Minimal: NowPlayingMinimal2,
|
|
330
|
+
Flash: NowPlayingFlash2
|
|
331
|
+
});
|
|
332
|
+
var now_playing_default = NowPlaying2;
|
|
333
|
+
export { NowPlayingArtwork2, NowPlayingLeading2, NowPlayingTrailing2, NowPlayingMinimal2, NowPlayingFlash2, NowPlaying2, now_playing_default };
|