diff --git a/src/features/ui/ui/flexbox.rs b/src/features/ui/ui/flexbox.rs new file mode 100644 index 0000000..20728b8 --- /dev/null +++ b/src/features/ui/ui/flexbox.rs @@ -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() + } + } +} diff --git a/src/features/ui/ui/mod.rs b/src/features/ui/ui/mod.rs index 9e3220b..f8515af 100644 --- a/src/features/ui/ui/mod.rs +++ b/src/features/ui/ui/mod.rs @@ -1,3 +1,4 @@ pub mod button; +pub mod flexbox; -pub use button::button; +pub use button::{button, pill_button};