feat: Add Flexbox helpers (#56)
This commit is contained in:
35
src/features/ui/ui/flexbox.rs
Normal file
35
src/features/ui/ui/flexbox.rs
Normal 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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
pub mod button;
|
pub mod button;
|
||||||
|
pub mod flexbox;
|
||||||
|
|
||||||
pub use button::button;
|
pub use button::{button, pill_button};
|
||||||
|
|||||||
Reference in New Issue
Block a user