From 147ff702fa86e50d93a006344e6bb52ec27f634d Mon Sep 17 00:00:00 2001 From: iamtoruk Date: Tue, 1 Sep 2026 17:57:08 -0700 Subject: [PATCH] feat(windows): the mac header, with a flame wordmark and an accent picker The popover opened with a flat two-tone wordmark and "AI Coding Cost Tracker", which is a category, not a promise. The mac says "Your AI Bill, Itemized" under the site's animated flame wordmark, and lets the reader pick the accent the whole surface is drawn in. The wordmark is the website's .flame-text verbatim: a 300 percent wide flame gradient clipped to the letters, swept by flameShift 3s ease infinite. It pauses while the popover is hidden, the gate the mac added after measuring 5 to 7 percent idle CPU on an always-running sweep, and honours prefers-reduced-motion. The nine presets are ThemeState.swift's, each with its four shades, and they map one to one onto the accent tokens the stylesheet already declares on :root. Writing them as an inline style on the same element outranks both theme blocks, so a single write covers light and dark, and main.tsx applies the saved preset before the first paint so nothing renders in ember and then jumps. The dock window reads the same tokens. --- windows/src/App.tsx | 24 ++++++---- windows/src/components/Header.tsx | 73 +++++++++++++++++++++++++++++++ windows/src/lib/accent.ts | 47 ++++++++++++++++++++ windows/src/lib/settings.ts | 1 + windows/src/main.tsx | 5 +++ windows/src/styles.css | 57 +++++++++++++++++++++++- 6 files changed, 196 insertions(+), 11 deletions(-) create mode 100644 windows/src/components/Header.tsx create mode 100644 windows/src/lib/accent.ts diff --git a/windows/src/App.tsx b/windows/src/App.tsx index 84f26fd9..f0ebd921 100644 --- a/windows/src/App.tsx +++ b/windows/src/App.tsx @@ -31,7 +31,8 @@ import { PeriodTabs, PERIOD_LABELS } from './components/PeriodTabs' import type { Period } from './components/PeriodTabs' import { FooterBar } from './components/FooterBar' import { ErrorToast } from './components/ErrorToast' -import { QuotaWarningRow } from './components/QuotaWarningRow' +import { Header } from './components/Header' +import { applyAccent, savedAccent, type AccentPreset } from './lib/accent' import { SettingsPanel, type SettingsSection, type ThemeChoice } from './components/SettingsPanel' const payloadCache = new PayloadCache() @@ -74,6 +75,7 @@ export function App() { const [quota, setQuota] = useState(EMPTY_QUOTA) // The window starts hidden and is shown by a tray click, which emits `codeburn://shown`. const [popoverVisible, setPopoverVisible] = useState(false) + const [accent, setAccent] = useState(savedAccent) const [themeChoice, setThemeChoice] = useState(() => { const saved = readSetting('theme') return saved === 'dark' || saved === 'light' ? saved : 'system' @@ -256,6 +258,11 @@ export function App() { }, [todayPayload, currency]) + const chooseAccent = (preset: AccentPreset) => { + applyAccent(preset) + setAccent(preset) + } + const chooseTheme = (choice: ThemeChoice) => { applyTheme(choice === 'system' ? null : choice) setThemeChoice(choice) @@ -316,14 +323,13 @@ export function App() { return (
-
-
- Code - Burn -
-
AI Coding Cost Tracker
- {!cliBlocked && !showSettings && } -
+
{!cliBlocked && !showSettings && ( diff --git a/windows/src/components/Header.tsx b/windows/src/components/Header.tsx new file mode 100644 index 00000000..503c5a38 --- /dev/null +++ b/windows/src/components/Header.tsx @@ -0,0 +1,73 @@ +import { useState } from 'react' +import { ACCENT_PRESETS, type AccentPreset } from '../lib/accent' +import { QuotaWarningRow } from './QuotaWarningRow' +import type { QuotaState } from '../lib/quota' + +/// Port of Header in mac/Sources/CodeBurnMenubar/Views/MenuBarContent.swift: the flame +/// wordmark and tagline on the left, the accent picker on the right, and the quota warning +/// row underneath. Package E adds the update badge between them. + +type Props = { + quota: QuotaState + showQuota: boolean + accent: AccentPreset + onAccent: (preset: AccentPreset) => void + animate: boolean +} + +export function Header({ quota, showQuota, accent, onAccent, animate }: Props) { + return ( +
+
+
+ +
Your AI Bill, Itemized
+
+ +
+ {showQuota && } +
+ ) +} + +/// The website's `.flame-text`: a 300 percent wide flame gradient clipped to the letters and +/// swept by `flameShift 3s ease infinite`. The sweep pauses while the popover is hidden, as +/// on the mac, where an always-running animation cost 5 to 7 percent idle CPU. +function FlameWordmark({ animate }: { animate: boolean }) { + return ( +
+ CodeBurn +
+ ) +} + +function AccentPicker({ accent, onAccent }: { accent: AccentPreset; onAccent: (p: AccentPreset) => void }) { + const [open, setOpen] = useState(false) + return ( +
+ {open && ( +
+ {ACCENT_PRESETS.map(preset => ( +
+ )} +
+ ) +} diff --git a/windows/src/lib/accent.ts b/windows/src/lib/accent.ts new file mode 100644 index 00000000..9e79b8c1 --- /dev/null +++ b/windows/src/lib/accent.ts @@ -0,0 +1,47 @@ +/// The accent presets from mac/Sources/CodeBurnMenubar/Theme/ThemeState.swift: Apple's +/// dark-mode system accent colours plus the CodeBurn ember. Each preset carries the four +/// shades the popover paints with, which map one to one onto the CSS tokens in styles.css. + +import { readSetting, writeSetting } from './settings' + +export type AccentPreset = { + id: string + label: string + base: string + light: string + deep: string + glow: string +} + +export const ACCENT_PRESETS: AccentPreset[] = [ + { id: 'ember', label: 'Ember', base: '#C9521D', light: '#E8774A', deep: '#8B3E13', glow: '#F0A070' }, + { id: 'blue', label: 'Blue', base: '#0A84FF', light: '#409CFF', deep: '#0652B3', glow: '#80C0FF' }, + { id: 'purple', label: 'Purple', base: '#BF5AF2', light: '#DA8FF7', deep: '#7C38A8', glow: '#E0B8FA' }, + { id: 'pink', label: 'Pink', base: '#FF375F', light: '#FF6E8C', deep: '#B32642', glow: '#FF99B0' }, + { id: 'red', label: 'Red', base: '#FF453A', light: '#FF6E63', deep: '#B33028', glow: '#FF9990' }, + { id: 'orange', label: 'Orange', base: '#FF9F0A', light: '#FFBD4A', deep: '#B36F06', glow: '#FFD080' }, + { id: 'yellow', label: 'Yellow', base: '#FFD60A', light: '#FFE04A', deep: '#B39606', glow: '#FFEA80' }, + { id: 'green', label: 'Green', base: '#30D158', light: '#5AE078', deep: '#20923D', glow: '#80F098' }, + { id: 'graphite', label: 'Graphite', base: '#98989D', light: '#AEAEB2', deep: '#5E5E62', glow: '#C8C8CC' }, +] + +export const DEFAULT_ACCENT = ACCENT_PRESETS[0] + +export function accentById(id: string | null): AccentPreset { + return ACCENT_PRESETS.find(p => p.id === id) ?? DEFAULT_ACCENT +} + +export function savedAccent(): AccentPreset { + return accentById(readSetting('accent')) +} + +/// Writes the preset over the tokens the stylesheet declares on :root. An inline style on +/// the same element outranks both theme blocks, so one write covers light and dark. +export function applyAccent(preset: AccentPreset): void { + const style = document.documentElement.style + style.setProperty('--brand-accent', preset.base) + style.setProperty('--brand-accent-dark', preset.light) + style.setProperty('--ember-deep', preset.deep) + style.setProperty('--ember-glow', preset.glow) + writeSetting('accent', preset.id) +} diff --git a/windows/src/lib/settings.ts b/windows/src/lib/settings.ts index 8aa4d2e1..afd526ee 100644 --- a/windows/src/lib/settings.ts +++ b/windows/src/lib/settings.ts @@ -6,6 +6,7 @@ const KEYS = { insight: 'codeburn.insight', starBannerDismissed: 'codeburn.starBannerDismissed', trayBadge: 'codeburn.trayBadge', + accent: 'codeburn.accent', } as const type Key = keyof typeof KEYS diff --git a/windows/src/main.tsx b/windows/src/main.tsx index 93fb4782..f9201cf3 100644 --- a/windows/src/main.tsx +++ b/windows/src/main.tsx @@ -3,11 +3,16 @@ import ReactDOM from 'react-dom/client' import { getCurrentWindow } from '@tauri-apps/api/window' import { App } from './App' import { Dock } from './Dock' +import { applyAccent, savedAccent } from './lib/accent' import './styles.css' // Both windows load the one bundle, so the label decides which surface mounts. const isDock = getCurrentWindow().label === 'dock' +// Before the first paint, so nothing tinted by the accent renders in the default ember and +// then jumps. The dock reads the same tokens. +applyAccent(savedAccent()) + ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( {isDock ? : } ) diff --git a/windows/src/styles.css b/windows/src/styles.css index 0ff0e1e7..09387256 100644 --- a/windows/src/styles.css +++ b/windows/src/styles.css @@ -211,10 +211,63 @@ code { font-family: var(--font-mono); } padding: 10px var(--gutter) 8px; border-bottom: 1px solid var(--separator); } +.header-top { display: flex; align-items: flex-start; gap: 8px; } +.header-brand { display: flex; flex-direction: column; gap: 1px; min-width: 0; } .brand { font-size: 13px; font-weight: 600; letter-spacing: -0.15px; line-height: 16px; } -.brand-primary { color: var(--label); } -.brand-accent { color: var(--brand-accent); } +/* The website's .flame-text: a 300% wide flame gradient clipped to the letters and swept by + flameShift, 3s ease infinite. The sweep pauses while the popover is hidden, as on the mac, + where an always-running animation cost 5 to 7 percent idle CPU. */ +.brand-flame { + background: linear-gradient(90deg, #ff6a00, #ffda44, #e8553a, #ff8c00, #ffda44, #ff6a00); + background-size: 300% 100%; + -webkit-background-clip: text; + background-clip: text; + color: transparent; + animation: flameShift 3s ease infinite; +} +.brand-flame.is-still { animation-play-state: paused; } +@keyframes flameShift { + 0%, 100% { background-position: 0% 50%; } + 50% { background-position: 100% 50%; } +} +@media (prefers-reduced-motion: reduce) { + .brand-flame { animation: none; background-position: 0% 50%; } +} .subhead { font-size: 10.5px; color: var(--label-2); } + +/* Accent picker: a dot showing the current preset, which reveals the nine swatches. */ +.accent-picker { display: flex; align-items: center; margin-left: auto; } +.accent-swatches { + display: flex; + gap: 5px; + padding: 4px 6px; + border-radius: var(--radius-card); + background: var(--fill-08); + animation: accent-swatches-in 200ms var(--ease-ui); +} +@keyframes accent-swatches-in { + from { opacity: 0; transform: translateX(6px); } + to { opacity: 1; transform: translateX(0); } +} +.accent-swatch { + width: 12px; + height: 12px; + padding: 0; + border: none; + border-radius: 50%; + cursor: pointer; +} +.accent-swatch.is-selected { box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.9); } +.accent-current { + width: 14px; + height: 14px; + margin-left: 4px; + padding: 0; + border: none; + border-radius: 50%; + box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.3); + cursor: pointer; +} /* Quota warning row: sits under the wordmark, above the strip, tinted by the worst connected provider's severity. */ .quota-warning {