Refactor alignment types into an alignment module

This commit is contained in:
Héctor Ramón Jiménez 2021-09-20 15:09:55 +07:00
parent 5fae6e59ff
commit a0ad399622
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
54 changed files with 402 additions and 377 deletions

View file

@ -1,5 +1,6 @@
//! Style your widgets.
use crate::{bumpalo, Align, Background, Color, CrossAlign, Length, Padding};
use crate::bumpalo;
use crate::{Alignment, Background, Color, Length, Padding};
use std::collections::BTreeMap;
@ -195,22 +196,13 @@ pub fn background(background: Background) -> String {
}
}
/// Returns the style value for the given [`Align`].
pub fn align(align: Align) -> &'static str {
match align {
Align::Start => "flex-start",
Align::Center => "center",
Align::End => "flex-end",
}
}
/// Returns the style value for the given [`CrossAlign`].
pub fn cross_align(align: CrossAlign) -> &'static str {
match align {
CrossAlign::Start => "flex-start",
CrossAlign::Center => "center",
CrossAlign::End => "flex-end",
CrossAlign::Fill => "stretch",
/// Returns the style value for the given [`Alignment`].
pub fn alignment(alignment: Alignment) -> &'static str {
match alignment {
Alignment::Start => "flex-start",
Alignment::Center => "center",
Alignment::End => "flex-end",
Alignment::Fill => "stretch",
}
}