T44d Web · Stories stand alone: nested ones surface, hidden ones drop their demos, early themes land, pastes arrive
This commit is contained in:
1 parent
edab58e91a
commit
2463bb0ac9
22 files changed
+352
-172
No files matched your search
@@ -16,16 +16,22 @@
|
||||
</script>
|
||||
<script type="module">
|
||||
import init, { set_theme } from "./gallery.js";
|
||||
await init();
|
||||
// The host switches the mode later: gallery.setTheme("dark"), or a message { ely: "theme", theme }.
|
||||
// The host sets the mode with gallery.setTheme(mode) or a message { ely: "theme", theme }, early or late.
|
||||
let early = null;
|
||||
let apply = (theme) => { early = theme; };
|
||||
const setTheme = (theme) => {
|
||||
set_theme(theme);
|
||||
apply(theme);
|
||||
document.documentElement.classList.toggle("dark", theme === "dark");
|
||||
};
|
||||
window.gallery = { setTheme };
|
||||
addEventListener("message", ({ data }) => {
|
||||
if (data && data.ely === "theme") setTheme(data.theme);
|
||||
});
|
||||
await init();
|
||||
apply = set_theme;
|
||||
if (early) set_theme(early);
|
||||
// A host that waits for this knows the mode it sends lands.
|
||||
window.parent.postMessage({ ely: "ready" }, "*");
|
||||
</script>
|
||||
</head>
|
||||
<body></body>
|
||||
|
||||
Reference in new issue
Block a user