Skip to content

Commit a76ebd8

Browse files
omnimodeclaude
andcommitted
feat(theme): add Cobalto brand theme and set as default
Introduces a new "Cobalto" theme using the organization's brand colors: - Light: white surface (#ffffff), cobalt blue primary (anomalyco#1391), deep navy text (#070E46) - Dark: dark navy surface (#070E46), bright blue primary (#4d6aff), soft blue-white text (#c8d4ff) Registers the theme in default-themes.ts and sets it as the default for the web app, replacing oc-2 as the fallback in preload and context. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
1 parent 511c2e5 commit a76ebd8

5 files changed

Lines changed: 103 additions & 9 deletions

File tree

‎packages/app/public/oc-theme-preload.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
;(function () {
22
var key = "opencode-theme-id"
3-
var themeId = localStorage.getItem(key) || "oc-2"
3+
var themeId = localStorage.getItem(key) || "cobalto"
44

55
if (themeId === "oc-1") {
66
themeId = "oc-2"
@@ -20,7 +20,7 @@
2020
var metas = document.querySelectorAll("meta[name='theme-color']")
2121
if (metas.length > 0) metas[0].setAttribute("content", isDark ? "#131010" : "#F8F7F7")
2222

23-
if (themeId === "oc-2") return
23+
if (themeId === "oc-2" || themeId === "cobalto") return
2424

2525
var css = localStorage.getItem("opencode-theme-css-" + mode)
2626
if (css) {

‎packages/ui/src/theme/context.tsx‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { createStore } from "solid-js/store"
33
import { makeEventListener } from "@solid-primitives/event-listener"
44
import { createSimpleContext } from "../context/helper"
55
import oc2ThemeJson from "./themes/oc-2.json"
6+
import cobaltoBrandThemeJson from "./themes/cobalto.json"
67
import { resolveThemeVariant, themeToCss } from "./resolve"
78
import type { DesktopTheme } from "./types"
89

@@ -41,6 +42,7 @@ function knownThemes() {
4142
}
4243

4344
const names: Record<string, string> = {
45+
cobalto: "Cobalto",
4446
"oc-2": "OC-2",
4547
amoled: "AMOLED",
4648
aura: "Aura",
@@ -80,6 +82,7 @@ const names: Record<string, string> = {
8082
zenburn: "Zenburn",
8183
}
8284
const oc2Theme = oc2ThemeJson as DesktopTheme
85+
const cobaltoBrandTheme = cobaltoBrandThemeJson as DesktopTheme
8386

8487
function normalize(id: string | null | undefined) {
8588
return id === "oc-1" ? "oc-2" : id
@@ -133,7 +136,7 @@ function applyThemeCss(theme: DesktopTheme, themeId: string, mode: "light" | "da
133136
const tokens = resolveThemeVariant(variant, isDark)
134137
const css = themeToCss(tokens)
135138

136-
if (themeId !== "oc-2") {
139+
if (themeId !== "oc-2" && themeId !== "cobalto") {
137140
write(isDark ? STORAGE_KEYS.THEME_CSS_DARK : STORAGE_KEYS.THEME_CSS_LIGHT, css)
138141
}
139142

@@ -154,7 +157,7 @@ function applyThemeCss(theme: DesktopTheme, themeId: string, mode: "light" | "da
154157
}
155158

156159
function cacheThemeVariants(theme: DesktopTheme, themeId: string) {
157-
if (themeId === "oc-2") return
160+
if (themeId === "oc-2" || themeId === "cobalto") return
158161
for (const mode of ["light", "dark"] as const) {
159162
const isDark = mode === "dark"
160163
const variant = isDark ? theme.dark : theme.light
@@ -167,12 +170,13 @@ function cacheThemeVariants(theme: DesktopTheme, themeId: string) {
167170
export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
168171
name: "Theme",
169172
init: (props: { defaultTheme?: string; onThemeApplied?: (theme: DesktopTheme, mode: "light" | "dark") => void }) => {
170-
const themeId = normalize(read(STORAGE_KEYS.THEME_ID) ?? props.defaultTheme) ?? "oc-2"
173+
const themeId = normalize(read(STORAGE_KEYS.THEME_ID) ?? props.defaultTheme) ?? "cobalto"
171174
const colorScheme = (read(STORAGE_KEYS.COLOR_SCHEME) as ColorScheme | null) ?? "system"
172175
const mode = colorScheme === "system" ? getSystemMode() : colorScheme
173176
const [store, setStore] = createStore({
174177
themes: {
175178
"oc-2": oc2Theme,
179+
cobalto: cobaltoBrandTheme,
176180
} as Record<string, DesktopTheme>,
177181
themeId,
178182
colorScheme,
@@ -225,9 +229,9 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
225229
if (e.key === STORAGE_KEYS.THEME_ID && e.newValue) {
226230
const next = normalize(e.newValue)
227231
if (!next) return
228-
if (next !== "oc-2" && !knownThemes().has(next) && !store.themes[next]) return
232+
if (next !== "oc-2" && next !== "cobalto" && !knownThemes().has(next) && !store.themes[next]) return
229233
setStore("themeId", next)
230-
if (next === "oc-2") {
234+
if (next === "oc-2" || next === "cobalto") {
231235
clear()
232236
return
233237
}
@@ -253,7 +257,7 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
253257
makeEventListener(mediaQuery, "change", onMedia)
254258

255259
const rawTheme = read(STORAGE_KEYS.THEME_ID)
256-
const savedTheme = normalize(rawTheme ?? props.defaultTheme) ?? "oc-2"
260+
const savedTheme = normalize(rawTheme ?? props.defaultTheme) ?? "cobalto"
257261
const savedScheme = (read(STORAGE_KEYS.COLOR_SCHEME) as ColorScheme | null) ?? "system"
258262
if (rawTheme && rawTheme !== savedTheme) {
259263
write(STORAGE_KEYS.THEME_ID, savedTheme)

‎packages/ui/src/theme/default-themes.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import catppuccinThemeJson from "./themes/catppuccin.json"
88
import catppuccinFrappeThemeJson from "./themes/catppuccin-frappe.json"
99
import catppuccinMacchiatoThemeJson from "./themes/catppuccin-macchiato.json"
1010
import cobalt2ThemeJson from "./themes/cobalt2.json"
11+
import cobaltoBrandThemeJson from "./themes/cobalto.json"
1112
import cursorThemeJson from "./themes/cursor.json"
1213
import draculaThemeJson from "./themes/dracula.json"
1314
import everforestThemeJson from "./themes/everforest.json"
@@ -46,6 +47,7 @@ export const catppuccinTheme = catppuccinThemeJson as DesktopTheme
4647
export const catppuccinFrappeTheme = catppuccinFrappeThemeJson as DesktopTheme
4748
export const catppuccinMacchiatoTheme = catppuccinMacchiatoThemeJson as DesktopTheme
4849
export const cobalt2Theme = cobalt2ThemeJson as DesktopTheme
50+
export const cobaltoBrandTheme = cobaltoBrandThemeJson as DesktopTheme
4951
export const cursorTheme = cursorThemeJson as DesktopTheme
5052
export const draculaTheme = draculaThemeJson as DesktopTheme
5153
export const everforestTheme = everforestThemeJson as DesktopTheme
@@ -85,6 +87,7 @@ export const DEFAULT_THEMES: Record<string, DesktopTheme> = {
8587
"catppuccin-frappe": catppuccinFrappeTheme,
8688
"catppuccin-macchiato": catppuccinMacchiatoTheme,
8789
cobalt2: cobalt2Theme,
90+
cobalto: cobaltoBrandTheme,
8891
cursor: cursorTheme,
8992
dracula: draculaTheme,
9093
everforest: everforestTheme,

‎packages/ui/src/theme/loader.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function applyTheme(theme: DesktopTheme, themeId?: string): void {
2727
}
2828

2929
function buildThemeCss(light: ResolvedTheme, dark: ResolvedTheme, themeId: string): string {
30-
const isDefaultTheme = themeId === "oc-2"
30+
const isDefaultTheme = themeId === "oc-2" || themeId === "cobalto"
3131
const lightCss = themeToCss(light)
3232
const darkCss = themeToCss(dark)
3333

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"$schema": "https://opencode.ai/desktop-theme.json",
3+
"name": "Cobalto",
4+
"id": "cobalto",
5+
"light": {
6+
"palette": {
7+
"neutral": "#ffffff",
8+
"ink": "#070E46",
9+
"primary": "#001391",
10+
"accent": "#2340cc",
11+
"success": "#1a6e45",
12+
"warning": "#a85200",
13+
"error": "#b0001a",
14+
"info": "#0050cc",
15+
"interactive": "#001391"
16+
},
17+
"overrides": {
18+
"text-weak": "#3a4280",
19+
"syntax-comment": "#6670aa",
20+
"syntax-keyword": "#001391",
21+
"syntax-string": "#1a6e45",
22+
"syntax-primitive": "#6200b3",
23+
"syntax-variable": "#0050cc",
24+
"syntax-property": "#005e8a",
25+
"syntax-type": "#005e8a",
26+
"syntax-constant": "#a85200",
27+
"syntax-operator": "#001391",
28+
"syntax-punctuation": "#070E46",
29+
"syntax-object": "#0050cc",
30+
"markdown-heading": "#001391",
31+
"markdown-text": "#070E46",
32+
"markdown-link": "#001391",
33+
"markdown-link-text": "#0050cc",
34+
"markdown-code": "#1a6e45",
35+
"markdown-block-quote": "#3a4280",
36+
"markdown-emph": "#a85200",
37+
"markdown-strong": "#070E46",
38+
"markdown-horizontal-rule": "#001391",
39+
"markdown-list-item": "#070E46",
40+
"markdown-list-enumeration": "#001391",
41+
"markdown-image": "#0050cc",
42+
"markdown-image-text": "#0050cc",
43+
"markdown-code-block": "#070E46"
44+
}
45+
},
46+
"dark": {
47+
"palette": {
48+
"neutral": "#070E46",
49+
"ink": "#c8d4ff",
50+
"primary": "#4d6aff",
51+
"accent": "#7088ff",
52+
"success": "#4db87a",
53+
"warning": "#ffaa44",
54+
"error": "#ff5566",
55+
"info": "#5599ff",
56+
"interactive": "#4d6aff"
57+
},
58+
"overrides": {
59+
"text-weak": "#8899dd",
60+
"syntax-comment": "#5566aa",
61+
"syntax-keyword": "#7088ff",
62+
"syntax-string": "#4db87a",
63+
"syntax-primitive": "#cc88ff",
64+
"syntax-variable": "#5599ff",
65+
"syntax-property": "#44bbdd",
66+
"syntax-type": "#44bbdd",
67+
"syntax-constant": "#ffaa44",
68+
"syntax-operator": "#7088ff",
69+
"syntax-punctuation": "#c8d4ff",
70+
"syntax-object": "#5599ff",
71+
"markdown-heading": "#7088ff",
72+
"markdown-text": "#c8d4ff",
73+
"markdown-link": "#7088ff",
74+
"markdown-link-text": "#5599ff",
75+
"markdown-code": "#4db87a",
76+
"markdown-block-quote": "#8899dd",
77+
"markdown-emph": "#ffaa44",
78+
"markdown-strong": "#e0e8ff",
79+
"markdown-horizontal-rule": "#223388",
80+
"markdown-list-item": "#c8d4ff",
81+
"markdown-list-enumeration": "#7088ff",
82+
"markdown-image": "#5599ff",
83+
"markdown-image-text": "#5599ff",
84+
"markdown-code-block": "#c8d4ff"
85+
}
86+
}
87+
}

0 commit comments

Comments
 (0)