feat: add light/dark theme to exchange instances with hub SSO sync
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -56,6 +56,9 @@
|
||||
const next = nextPath || "/";
|
||||
const q = new URLSearchParams({ exchange_id: String(exchangeId), next });
|
||||
if (options.embed) q.set("embed", "1");
|
||||
if (globalThis.HubTheme && typeof HubTheme.get === "function") {
|
||||
q.set("hub_theme", HubTheme.get());
|
||||
}
|
||||
const r = await apiFetch("/api/instance/open-url?" + q.toString());
|
||||
const j = await r.json();
|
||||
if (!j.ok || !j.url) {
|
||||
@@ -135,6 +138,16 @@
|
||||
shell.classList.remove("hidden");
|
||||
shell.setAttribute("aria-hidden", "false");
|
||||
document.body.classList.add("hub-instance-frame-open");
|
||||
frame.addEventListener("load", function syncInstanceFrameTheme() {
|
||||
try {
|
||||
if (globalThis.HubTheme && typeof HubTheme.get === "function" && frame.contentWindow) {
|
||||
frame.contentWindow.postMessage(
|
||||
{ type: "hub-theme-sync", theme: HubTheme.get() },
|
||||
"*"
|
||||
);
|
||||
}
|
||||
} catch (_) {}
|
||||
});
|
||||
}
|
||||
|
||||
function closeInstanceFrame() {
|
||||
|
||||
Reference in New Issue
Block a user