diff options
Diffstat (limited to 'src/types/rendered_element.rs')
| -rw-r--r-- | src/types/rendered_element.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/types/rendered_element.rs b/src/types/rendered_element.rs new file mode 100644 index 0000000..e909ac5 --- /dev/null +++ b/src/types/rendered_element.rs @@ -0,0 +1,36 @@ +use unique_id::{string::StringGenerator, Generator}; + +use super::{props::Props, ElementName}; +pub struct RenderedElement { + pub id: String, + pub child_elements: Vec<RenderedElement>, + pub name: ElementName, + pub props: Props, +} + +impl RenderedElement { + pub fn new(name: ElementName) -> Self { + let gen = StringGenerator::default(); + Self { + id: gen.next_id(), + child_elements: vec![], + name, + props: Props::default(), + } + } + + pub fn from_vec(name: ElementName, child_elements: Vec<RenderedElement>) -> Self { + let gen = StringGenerator::default(); + Self { + id: gen.next_id(), + child_elements, + name, + props: Props::default(), + } + } + + pub fn push(mut self, element: RenderedElement) -> Self { + self.child_elements.push(element); + self + } +} |
