add popover
This commit is contained in:
+77
-1
@@ -20,7 +20,8 @@ pub use ramps::{AccentShades, Oklch};
|
||||
pub use resolve::{Ramps, ResolvedTheme};
|
||||
pub use system::{AccessibilityPreferences, PartialPalette, SourceKind, SystemTheme};
|
||||
|
||||
use gpui::{App, Global, Pixels, WindowAppearance, px};
|
||||
use gpui::{App, Global, Hsla, Pixels, WindowAppearance, px};
|
||||
use std::time::Duration;
|
||||
|
||||
/// Light or dark, resolved from the system appearance.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, serde::Deserialize)]
|
||||
@@ -47,6 +48,9 @@ pub struct Theme {
|
||||
pub colors: ColorTokens,
|
||||
pub ramps: Ramps,
|
||||
pub radius: Radius,
|
||||
pub elevations: Elevations,
|
||||
/// Overlay transition timing; gpui's animation primitives do the rest.
|
||||
pub motion: Motion,
|
||||
/// The platform's native root font size; rem-based sizing scales with it.
|
||||
pub root_font_size: Pixels,
|
||||
pub sizes: SizeTable,
|
||||
@@ -61,6 +65,8 @@ pub struct Radius {
|
||||
/// Small controls: checkbox and radio indicators.
|
||||
pub sm: Pixels,
|
||||
pub control: Pixels,
|
||||
/// Floating layers: popovers, menus, dialogs.
|
||||
pub overlay: Pixels,
|
||||
/// Pill and circle shapes.
|
||||
pub full: Pixels,
|
||||
}
|
||||
@@ -70,11 +76,79 @@ impl Default for Radius {
|
||||
Self {
|
||||
sm: px(4.),
|
||||
control: px(6.),
|
||||
overlay: px(10.),
|
||||
full: px(9999.),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// One drop shadow of a floating layer, transcribed from the platform's
|
||||
/// native overlay shadows.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Elevation {
|
||||
pub offset_y: Pixels,
|
||||
pub blur_radius: Pixels,
|
||||
pub spread_radius: Pixels,
|
||||
/// Translucent black, like every native overlay shadow.
|
||||
pub color: Hsla,
|
||||
}
|
||||
|
||||
impl Elevation {
|
||||
/// The gpui shadow list an overlay panel paints with.
|
||||
pub fn shadows(self) -> Vec<gpui::BoxShadow> {
|
||||
vec![gpui::BoxShadow {
|
||||
color: self.color,
|
||||
offset: gpui::point(px(0.), self.offset_y),
|
||||
blur_radius: self.blur_radius,
|
||||
spread_radius: self.spread_radius,
|
||||
inset: false,
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
/// The drop shadows of each floating layer class.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Elevations {
|
||||
/// Popovers and menus ride above content on a tight shadow.
|
||||
pub popover: Elevation,
|
||||
/// Modal dialogs sit higher with a wider one.
|
||||
pub dialog: Elevation,
|
||||
}
|
||||
|
||||
impl Default for Elevations {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
popover: Elevation {
|
||||
offset_y: px(4.),
|
||||
blur_radius: px(24.),
|
||||
spread_radius: px(0.),
|
||||
color: colors::scrim(0.3),
|
||||
},
|
||||
dialog: Elevation {
|
||||
offset_y: px(8.),
|
||||
blur_radius: px(40.),
|
||||
spread_radius: px(0.),
|
||||
color: colors::scrim(0.35),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Overlay transition timings; the platform refines these per phase.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Motion {
|
||||
/// The enter transition of popovers, menus, and dialogs.
|
||||
pub overlay: Duration,
|
||||
}
|
||||
|
||||
impl Default for Motion {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
overlay: Duration::from_millis(200),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A named control size class.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
pub enum Size {
|
||||
@@ -170,6 +244,8 @@ impl Theme {
|
||||
colors: resolved.colors,
|
||||
ramps: resolved.ramps,
|
||||
radius: resolved.radius,
|
||||
elevations: resolved.elevations,
|
||||
motion: resolved.motion,
|
||||
root_font_size: resolved.root_font_size,
|
||||
sizes: resolved.sizes,
|
||||
accessibility: resolved.accessibility,
|
||||
|
||||
Reference in New Issue
Block a user