pub use icondata::*;
use leptos::SignalGet;
#[leptos::component]
pub fn Icon(
#[prop(into)]
icon: leptos::MaybeSignal<Icon>,
#[prop(into, optional)]
width: Option<leptos::MaybeSignal<String>>,
#[prop(into, optional)]
height: Option<leptos::MaybeSignal<String>>,
#[prop(into, optional)]
class: Option<leptos::MaybeSignal<String>>,
#[prop(into, optional)]
style: Option<leptos::MaybeSignal<String>>,
) -> impl leptos::IntoView {
let icon = move || icondata::IconData::from(icon.get());
let svg = move || {
let icon = icon();
let mut svg = leptos::svg::svg();
if let Some(classes) = class.clone() {
svg = svg.classes(classes.get());
}
let mut svg = match (style.clone(), icon.style) {
(Some(a), Some(b)) => svg.attr("style", format!("{b} {}", a.get())),
(Some(a), None) => svg.attr("style", a.get()),
(None, Some(b)) => svg.attr("style", b),
(None, None) => svg,
};
if let Some(x) = icon.x {
svg = svg.attr("x", x);
}
if let Some(y) = icon.y {
svg = svg.attr("x", y);
}
svg = svg.attr(
"width",
leptos::Attribute::String(match (width.clone(), icon.width) {
(Some(a), Some(_b)) => leptos::Oco::from(a.get()),
(Some(a), None) => leptos::Oco::from(a.get()),
(None, Some(_b)) => leptos::Oco::from("1em"),
(None, None) => leptos::Oco::from("1em"),
}),
);
svg = svg.attr(
"height",
leptos::Attribute::String(match (height.clone(), icon.height) {
(Some(a), Some(_b)) => leptos::Oco::from(a.get()),
(Some(a), None) => leptos::Oco::from(a.get()),
(None, Some(_b)) => leptos::Oco::from("1em"),
(None, None) => leptos::Oco::from("1em"),
}),
);
if let Some(view_box) = icon.view_box {
svg = svg.attr("viewBox", view_box);
}
if let Some(stroke_linecap) = icon.stroke_linecap {
svg = svg.attr("stroke-linecap", stroke_linecap);
}
if let Some(stroke_linejoin) = icon.stroke_linejoin {
svg = svg.attr("stroke-linejoin", stroke_linejoin);
}
if let Some(stroke_width) = icon.stroke_width {
svg = svg.attr("stroke-width", stroke_width);
}
if let Some(stroke) = icon.stroke {
svg = svg.attr("stroke", stroke);
}
svg = svg.attr("fill", icon.fill.unwrap_or("currentColor"));
svg = svg.attr("role", "graphics-symbol");
svg = svg.inner_html(icon.data);
svg
};
leptos::IntoView::into_view(svg)
}