added instructions

This commit is contained in:
2024-12-18 23:06:51 +01:00
parent 8182e70ca4
commit 1c67eaa3a2
6 changed files with 33 additions and 10 deletions
+16
View File
@@ -20,11 +20,17 @@ impl ElementWidget for Text<'_> {
}
}
#[derive(Debug)]
pub enum Instruction {
SetStyle(Css),
}
#[element]
#[elem_fn]
#[derive(Default, Debug)]
pub struct Div {
pub styling: Option<std::collections::HashMap<StyleName, Style>>,
pub instructions: Vec<Instruction>,
}
impl ElementWidget for Div<'_> {
@@ -66,6 +72,16 @@ impl ElementWidget for Div<'_> {
}
}
}
fn initialize(&mut self, document: &mut Document) {
for inst in &self.instructions {
match inst {
Instruction::SetStyle(s) => {
document.css.extend(s.clone().into_iter());
}
}
}
}
}
#[element]