add button

This commit is contained in:
2026-10-28 17:02:02 +07:00
parent 12d4120bfd
commit 0b8b619342
13 changed files with 708 additions and 54 deletions
+26 -1
View File
@@ -20,7 +20,7 @@ pub use ramps::{AccentShades, Oklch};
pub use resolve::{Ramps, ResolvedTheme};
pub use system::{AccessibilityPreferences, PartialPalette, SourceKind, SystemTheme};
use gpui::{App, Global, WindowAppearance};
use gpui::{App, Global, Pixels, WindowAppearance, px};
/// Light or dark, resolved from the system appearance.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, serde::Deserialize)]
@@ -46,11 +46,35 @@ pub struct Theme {
pub variant: ThemeVariant,
pub colors: ColorTokens,
pub ramps: Ramps,
pub radius: Radius,
pub accessibility: AccessibilityPreferences,
}
impl Global for Theme {}
/// Corner radii components paint from; grows one class at a time.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Radius {
pub control: Pixels,
}
impl Default for Radius {
fn default() -> Self {
Self { control: px(6.) }
}
}
/// Reads the resolved theme global from any app context.
pub trait ActiveTheme {
fn theme(&self) -> &Theme;
}
impl ActiveTheme for App {
fn theme(&self) -> &Theme {
Theme::global(self)
}
}
impl Theme {
/// Reads the theme global. Panics before `init`.
pub fn global(cx: &App) -> &Self {
@@ -62,6 +86,7 @@ impl Theme {
variant: resolved.variant,
colors: resolved.colors,
ramps: resolved.ramps,
radius: resolved.radius,
accessibility: resolved.accessibility,
}
}