use crate::id::Id;
use derive_rich::Rich;
use savory::prelude::*;
#[derive(Clone, Rich)]
pub struct Svg<Msg> {
#[rich(write)]
pub id: Option<Id>,
#[rich(write)]
pub draw: Vec<Node<Msg>>,
}
impl<Msg> Svg<Msg> {
pub fn new(draw: impl IntoIterator<Item = Node<Msg>>) -> Self {
Self {
id: None,
draw: draw.into_iter().collect(),
}
}
}
impl<Msg> View<Node<Msg>> for Svg<Msg> {
fn view(&self) -> Node<Msg> {
html::svg()
.try_id(self.id.clone())
.class("svg")
.push(self.draw.clone())
}
}