summaryrefslogtreecommitdiffhomepage
path: root/packages/ui/src/components/diff.tsx
diff options
context:
space:
mode:
authoradamelmore <[email protected]>2026-01-25 19:07:19 -0600
committeradamelmore <[email protected]>2026-01-25 19:07:24 -0600
commit5369e96ab70b88abf1492c50f191dcf9e3bb7108 (patch)
tree466c39d6d5ff44a445a432d18033511eadab7058 /packages/ui/src/components/diff.tsx
parentfbcf13852658750bc3e5ba4d7114f7411f61a772 (diff)
downloadopencode-5369e96ab70b88abf1492c50f191dcf9e3bb7108.tar.gz
opencode-5369e96ab70b88abf1492c50f191dcf9e3bb7108.zip
fix(app): line selection colors
Diffstat (limited to 'packages/ui/src/components/diff.tsx')
-rw-r--r--packages/ui/src/components/diff.tsx27
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/ui/src/components/diff.tsx b/packages/ui/src/components/diff.tsx
index 2fb2ea3bc..c97744a9f 100644
--- a/packages/ui/src/components/diff.tsx
+++ b/packages/ui/src/components/diff.tsx
@@ -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,11 +501,25 @@ 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 ?? []
requestAnimationFrame(() => applyCommentedLines(ranges))