1use gpui::{hsla, point, px, BoxShadow};
2use smallvec::{smallvec, SmallVec};
3
4#[doc = include_str!("docs/elevation.md")]
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub enum Elevation {
7 ElevationIndex(ElevationIndex),
8 LayerIndex(LayerIndex),
9 ElementIndex(ElementIndex),
10}
11
12#[derive(Debug, Clone, Copy, PartialEq, Eq)]
13pub enum ElevationIndex {
14 Background,
15 Surface,
16 ElevatedSurface,
17 Wash,
18 ModalSurface,
19 DraggedElement,
20}
21
22impl ElevationIndex {
23 pub fn shadow(self) -> SmallVec<[BoxShadow; 2]> {
24 match self {
25 ElevationIndex::Surface => smallvec![],
26
27 ElevationIndex::ElevatedSurface => smallvec![BoxShadow {
28 color: hsla(0., 0., 0., 0.12),
29 offset: point(px(0.), px(2.)),
30 blur_radius: px(3.),
31 spread_radius: px(0.),
32 }],
33
34 ElevationIndex::ModalSurface => smallvec![
35 BoxShadow {
36 color: hsla(0., 0., 0., 0.12),
37 offset: point(px(0.), px(2.)),
38 blur_radius: px(3.),
39 spread_radius: px(0.),
40 },
41 BoxShadow {
42 color: hsla(0., 0., 0., 0.08),
43 offset: point(px(0.), px(3.)),
44 blur_radius: px(6.),
45 spread_radius: px(0.),
46 },
47 BoxShadow {
48 color: hsla(0., 0., 0., 0.04),
49 offset: point(px(0.), px(6.)),
50 blur_radius: px(12.),
51 spread_radius: px(0.),
52 },
53 ],
54
55 _ => smallvec![],
56 }
57 }
58}
59
60#[derive(Debug, Clone, Copy, PartialEq, Eq)]
61pub enum LayerIndex {
62 BehindElement,
63 Element,
64 ElevatedElement,
65}
66
67/// An appropriate z-index for the given layer based on its intended usage.
68#[derive(Debug, Clone, Copy, PartialEq, Eq)]
69pub enum ElementIndex {
70 Effect,
71 Background,
72 Tint,
73 Highlight,
74 Content,
75 Overlay,
76}