add map for pseudo elements

This commit is contained in:
annieversary 2022-07-02 14:58:57 +01:00
parent fa22940ac1
commit 28d7886ee8
3 changed files with 15 additions and 1 deletions

View File

@ -28,12 +28,13 @@ impl<'a> Class<'a> {
if let Some(pseudo) = pseudo {
rest.push_str("::");
let pseudo: &str = z.pseudos.get(*pseudo).map(AsRef::as_ref).unwrap_or(pseudo);
rest.push_str(pseudo);
}
// TODO we can probably skip the format here, we just need to push the char at the start
if !rest.is_empty() {
rest = format!(":{rest}");
rest.insert(0, ':')
}
format!(".{original}{rest}")

View File

@ -58,3 +58,13 @@ pub(crate) fn default_modifiers() -> HashMap<String, String> {
.map(|(a, b)| (a.to_string(), b.to_string()))
.collect()
}
pub(crate) fn default_pseudos() -> HashMap<String, String> {
vec![
("ph", "placeholder"),
// TODO
]
.into_iter()
.map(|(a, b)| (a.to_string(), b.to_string()))
.collect()
}

View File

@ -15,6 +15,7 @@ pub struct Zephyr {
pub names: HashMap<String, String>,
pub values: HashMap<String, String>,
pub modifiers: HashMap<String, String>,
pub pseudos: HashMap<String, String>,
}
impl Zephyr {
@ -25,6 +26,7 @@ impl Zephyr {
names: default_names(),
values: default_values(),
modifiers: default_modifiers(),
pseudos: default_pseudos(),
}
}
@ -35,6 +37,7 @@ impl Zephyr {
names: HashMap::new(),
values: HashMap::new(),
modifiers: HashMap::new(),
pseudos: HashMap::new(),
}
}