gpui_router/
router.rs

1use gpui::*;
2use smallvec::SmallVec;
3
4/// A simple router component that can hold child elements.
5pub fn router() -> impl IntoElement {
6  Router::new()
7}
8
9/// A simple router component that can hold child elements.
10#[derive(IntoElement, Default)]
11pub struct Router {
12  children: SmallVec<[AnyElement; 1]>,
13}
14
15impl Router {
16  pub fn new() -> Self {
17    Default::default()
18  }
19}
20
21impl ParentElement for Router {
22  fn extend(&mut self, elements: impl IntoIterator<Item = AnyElement>) {
23    self.children.extend(elements);
24  }
25}
26
27impl RenderOnce for Router {
28  fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement {
29    div().children(self.children)
30  }
31}