use crate::prelude::*; use crate::{v_stack, Buffer, Icon, IconButton, Label}; #[derive(Component)] pub struct MultiBuffer { buffers: Vec, } impl MultiBuffer { pub fn new(buffers: Vec) -> Self { Self { buffers } } fn render(self, _view: &mut V, cx: &mut ViewContext) -> impl Component { let theme = theme(cx); v_stack() .w_full() .h_full() .flex_1() .children(self.buffers.clone().into_iter().map(|buffer| { v_stack() .child( div() .flex() .items_center() .justify_between() .p_4() .bg(theme.editor_subheader) .child(Label::new("main.rs")) .child(IconButton::new("arrow_up_right", Icon::ArrowUpRight)), ) .child(buffer) })) } } #[cfg(feature = "stories")] pub use stories::*; #[cfg(feature = "stories")] mod stories { use super::*; use crate::{hello_world_rust_buffer_example, Story}; use gpui2::{Div, Render}; pub struct MultiBufferStory; impl Render for MultiBufferStory { type Element = Div; fn render(&mut self, cx: &mut ViewContext) -> Self::Element { let theme = theme(cx); Story::container(cx) .child(Story::title_for::<_, MultiBuffer>(cx)) .child(Story::label(cx, "Default")) .child(MultiBuffer::new(vec![ hello_world_rust_buffer_example(&theme), hello_world_rust_buffer_example(&theme), hello_world_rust_buffer_example(&theme), hello_world_rust_buffer_example(&theme), hello_world_rust_buffer_example(&theme), ])) } } }