diff options
| author | pml68 <contact@pml68.me> | 2024-09-03 21:55:34 +0200 |
|---|---|---|
| committer | pml68 <contact@pml68.me> | 2024-09-22 23:55:11 +0200 |
| commit | e8792ea151e0c26fd3497a09446f1b846df1c87c (patch) | |
| tree | 3aed2ad399ae78fd6ead35c3d71906f0dbe31b71 /src/types/rendered_element.rs | |
| parent | feat: format children nodes into code (without props) (diff) | |
| download | iced-builder-e8792ea151e0c26fd3497a09446f1b846df1c87c.tar.gz | |
feat: finish codegen for elements **without** props
feat: wow
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 + } +} |
