From 75e50af338d8564ff71f2981c08e92de5073b5f9 Mon Sep 17 00:00:00 2001 From: jainiksha Date: Fri, 19 Jun 2026 13:03:34 +0530 Subject: [PATCH] feat: add terminal theme editor with live preview --- packages/ui/src/ThemeEditor.ts | 50 ++++++++++++++++++++++++++++++++++ packages/ui/src/index.ts | 3 ++ 2 files changed, 53 insertions(+) create mode 100644 packages/ui/src/ThemeEditor.ts diff --git a/packages/ui/src/ThemeEditor.ts b/packages/ui/src/ThemeEditor.ts new file mode 100644 index 00000000..ef3d705e --- /dev/null +++ b/packages/ui/src/ThemeEditor.ts @@ -0,0 +1,50 @@ +export interface ThemeConfig { + foreground: string; + background: string; + primary: string; + secondary: string; +} + +export class ThemeEditor { + private theme: ThemeConfig; + + constructor(initialTheme?: Partial) { + this.theme = { + foreground: "#ffffff", + background: "#000000", + primary: "#00ff00", + secondary: "#888888", + ...initialTheme, + }; + } + + setColor( + key: keyof ThemeConfig, + value: string + ): void { + this.theme[key] = value; + } + + getTheme(): ThemeConfig { + return this.theme; + } + + preview(): string { + return ` +Theme Preview +------------- +Foreground: ${this.theme.foreground} +Background: ${this.theme.background} +Primary: ${this.theme.primary} +Secondary: ${this.theme.secondary} +`; + } + + exportTheme(): string { + return JSON.stringify(this.theme, null, 2); + } + + importTheme(json: string): void { + this.theme = JSON.parse(json); + } +} \ No newline at end of file diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts index 1cbbb0b8..ddc6ecbe 100644 --- a/packages/ui/src/index.ts +++ b/packages/ui/src/index.ts @@ -252,3 +252,6 @@ export { ChatThread } from './ChatThread.js'; export type { ChatThreadOptions } from './ChatThread.js'; export { TokenUsage } from './TokenUsage.js'; export type { TokenUsageOptions } from './TokenUsage.js'; + +export { ThemeEditor } from "./ThemeEditor.js"; +export type { ThemeConfig } from "./ThemeEditor.js"; \ No newline at end of file