added instructions
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user