···
5
5
<Page title="Diffuse">
6
6
<script src="../../../scripts/themes/pilot/index.js"></script>
7
7
8
8
+
<!-- Temporary filler to push audio UI down to the bottom -->
9
9
+
<div class="filler" style="flex: 1;"></div>
10
10
+
8
11
<!-- Theme applets -->
9
12
<iframe id="applet__ui__audio" src="ui/audio/" frameborder="0"></iframe>
10
13
···
20
20
reactive(
21
21
ui.audio,
22
22
"isPlaying",
23
23
-
(isPlaying: boolean) => engine.audio.sendAction(isPlaying ? "play" : "pause", null),
23
23
+
(isPlaying: boolean) =>
24
24
+
engine.audio.sendAction(isPlaying ? "play" : "pause", null),
24
25
);
25
26
26
27
reactive(
···
49
50
}
50
51
51
52
const applet = await applets.connect(frame.contentWindow);
53
53
+
52
54
if (opts.setHeight) {
53
53
-
applet.onresize = () => (frame.height = `${applet.height}px`);
55
55
+
applet.onresize = () => {
56
56
+
frame.height = `${applet.height}px`;
57
57
+
frame.classList.add("has-loaded");
58
58
+
};
59
59
+
} else {
60
60
+
if (frame.contentDocument?.readyState === "complete") {
61
61
+
frame.classList.add("has-loaded");
62
62
+
}
63
63
+
64
64
+
frame.addEventListener("load", () => {
65
65
+
frame.classList.add("has-loaded");
66
66
+
});
54
67
}
55
68
56
69
return applet;
···
60
73
// 🔮 Reactive state management
61
74
////////////////////////////////////////////
62
75
// TODO: Applet should have a subtype
63
63
-
function reactive<T>(applet: Applet, property: string, effectFn: (t: T) => void) {
76
76
+
function reactive<T>(
77
77
+
applet: Applet,
78
78
+
property: string,
79
79
+
effectFn: (t: T) => void,
80
80
+
) {
64
81
const [getter, setter] = signal(
65
82
(applet.data as any)[property] as T,
66
83
);
···
22
22
background-color: var(--delicate-cloud);
23
23
color: var(--made-in-the-shade);
24
24
display: flex;
25
25
+
flex-direction: column;
25
26
overflow: hidden;
26
27
height: 100dvh;
27
28
}
···
30
31
* Applets (UI)
31
32
***********************************/
32
33
#applet__ui__audio {
33
33
-
align-self: flex-end;
34
34
+
opacity: 0;
35
35
+
pointer-events: none;
36
36
+
transition: 375ms opacity;
37
37
+
transition-delay: 250ms;
34
38
width: 100%;
39
39
+
40
40
+
&.has-loaded {
41
41
+
opacity: 1;
42
42
+
pointer-events: initial;
43
43
+
}
35
44
}
36
45
37
46
/***********************************