|
2 | 2 | const SEARCH_ATTRIBUTE = "data-apps-sidebar-search"; |
3 | 3 | const EMPTY_ATTRIBUTE = "data-apps-sidebar-empty"; |
4 | 4 |
|
| 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 | + |
5 | 13 | function applySidebarAppsFilterTheme(searchInput, emptyState, clearFilterButton) { |
6 | | - const isDark = document.documentElement.classList.contains("dark"); |
| 14 | + const isDark = isPageDarkTheme(); |
7 | 15 | searchInput.style.background = isDark ? "rgba(17,24,39,0.72)" : "rgba(248,250,252,0.98)"; |
8 | 16 | searchInput.style.color = isDark ? "#e5e7eb" : "#111827"; |
9 | 17 | searchInput.style.border = isDark ? "1px solid rgba(75,85,99,0.9)" : "1px solid rgba(203,213,225,0.95)"; |
|
29 | 37 | return false; |
30 | 38 | } |
31 | 39 |
|
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 | + } |
33 | 47 | return true; |
34 | 48 | } |
35 | 49 |
|
|
126 | 140 | if (typeof window !== "undefined" && typeof document !== "undefined") { |
127 | 141 | window.requestAnimationFrame(installWhenReady); |
128 | 142 | 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"] }); |
130 | 144 | } |
131 | 145 | })(); |
0 commit comments