use super::*;
#[doc=include_str!("readme.md")]
#[derive(Debug, Clone)]
pub struct TailwindJustifyContent {
kind: StandardValue,
}
crate::macros::sealed::keyword_instance!(TailwindJustifyContent => "justify-content", {
"between" => "space-between",
"around" => "space-around",
"evenly" => "space-evenly",
"start" => "flex-start",
"left" => "flex-start",
"end" => "flex-end",
"right" => "flex-end",
"center-safe" => "safe center",
"end-safe" => "safe end",
});
impl Display for TailwindJustifyContent {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match &self.kind {
StandardValue::Keyword(s) => match s.as_str() {
"flex-start" => write!(f, "justify-start"),
"flex-end" => write!(f, "justify-end"),
"center" => write!(f, "justify-center"),
"space-between" => write!(f, "justify-between"),
"space-around" => write!(f, "justify-around"),
"space-evenly" => write!(f, "justify-evenly"),
"safe center" => write!(f, "justify-center-safe"),
"safe end" => write!(f, "justify-end-safe"),
_ => write!(f, "justify-{}", s),
},
StandardValue::Arbitrary(s) => s.write_class(f, "justify-content-"),
}
}
}
impl TailwindJustifyContent {
pub fn parse(pattern: &[&str], arbitrary: &TailwindArbitrary) -> Result<Self> {
let mut kind = StandardValue::parser("justify-content", &Self::check_valid)(pattern, arbitrary)?;
if let StandardValue::Keyword(s) = &kind {
kind = StandardValue::Keyword(Self::map_keyword(s).to_string());
}
Ok(Self { kind })
}
pub fn parse_arbitrary(arbitrary: &TailwindArbitrary) -> Result<Self> {
StandardValue::parse_arbitrary(arbitrary).map(|kind| Self { kind })
}
pub fn check_valid(mode: &str) -> bool {
let set = BTreeSet::from_iter(vec![
"start",
"end",
"center",
"between",
"around",
"evenly",
"stretch",
"baseline",
"normal",
"flex-start", "flex-end", "space-around", "space-between", "space-evenly", "start",
"stretch",
"end-safe",
"center-safe",
"inherit",
"initial",
"left",
"revert",
"right",
"unset",
]);
set.contains(mode)
}
}