//! Semantic color roles. This module is the only place in the workspace //! allowed to hold color literals. use gpui::{Hsla, rgb}; fn hex(hex: u32) -> Hsla { rgb(hex).into() } /// The semantic color roles components paint from. #[derive(Clone, Copy, Debug, PartialEq)] pub struct ColorTokens { pub background: Hsla, pub foreground: Hsla, pub surface: Hsla, pub surface_foreground: Hsla, pub primary: Hsla, pub primary_foreground: Hsla, pub secondary: Hsla, pub secondary_foreground: Hsla, pub muted: Hsla, pub muted_foreground: Hsla, pub accent: Hsla, pub accent_foreground: Hsla, pub destructive: Hsla, pub destructive_foreground: Hsla, pub border: Hsla, pub input: Hsla, pub ring: Hsla, pub selection: Hsla, } impl ColorTokens { /// Neutral light palette; the fallback when no system theme applies. pub fn light() -> Self { Self { background: hex(0xffffff), foreground: hex(0x18181b), surface: hex(0xfafafa), surface_foreground: hex(0x18181b), primary: hex(0x2563eb), primary_foreground: hex(0xffffff), secondary: hex(0xf4f4f5), secondary_foreground: hex(0x18181b), muted: hex(0xf4f4f5), muted_foreground: hex(0x71717a), accent: hex(0x2563eb), accent_foreground: hex(0xffffff), destructive: hex(0xdc2626), destructive_foreground: hex(0xffffff), border: hex(0xe4e4e7), input: hex(0xe4e4e7), ring: hex(0x93c5fd), selection: hex(0xdbeafe), } } /// Neutral dark palette; the fallback when no system theme applies. pub fn dark() -> Self { Self { background: hex(0x09090b), foreground: hex(0xfafafa), surface: hex(0x18181b), surface_foreground: hex(0xfafafa), primary: hex(0x3b82f6), primary_foreground: hex(0xffffff), secondary: hex(0x27272a), secondary_foreground: hex(0xfafafa), muted: hex(0x27272a), muted_foreground: hex(0xa1a1aa), accent: hex(0x3b82f6), accent_foreground: hex(0xffffff), destructive: hex(0xef4444), destructive_foreground: hex(0xffffff), border: hex(0x27272a), input: hex(0x27272a), ring: hex(0x1d4ed8), selection: hex(0x1e3a8a), } } }