use tairitsu_vdom::{VElement, VNode, VText};
pub fn icon_vnode(name: &str, size: u32) -> VNode {
let path = match hikari_icons::get(name) {
Some(d) => d
.path
.or_else(|| d.paths.first().and_then(|p| p.d))
.unwrap_or(""),
None => "",
};
if path.is_empty() {
return VNode::Text(VText::new(""));
}
let svg = format!(
r#"<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="{size}" height="{size}" fill="currentColor"><path d="{path}"/></svg>"#
);
VNode::Element(Box::new(
VElement::new("span")
.class("hi-icon-inline")
.attr(
"style",
&format!("display:inline-flex;align-items:center;width:{size}px;height:{size}px"),
)
.attr("aria-hidden", "true")
.dangerous_inner_html(&svg),
))
}