pintariching / railwind

Tailwind compiler rewritten in rust
MIT License
320 stars 9 forks source link

Adding extendability for classes #36

Closed pintariching closed 1 year ago

pintariching commented 1 year ago

I'm thinking about how to add extendability to classes that support it. Right now, every class gets a pub static ref HashMap<&'static str, &'static str> parsed from a .ron file at runtime. Now I imagine, modifying static references is a big no no and I'm unsure on how to proceed.

One idea is, to create a new class with an optional struct

pub enum SpacingConfig<'a> {
    Padding(HashMap<&'a str, &'a str>),
    Margin(HashMap<&'a str, &'a str>),
    SpaceBetween(HashMap<&'a str, &'a str>),
}

like

Spacing::new("p-5", Some(SpacingConfig::Padding(HashMap::from([("33", "33px")])))

and the hashmap gets created when a class is called and possibly cached somehow, if it's called again?