fix(app): remove oc-1 theme

This commit is contained in:
Adam
2026-03-09 08:25:34 -05:00
parent 5cc61e1b53
commit 6388cbaf92
7 changed files with 126 additions and 50 deletions

View File

@@ -16,6 +16,15 @@ const STORAGE_KEYS = {
const THEME_STYLE_ID = "oc-theme"
function normalize(id: string | null | undefined) {
return id === "oc-1" ? "oc-2" : id
}
function clear() {
localStorage.removeItem(STORAGE_KEYS.THEME_CSS_LIGHT)
localStorage.removeItem(STORAGE_KEYS.THEME_CSS_DARK)
}
function ensureThemeStyleElement(): HTMLStyleElement {
const existing = document.getElementById(THEME_STYLE_ID) as HTMLStyleElement | null
if (existing) return existing
@@ -71,7 +80,7 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
init: (props: { defaultTheme?: string }) => {
const [store, setStore] = createStore({
themes: DEFAULT_THEMES as Record<string, DesktopTheme>,
themeId: props.defaultTheme ?? "oc-2",
themeId: normalize(props.defaultTheme) ?? "oc-2",
colorScheme: "system" as ColorScheme,
mode: getSystemMode(),
previewThemeId: null as string | null,
@@ -89,9 +98,14 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
onCleanup(() => mediaQuery.removeEventListener("change", handler))
const savedTheme = localStorage.getItem(STORAGE_KEYS.THEME_ID)
const themeId = normalize(savedTheme)
const savedScheme = localStorage.getItem(STORAGE_KEYS.COLOR_SCHEME) as ColorScheme | null
if (savedTheme && store.themes[savedTheme]) {
setStore("themeId", savedTheme)
if (themeId && store.themes[themeId]) {
setStore("themeId", themeId)
}
if (savedTheme && themeId && savedTheme !== themeId) {
localStorage.setItem(STORAGE_KEYS.THEME_ID, themeId)
clear()
}
if (savedScheme) {
setStore("colorScheme", savedScheme)
@@ -113,14 +127,23 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
})
const setTheme = (id: string) => {
const theme = store.themes[id]
const next = normalize(id)
if (!next) {
console.warn(`Theme "${id}" not found`)
return
}
const theme = store.themes[next]
if (!theme) {
console.warn(`Theme "${id}" not found`)
return
}
setStore("themeId", id)
localStorage.setItem(STORAGE_KEYS.THEME_ID, id)
cacheThemeVariants(theme, id)
setStore("themeId", next)
localStorage.setItem(STORAGE_KEYS.THEME_ID, next)
if (next === "oc-2") {
clear()
return
}
cacheThemeVariants(theme, next)
}
const setColorScheme = (scheme: ColorScheme) => {
@@ -138,15 +161,17 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
setColorScheme,
registerTheme: (theme: DesktopTheme) => setStore("themes", theme.id, theme),
previewTheme: (id: string) => {
const theme = store.themes[id]
const next = normalize(id)
if (!next) return
const theme = store.themes[next]
if (!theme) return
setStore("previewThemeId", id)
setStore("previewThemeId", next)
const previewMode = store.previewScheme
? store.previewScheme === "system"
? getSystemMode()
: store.previewScheme
: store.mode
applyThemeCss(theme, id, previewMode)
applyThemeCss(theme, next, previewMode)
},
previewColorScheme: (scheme: ColorScheme) => {
setStore("previewScheme", scheme)

View File

@@ -1,5 +1,4 @@
import type { DesktopTheme } from "./types"
import oc1ThemeJson from "./themes/oc-1.json"
import oc2ThemeJson from "./themes/oc-2.json"
import tokyoThemeJson from "./themes/tokyonight.json"
import draculaThemeJson from "./themes/dracula.json"
@@ -16,7 +15,6 @@ import carbonfoxThemeJson from "./themes/carbonfox.json"
import gruvboxThemeJson from "./themes/gruvbox.json"
import auraThemeJson from "./themes/aura.json"
export const oc1Theme = oc1ThemeJson as DesktopTheme
export const oc2Theme = oc2ThemeJson as DesktopTheme
export const tokyonightTheme = tokyoThemeJson as DesktopTheme
export const draculaTheme = draculaThemeJson as DesktopTheme
@@ -35,7 +33,6 @@ export const auraTheme = auraThemeJson as DesktopTheme
export const DEFAULT_THEMES: Record<string, DesktopTheme> = {
"oc-2": oc2Theme,
"oc-1": oc1Theme,
aura: auraTheme,
ayu: ayuTheme,
carbonfox: carbonfoxTheme,

View File

@@ -35,7 +35,6 @@ export { ThemeProvider, useTheme, type ColorScheme } from "./context"
export {
DEFAULT_THEMES,
oc1Theme,
oc2Theme,
tokyonightTheme,
draculaTheme,

View File

@@ -1,35 +0,0 @@
{
"$schema": "https://opencode.ai/desktop-theme.json",
"name": "OC-1",
"id": "oc-1",
"light": {
"palette": {
"neutral": "#8e8b8b",
"ink": "#656363",
"primary": "#dcde8d",
"accent": "#fb4804",
"success": "#12c905",
"warning": "#ffdc17",
"error": "#fc533a",
"info": "#a753ae",
"interactive": "#034cff",
"diffAdd": "#9ff29a",
"diffDelete": "#fc533a"
}
},
"dark": {
"palette": {
"neutral": "#716c6b",
"ink": "#b7b1b1",
"primary": "#fab283",
"accent": "#ffba92",
"success": "#12c905",
"warning": "#fcd53a",
"error": "#fc533a",
"info": "#edb2f1",
"interactive": "#034cff",
"diffAdd": "#c8ffc4",
"diffDelete": "#fc533a"
}
}
}