fix(app): line selection colors

This commit is contained in:
adamelmore
2026-01-25 19:07:19 -06:00
parent fbcf138526
commit 5369e96ab7
4 changed files with 90 additions and 9 deletions

View File

@@ -102,6 +102,19 @@ export function Diff<T>(props: DiffProps<T>) {
return root
}
const applyScheme = () => {
const host = container.querySelector("diffs-container")
if (!(host instanceof HTMLElement)) return
const scheme = document.documentElement.dataset.colorScheme
if (scheme === "dark" || scheme === "light") {
host.dataset.colorScheme = scheme
return
}
host.removeAttribute("data-color-scheme")
}
const notifyRendered = () => {
if (!local.onRendered) return
@@ -488,10 +501,24 @@ export function Diff<T>(props: DiffProps<T>) {
containerWrapper: container,
})
applyScheme()
setRendered((value) => value + 1)
notifyRendered()
})
createEffect(() => {
if (typeof document === "undefined") return
if (typeof MutationObserver === "undefined") return
const root = document.documentElement
const monitor = new MutationObserver(() => applyScheme())
monitor.observe(root, { attributes: true, attributeFilter: ["data-color-scheme"] })
applyScheme()
onCleanup(() => monitor.disconnect())
})
createEffect(() => {
rendered()
const ranges = local.commentedLines ?? []