mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-24 22:09:14 +00:00
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.
This commit is contained in:
parent
9d4f0ff4f0
commit
147ff702fa
6 changed files with 196 additions and 11 deletions
|
|
@ -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<MenubarPayload>()
|
||||
|
|
@ -74,6 +75,7 @@ export function App() {
|
|||
const [quota, setQuota] = useState<QuotaState>(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<AccentPreset>(savedAccent)
|
||||
const [themeChoice, setThemeChoice] = useState<ThemeChoice>(() => {
|
||||
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 (
|
||||
<div className="popover">
|
||||
<header className="header">
|
||||
<div className="brand">
|
||||
<span className="brand-primary">Code</span>
|
||||
<span className="brand-accent">Burn</span>
|
||||
</div>
|
||||
<div className="subhead">AI Coding Cost Tracker</div>
|
||||
{!cliBlocked && !showSettings && <QuotaWarningRow quota={quota} />}
|
||||
</header>
|
||||
<Header
|
||||
quota={quota}
|
||||
showQuota={!cliBlocked && !showSettings}
|
||||
accent={accent}
|
||||
onAccent={chooseAccent}
|
||||
animate={popoverVisible}
|
||||
/>
|
||||
|
||||
{!cliBlocked && !showSettings && (
|
||||
<AgentTabStrip selected={provider} onSelect={setProvider} payload={todayPayload} currency={currency} quota={quota} />
|
||||
|
|
|
|||
73
windows/src/components/Header.tsx
Normal file
73
windows/src/components/Header.tsx
Normal file
|
|
@ -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 (
|
||||
<header className="header">
|
||||
<div className="header-top">
|
||||
<div className="header-brand">
|
||||
<FlameWordmark animate={animate} />
|
||||
<div className="subhead">Your AI Bill, Itemized</div>
|
||||
</div>
|
||||
<AccentPicker accent={accent} onAccent={onAccent} />
|
||||
</div>
|
||||
{showQuota && <QuotaWarningRow quota={quota} />}
|
||||
</header>
|
||||
)
|
||||
}
|
||||
|
||||
/// 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 (
|
||||
<div className={`brand brand-flame ${animate ? '' : 'is-still'}`} aria-label="CodeBurn">
|
||||
CodeBurn
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function AccentPicker({ accent, onAccent }: { accent: AccentPreset; onAccent: (p: AccentPreset) => void }) {
|
||||
const [open, setOpen] = useState(false)
|
||||
return (
|
||||
<div className="accent-picker">
|
||||
{open && (
|
||||
<div className="accent-swatches">
|
||||
{ACCENT_PRESETS.map(preset => (
|
||||
<button
|
||||
key={preset.id}
|
||||
type="button"
|
||||
className={`accent-swatch ${preset.id === accent.id ? 'is-selected' : ''}`}
|
||||
style={{ background: preset.base }}
|
||||
aria-label={preset.label}
|
||||
aria-pressed={preset.id === accent.id}
|
||||
onClick={() => onAccent(preset)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className="accent-current"
|
||||
style={{ background: accent.base }}
|
||||
aria-label="Change accent color"
|
||||
aria-expanded={open}
|
||||
onClick={() => setOpen(o => !o)}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
47
windows/src/lib/accent.ts
Normal file
47
windows/src/lib/accent.ts
Normal file
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
<React.StrictMode>{isDock ? <Dock /> : <App />}</React.StrictMode>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue