feat: Add Flexbox helpers (#56)

This commit is contained in:
demenik
2025-11-28 12:59:17 +01:00
parent 5e113717e4
commit 3ab3c8c2d9
2 changed files with 37 additions and 1 deletions

View File

@@ -0,0 +1,35 @@
use crate::prelude::*;
pub trait Flexbox {
fn hstack(spacing: Val) -> Self;
fn vstack(spacing: Val) -> Self;
fn center() -> Self;
}
impl Flexbox for Node {
fn hstack(spacing: Val) -> Self {
Self {
flex_direction: FlexDirection::Row,
align_items: AlignItems::Center,
column_gap: spacing,
..default()
}
}
fn vstack(spacing: Val) -> Self {
Self {
flex_direction: FlexDirection::Column,
align_items: AlignItems::Center,
row_gap: spacing,
..default()
}
}
fn center() -> Self {
Self {
justify_content: JustifyContent::Center,
align_items: AlignItems::Center,
..default()
}
}
}

View File

@@ -1,3 +1,4 @@
pub mod button;
pub mod flexbox;
pub use button::button;
pub use button::{button, pill_button};