1use gpui2::{relative, rems, Size};
2
3use crate::prelude::*;
4use crate::{Icon, IconButton, Pane, Tab};
5
6#[derive(Component)]
7pub struct Terminal;
8
9impl Terminal {
10 pub fn new() -> Self {
11 Self
12 }
13
14 fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
15 let theme = theme(cx);
16
17 let can_navigate_back = true;
18 let can_navigate_forward = false;
19
20 div()
21 .flex()
22 .flex_col()
23 .w_full()
24 .child(
25 // Terminal Tabs.
26 div()
27 .w_full()
28 .flex()
29 .bg(theme.surface)
30 .child(
31 div().px_1().flex().flex_none().gap_2().child(
32 div()
33 .flex()
34 .items_center()
35 .gap_px()
36 .child(
37 IconButton::new("arrow_left", Icon::ArrowLeft).state(
38 InteractionState::Enabled.if_enabled(can_navigate_back),
39 ),
40 )
41 .child(IconButton::new("arrow_right", Icon::ArrowRight).state(
42 InteractionState::Enabled.if_enabled(can_navigate_forward),
43 )),
44 ),
45 )
46 .child(
47 div().w_0().flex_1().h_full().child(
48 div()
49 .flex()
50 .child(
51 Tab::new(1)
52 .title("zed — fish".to_string())
53 .icon(Icon::Terminal)
54 .close_side(IconSide::Right)
55 .current(true),
56 )
57 .child(
58 Tab::new(2)
59 .title("zed — fish".to_string())
60 .icon(Icon::Terminal)
61 .close_side(IconSide::Right)
62 .current(false),
63 ),
64 ),
65 ),
66 )
67 // Terminal Pane.
68 .child(
69 Pane::new(
70 "terminal",
71 Size {
72 width: relative(1.).into(),
73 height: rems(36.).into(),
74 },
75 )
76 .child(crate::static_data::terminal_buffer(&theme)),
77 )
78 }
79}
80
81#[cfg(feature = "stories")]
82pub use stories::*;
83
84#[cfg(feature = "stories")]
85mod stories {
86 use crate::Story;
87
88 use super::*;
89
90 #[derive(Component)]
91 pub struct TerminalStory;
92
93 impl TerminalStory {
94 fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
95 Story::container(cx)
96 .child(Story::title_for::<_, Terminal>(cx))
97 .child(Story::label(cx, "Default"))
98 .child(Terminal::new())
99 }
100 }
101}