Skip to content

Commit ff01ca8

Browse files
committed
Update docs apps filter field based on theme
1 parent d69773c commit ff01ca8

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

.claude/CLAUDE-KNOWLEDGE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,3 +400,6 @@ A: Root `dev` starts the OpenAPI docs watcher at the same time as package `dev`
400400

401401
## Q: How do SDK source tests replace the compile-time client version sentinel?
402402
A: `packages/template/vitest.config.ts` installs a Vite transform plugin for Vitest that replaces `STACK_COMPILE_TIME_CLIENT_PACKAGE_VERSION_SENTINEL` with `js <package-name>@<version>` from the local package.json. Keep the plugin in `packages/template` so `pnpm pre`/`scripts/generate-sdks.ts` propagates it to `packages/js`, `packages/react`, and `packages/stack`; otherwise tests importing `common.ts` throw `Client version was not replaced` before test collection.
403+
404+
## Q: How does the Mintlify apps sidebar filter stay in sync with theme changes?
405+
A: `docs-mintlify/apps-sidebar-filter.js` injects the Apps filter with inline styles, so the MutationObserver must reapply `applySidebarAppsFilterTheme` when an existing input is found. Theme detection should handle both `html.dark` and `data-theme="dark"` signals.

docs-mintlify/apps-sidebar-filter.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,16 @@
22
const SEARCH_ATTRIBUTE = "data-apps-sidebar-search";
33
const EMPTY_ATTRIBUTE = "data-apps-sidebar-empty";
44

5+
function isPageDarkTheme() {
6+
const body = document.body;
7+
return document.documentElement.classList.contains("dark")
8+
|| document.documentElement.getAttribute("data-theme") === "dark"
9+
|| body?.classList.contains("dark") === true
10+
|| body?.getAttribute("data-theme") === "dark";
11+
}
12+
513
function applySidebarAppsFilterTheme(searchInput, emptyState, clearFilterButton) {
6-
const isDark = document.documentElement.classList.contains("dark");
14+
const isDark = isPageDarkTheme();
715
searchInput.style.background = isDark ? "rgba(17,24,39,0.72)" : "rgba(248,250,252,0.98)";
816
searchInput.style.color = isDark ? "#e5e7eb" : "#111827";
917
searchInput.style.border = isDark ? "1px solid rgba(75,85,99,0.9)" : "1px solid rgba(203,213,225,0.95)";
@@ -29,7 +37,13 @@
2937
return false;
3038
}
3139

32-
if (appsHeader.querySelector(`[${SEARCH_ATTRIBUTE}="true"]`) != null) {
40+
const existingSearchInput = appsHeader.querySelector(`input[${SEARCH_ATTRIBUTE}="true"]`);
41+
if (existingSearchInput != null) {
42+
const existingEmptyState = appsGroupContainer.querySelector(`div[${EMPTY_ATTRIBUTE}="true"]`);
43+
const existingClearFilterButton = existingEmptyState?.querySelector("button");
44+
if (existingEmptyState != null && existingClearFilterButton != null) {
45+
applySidebarAppsFilterTheme(existingSearchInput, existingEmptyState, existingClearFilterButton);
46+
}
3347
return true;
3448
}
3549

@@ -126,6 +140,6 @@
126140
if (typeof window !== "undefined" && typeof document !== "undefined") {
127141
window.requestAnimationFrame(installWhenReady);
128142
const observer = new MutationObserver(() => installAppsSidebarFilter());
129-
observer.observe(document.documentElement, { childList: true, subtree: true, attributes: true, attributeFilter: ["class"] });
143+
observer.observe(document.documentElement, { childList: true, subtree: true, attributes: true, attributeFilter: ["class", "data-theme"] });
130144
}
131145
})();

0 commit comments

Comments
 (0)