mirror of
https://github.com/tiennm99/claude-code-usage-bubble.git
synced 2026-09-09 06:20:16 +00:00
Phase 0 of UI/UX polish pass. Surgical changes, no substrate migration yet. - Extract bar_fill_color + accent_color_for into new src/usage_color.rs so the bubble, panel, and tray badge agree on a single 4-band usage ramp. - Panel: color each bar from its own percent (was using max(5h, 7d) for both rows, so a healthy 5h bar turned red whenever 7d was full). - Light-mode amber #B47A20 (was #E0A040, failed WCAG AA at 2.4:1). - Codex identity: switch from white/charcoal to OpenAI teal #10A37F across bubble, panel stripe, and tray sweep so the surfaces share one brand color and the tray badge stops reading as "loading spinner". - Panel: drop WS_BORDER, add DwmSetWindowAttribute(DWMWCP_ROUND) for Win11 rounded corners. Idempotent re-apply on every show() so the attribute survives any future destroy/recreate path. Silently no-ops on Win10.
42 lines
1.6 KiB
Rust
42 lines
1.6 KiB
Rust
// Shared usage→color ramp used by the floating bubble, the expanded panel,
|
||
// and the tray badge. Keeping the function in one place ensures the three
|
||
// surfaces never disagree about what "78% used" looks like.
|
||
|
||
use crate::os::Rgb as Color;
|
||
use crate::usage::ProviderId;
|
||
|
||
/// Per-provider identity color. Claude = warm orange `#D97757`. Codex =
|
||
/// OpenAI brand teal `#10A37F`, used consistently across dark and light
|
||
/// themes so the badge/bubble/panel never disagree on Codex identity.
|
||
pub fn accent_color_for(model: ProviderId, _is_dark: bool) -> Color {
|
||
match model {
|
||
ProviderId::Claude => Color::from_hex("#D97757"),
|
||
ProviderId::ChatGpt => Color::from_hex("#10A37F"),
|
||
}
|
||
}
|
||
|
||
/// Discrete 4-band fill color. The "safe" band uses the provider's identity
|
||
/// color so Codex bars stay white-on-dark while Claude bars stay orange; the
|
||
/// warning bands are theme-aware so light-mode amber stays readable against
|
||
/// the `#F3F3F3` background.
|
||
///
|
||
/// - <60% → provider accent
|
||
/// - 60–80% → amber (dark `#E0A040`, light `#B47A20` for WCAG AA contrast)
|
||
/// - 80–95% → red `#C45020`
|
||
/// - ≥95% → deep red `#A01818` — paired with pulse animation
|
||
pub fn bar_fill_color(model: ProviderId, is_dark: bool, percent: f64) -> Color {
|
||
if percent < 60.0 {
|
||
accent_color_for(model, is_dark)
|
||
} else if percent < 80.0 {
|
||
if is_dark {
|
||
Color::from_hex("#E0A040")
|
||
} else {
|
||
Color::from_hex("#B47A20")
|
||
}
|
||
} else if percent < 95.0 {
|
||
Color::from_hex("#C45020")
|
||
} else {
|
||
Color::from_hex("#A01818")
|
||
}
|
||
}
|