aura-gui 0.2.2

UI nativa acelerada por GPU para escritorio, Android e iOS, en un solo crate: estilo tipo Tailwind, componentes, sombras, animaciones y agentes de IA. Reposo a cero. Licencia AGPL-3.0 o comercial.
//! Panel lateral con separador a la derecha.

use crate::core::px;
use crate::view::prelude::*;
use crate::widgets::separator::vertical_separator;

pub struct Sidebar {
    width: Pixels,
    content: Div,
}

impl Sidebar {
    pub fn new() -> Self {
        Self { width: px(240.0), content: div().flex_col().flex_1().overflow_hidden() }
    }

    pub fn width(mut self, width: Pixels) -> Self {
        self.width = width;
        self
    }
}

impl Default for Sidebar {
    fn default() -> Self {
        Self::new()
    }
}

impl ParentElement for Sidebar {
    fn extend_children(&mut self, children: impl IntoIterator<Item = AnyElement>) {
        let content = std::mem::replace(&mut self.content, div());
        self.content = content.children(children);
    }
}

impl IntoElement for Sidebar {
    fn into_element(self) -> AnyElement {
        div()
            .flex_row()
            .h_full()
            .w(self.width)
            .flex_shrink_0()
            .bg(Token::Surface)
            .child(self.content)
            .child(vertical_separator())
            .into_element()
    }
}