feat(theme): extract TUI theme package (#39378)

This commit is contained in:
James Long 2026-07-28 14:14:39 -04:00 committed by GitHub
commit c445d98188
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 419 additions and 235 deletions

View file

@ -1,11 +1,8 @@
import { expect, test } from "bun:test"
import { createSignal } from "solid-js"
import { RGBA } from "@opentui/core"
import { createComponentTheme } from "../../../src/theme/v2/component"
import { DEFAULT_THEME } from "../../../src/theme/v2/defaults"
import { resolveTheme } from "../../../src/theme/v2/resolve"
import { selectTheme } from "../../../src/theme/v2/select"
import type { ContextKey } from "../../../src/theme/v2"
import { DEFAULT_THEME, resolveTheme, selectTheme, type ContextKey } from "@opencode-ai/theme/tui"
import { createComponentTheme } from "../../../src/theme/component"
test("provides reactive properties, states, contexts, and color operations", () => {
const [resolved, setResolved] = createSignal(resolveTheme(selectTheme(DEFAULT_THEME, "light")))

View file

@ -1,10 +1,14 @@
import { expect, test } from "bun:test"
import { RGBA } from "@opentui/core"
import {
DEFAULT_THEME,
resolveTheme,
resolveThemeDocument,
selectTheme,
type Mode,
type ThemeDefinition,
} from "@opencode-ai/theme/tui"
import { parseTheme, type ThemeDocumentSource } from "../../../src/theme"
import { DEFAULT_THEME } from "../../../src/theme/v2/defaults"
import type { Mode, ThemeDefinition } from "../../../src/theme/v2"
import { resolveTheme, resolveThemeDocument } from "../../../src/theme/v2/resolve"
import { selectTheme } from "../../../src/theme/v2/select"
const light = selectTheme(DEFAULT_THEME, "light")
const dark = selectTheme(DEFAULT_THEME, "dark")

View file

@ -1,6 +1,13 @@
import { expect, test } from "bun:test"
import type { HueDefinition, ThemeDefinition, ThemeDocument } from "../../../src/theme/v2"
import { selectTheme, selectThemeMode, supportsThemeMode, themeModes } from "../../../src/theme/v2/select"
import {
selectTheme,
selectThemeMode,
supportsThemeMode,
themeModes,
type HueDefinition,
type ThemeDefinition,
type ThemeDocument,
} from "@opencode-ai/theme/tui"
const hue = {} as HueDefinition
const light = { hue, categorical: ["blue"], text: { default: "#111111", subdued: "#222222" } } satisfies ThemeDefinition

View file

@ -1,5 +1,5 @@
import { expect, test } from "bun:test"
import type { BackgroundDefinition, TextDefinition, ThemeDefinition, ThemeDocument } from "../../../src/theme/v2"
import type { BackgroundDefinition, TextDefinition, ThemeDefinition, ThemeDocument } from "@opencode-ai/theme/tui"
const text = {
default: "$hue.neutral.900",

View file

@ -1,9 +1,13 @@
import { expect, test } from "bun:test"
import {
DEFAULT_CATEGORICAL,
DEFAULT_THEME,
migrateV1,
resolveThemeDocument,
selectThemeMode,
themeModes,
} from "@opencode-ai/theme/tui"
import { DEFAULT_THEMES, resolveTheme as resolveV1 } from "../../../src/theme"
import { resolveThemeDocument } from "../../../src/theme/v2/resolve"
import { selectThemeMode, themeModes } from "../../../src/theme/v2/select"
import { migrateV1 } from "../../../src/theme/v2/v1-migrate"
import { DEFAULT_CATEGORICAL, DEFAULT_THEME } from "../../../src/theme/v2/defaults"
test("migrates resolved V1 modes into V2 tokens", () => {
const migrated = migrateV1(DEFAULT_THEMES.opencode)