Files
oak-gpui/crates/ui/src/styles/elevation.rs
T
Piotr Osiewicz e6c1c51b37 chore: Fix several style lints (#17488)
It's not comprehensive enough to start linting on `style` group, but
hey, it's a start.

Release Notes:

- N/A
2024-09-06 11:58:39 +02:00

83 lines
2.1 KiB
Rust

use gpui::{hsla, point, px, BoxShadow};
use smallvec::{smallvec, SmallVec};
#[doc = include_str!("docs/elevation.md")]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Elevation {
ElevationIndex(ElevationIndex),
LayerIndex(LayerIndex),
ElementIndex(ElementIndex),
}
impl From<ElevationIndex> for Elevation {
fn from(val: ElevationIndex) -> Self {
Elevation::ElevationIndex(val)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ElevationIndex {
Background,
Surface,
ElevatedSurface,
Wash,
ModalSurface,
DraggedElement,
}
impl ElevationIndex {
pub fn shadow(self) -> SmallVec<[BoxShadow; 2]> {
match self {
ElevationIndex::Surface => smallvec![],
ElevationIndex::ElevatedSurface => smallvec![BoxShadow {
color: hsla(0., 0., 0., 0.12),
offset: point(px(0.), px(2.)),
blur_radius: px(3.),
spread_radius: px(0.),
}],
ElevationIndex::ModalSurface => smallvec![
BoxShadow {
color: hsla(0., 0., 0., 0.12),
offset: point(px(0.), px(2.)),
blur_radius: px(3.),
spread_radius: px(0.),
},
BoxShadow {
color: hsla(0., 0., 0., 0.08),
offset: point(px(0.), px(3.)),
blur_radius: px(6.),
spread_radius: px(0.),
},
BoxShadow {
color: hsla(0., 0., 0., 0.04),
offset: point(px(0.), px(6.)),
blur_radius: px(12.),
spread_radius: px(0.),
},
],
_ => smallvec![],
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum LayerIndex {
BehindElement,
Element,
ElevatedElement,
}
/// An appropriate z-index for the given layer based on its intended usage.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ElementIndex {
Effect,
Background,
Tint,
Highlight,
Content,
Overlay,
}