windjammer-ui 0.3.6

Cross-platform UI framework for Windjammer (Web, Desktop, Mobile)
Documentation
// Column - Vertical layout component with gap and alignment
pub struct Column {
    children: Vec<string>,
    gap: string,
    align: ColumnAlign,
    justify: ColumnJustify,
    class: string,
}

pub enum ColumnAlign {
    Start,
    Center,
    End,
    Stretch,
}

pub enum ColumnJustify {
    Start,
    Center,
    End,
    SpaceBetween,
    SpaceAround,
    SpaceEvenly,
}

impl Column {
    pub fn new() -> Column {
        Column {
            children: Vec::new(),
            gap: "8px".to_string(),
            align: ColumnAlign::Start,
            justify: ColumnJustify::Start,
            class: String::new(),
        }
    }
    
    pub fn child(child: string) -> Column {
        self.children.push(child)
        self
    }
    
    pub fn gap(gap: string) -> Column {
        self.gap = gap
        self
    }
    
    pub fn align(align: ColumnAlign) -> Column {
        self.align = align
        self
    }
    
    pub fn justify(justify: ColumnJustify) -> Column {
        self.justify = justify
        self
    }
    
    pub fn class(class: string) -> Column {
        self.class = class
        self
    }
    
    pub fn render() -> string {
        let align_str = match self.align {
            ColumnAlign::Start => "flex-start",
            ColumnAlign::Center => "center",
            ColumnAlign::End => "flex-end",
            ColumnAlign::Stretch => "stretch",
        }
        
        let justify_str = match self.justify {
            ColumnJustify::Start => "flex-start",
            ColumnJustify::Center => "center",
            ColumnJustify::End => "flex-end",
            ColumnJustify::SpaceBetween => "space-between",
            ColumnJustify::SpaceAround => "space-around",
            ColumnJustify::SpaceEvenly => "space-evenly",
        }
        
        let mut html = String::new()
        html.push_str("<div class=\"wj-column ")
        html.push_str(self.class.as_str())
        html.push_str("\" style=\"display: flex; flex-direction: column; gap: ")
        html.push_str(self.gap.as_str())
        html.push_str("; align-items: ")
        html.push_str(align_str)
        html.push_str("; justify-content: ")
        html.push_str(justify_str)
        html.push_str(";\">")
        
        for child in self.children {
            html.push_str(child.as_str())
        }
        
        html.push_str("</div>")
        html
    }
}