Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "anywidget-archimate"
version = "0.1.3"
version = "0.1.4"
description = "Interactive ArchiMate model viewer widget for Jupyter, Marimo, and VS Code notebooks"
readme = "README.md"
license = "Apache-2.0"
Expand Down
24 changes: 24 additions & 0 deletions src/anywidget_archimate/ui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,30 @@ function render({ model, el }) {
wrapper.className = "aam-wrapper";
el.appendChild(wrapper);

// Auto-detect host theme (marimo uses Tailwind class="dark" on <html>)
function detectHostDark() {
const html = document.documentElement;
if (html.classList.contains("dark")) return true;
if (html.dataset.theme === "dark") return true;
if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) return true;
return false;
}

const hasHostTheme = !!el.getRootNode()?.host?.tagName?.startsWith("MARIMO-");
if (hasHostTheme) {
wrapper.classList.add("aam-auto-theme");
model.set("dark_mode", detectHostDark());
model.save_changes();
const themeObserver = new MutationObserver(() => {
const dark = detectHostDark();
if (model.get("dark_mode") !== dark) {
model.set("dark_mode", dark);
model.save_changes();
}
});
themeObserver.observe(document.documentElement, { attributes: true, attributeFilter: ["class", "data-theme"] });
}

const toolbar = document.createElement("div");
toolbar.className = "aam-toolbar";
toolbar.innerHTML = `
Expand Down
41 changes: 24 additions & 17 deletions src/anywidget_archimate/ui/styles.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
/* anywidget-archimate styles */

/* Light mode (matches marimo light) */
.aam-wrapper {
--aam-bg: #ffffff;
--aam-text: #111827;
--aam-border: #e5e7eb;
--aam-toolbar-bg: #f9fafb;
--aam-btn-bg: #f3f4f6;
--aam-btn-hover: #e5e7eb;
--aam-graph-bg: #fdfdfd;
--aam-detail-bg: #f9fafb;
--aam-panel-bg: #f9fafb;
--aam-text: #0f172a;
--aam-border: #e2e8f0;
--aam-toolbar-bg: #f8f9fa;
--aam-btn-bg: #f1f5f9;
--aam-btn-hover: #e2e8f0;
--aam-graph-bg: #ffffff;
--aam-detail-bg: #f8f9fa;
--aam-panel-bg: #f8f9fa;
--aam-panel-width: 220px;

font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
Expand All @@ -23,16 +24,17 @@
flex-direction: column;
}

/* Dark mode (matches marimo dark) */
.aam-wrapper.aam-dark {
--aam-bg: #1a1a2e;
--aam-text: #e0e0e0;
--aam-border: #333355;
--aam-toolbar-bg: #16162a;
--aam-btn-bg: #2a2a4a;
--aam-btn-hover: #3a3a5a;
--aam-graph-bg: #1e1e3a;
--aam-detail-bg: #22223a;
--aam-panel-bg: #16162a;
--aam-bg: #181c1a;
--aam-text: #eceeed;
--aam-border: #3b403e;
--aam-toolbar-bg: #1f2321;
--aam-btn-bg: #252927;
--aam-btn-hover: #3b403e;
--aam-graph-bg: #181c1a;
--aam-detail-bg: #252927;
--aam-panel-bg: #1f2321;
}

/* Toolbar */
Expand Down Expand Up @@ -396,3 +398,8 @@
border-radius: 3px;
font-size: 12px;
}

/* Hide dark mode button when host provides theme */
.aam-wrapper.aam-auto-theme .aam-btn-dark {
display: none;
}
Loading