File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ mod button;
3
3
mod checkbox;
4
4
mod context_menu;
5
5
mod details;
6
+ mod divider;
6
7
mod elevated_surface;
7
8
mod facepile;
8
9
mod icon;
@@ -31,6 +32,7 @@ pub use button::*;
31
32
pub use checkbox:: * ;
32
33
pub use context_menu:: * ;
33
34
pub use details:: * ;
35
+ pub use divider:: * ;
34
36
pub use elevated_surface:: * ;
35
37
pub use facepile:: * ;
36
38
pub use icon:: * ;
Original file line number Diff line number Diff line change
1
+ use crate :: prelude:: * ;
2
+
3
+ enum DividerDirection {
4
+ Horizontal ,
5
+ Vertical ,
6
+ }
7
+
8
+ #[ derive( Component ) ]
9
+ pub struct Divider {
10
+ direction : DividerDirection ,
11
+ inset : bool ,
12
+ }
13
+
14
+ impl Divider {
15
+ pub fn horizontal ( ) -> Self {
16
+ Self {
17
+ direction : DividerDirection :: Horizontal ,
18
+ inset : false ,
19
+ }
20
+ }
21
+
22
+ pub fn vertical ( ) -> Self {
23
+ Self {
24
+ direction : DividerDirection :: Vertical ,
25
+ inset : false ,
26
+ }
27
+ }
28
+
29
+ pub fn inset ( mut self ) -> Self {
30
+ self . inset = true ;
31
+ self
32
+ }
33
+
34
+ fn render < V : ' static > ( self , _view : & mut V , cx : & mut ViewContext < V > ) -> impl Component < V > {
35
+ div ( )
36
+ . map ( |this| match self . direction {
37
+ DividerDirection :: Horizontal => {
38
+ this. h_px ( ) . w_full ( ) . when ( self . inset , |this| this. mx_1p5 ( ) )
39
+ }
40
+ DividerDirection :: Vertical => {
41
+ this. w_px ( ) . h_full ( ) . when ( self . inset , |this| this. my_1p5 ( ) )
42
+ }
43
+ } )
44
+ . bg ( cx. theme ( ) . colors ( ) . border_variant )
45
+ }
46
+ }
You can’t perform that action at this time.
0 commit comments