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