Skip to content
Open
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
9 changes: 3 additions & 6 deletions app/components/Terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useEffect, useRef, useState } from 'react'

import { DirectionDownIcon, DirectionUpIcon } from '@oxide/design-system/icons/react'

import { subscribeToTheme } from '~/stores/theme'
import { classed } from '~/util/classed'

import { AttachAddon } from './AttachAddon'
Expand Down Expand Up @@ -110,16 +111,12 @@ export function Terminal({ ws }: TerminalProps) {
// Update terminal colors when the theme changes. getComputedStyle in
// getTheme() forces a synchronous style recalc, so the CSS custom
// properties already reflect the new theme by the time we read them.
const observer = new MutationObserver(() => {
const unsubscribe = subscribeToTheme(() => {
newTerm.options.theme = getTheme()
})
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ['data-theme'],
})

return () => {
observer.disconnect()
unsubscribe()
newTerm.dispose()
window.removeEventListener('resize', resize)
}
Expand Down
Loading
Loading