fc_ui/capabilities/foundation/
styled_ext.rs1use gpui::*;
2
3pub trait StyledExt: Styled + Sized {
4 fn center(self) -> Self {
5 self.flex().items_center().justify_center()
6 }
7
8 #[deprecated(note = "unused; use .flex().flex_col() directly, will be removed in 0.10")]
9 fn stack(self) -> Self {
10 self.flex().flex_col()
11 }
12
13 #[deprecated(note = "unused; use .flex().flex_row() directly, will be removed in 0.10")]
14 fn row(self) -> Self {
15 self.flex().flex_row()
16 }
17
18 #[deprecated(
19 note = "unused and bypasses theme tokens; will be removed or reworked on top of theme tokens in 0.10"
20 )]
21 fn glass(self, opacity: f32) -> Self {
22 let bg_color = hsla(0.0, 0.0, 1.0, 0.08 * opacity);
23 let border_color = hsla(0.0, 0.0, 1.0, 0.12 * opacity);
24 self.bg(bg_color).border_1().border_color(border_color)
25 }
26
27 #[deprecated(note = "unused; use theme shadow tokens instead, will be removed in 0.10")]
28 fn elevated(self, level: u8) -> Self {
29 let shadow = match level {
30 0 => return self,
31 1 => BoxShadow {
32 offset: point(px(0.0), px(1.0)),
33 blur_radius: px(2.0),
34 spread_radius: px(0.0),
35 inset: false,
36 color: hsla(0.0, 0.0, 0.0, 0.05),
37 },
38 2 => BoxShadow {
39 offset: point(px(0.0), px(1.0)),
40 blur_radius: px(3.0),
41 spread_radius: px(0.0),
42 inset: false,
43 color: hsla(0.0, 0.0, 0.0, 0.1),
44 },
45 3 => BoxShadow {
46 offset: point(px(0.0), px(4.0)),
47 blur_radius: px(6.0),
48 spread_radius: px(-1.0),
49 inset: false,
50 color: hsla(0.0, 0.0, 0.0, 0.1),
51 },
52 4 => BoxShadow {
53 offset: point(px(0.0), px(10.0)),
54 blur_radius: px(15.0),
55 spread_radius: px(-3.0),
56 inset: false,
57 color: hsla(0.0, 0.0, 0.0, 0.1),
58 },
59 _ => BoxShadow {
60 offset: point(px(0.0), px(20.0)),
61 blur_radius: px(25.0),
62 spread_radius: px(-5.0),
63 inset: false,
64 color: hsla(0.0, 0.0, 0.0, 0.1),
65 },
66 };
67 self.shadow(smallvec::smallvec![shadow])
68 }
69
70 #[deprecated(note = "unused; use .shadow() directly, will be removed in 0.10")]
71 fn ring(self, color: Hsla, width: Pixels) -> Self {
72 let shadow = BoxShadow {
73 offset: point(px(0.0), px(0.0)),
74 blur_radius: px(0.0),
75 spread_radius: width,
76 inset: false,
77 color,
78 };
79 self.shadow(smallvec::smallvec![shadow])
80 }
81}
82
83impl<T: Styled + Sized> StyledExt for T {}