use dioxus::prelude::*;
pub trait IconShape: Clone + PartialEq + 'static {
fn child_elements(&self) -> Element;
const TITLE: Option<&'static str> = None;
const WIDTH: Option<&'static str> = None;
const HEIGHT: Option<&'static str> = None;
const FILL: Option<&'static str> = Some("currentColor");
const STROKE: Option<&'static str> = None;
const STROKE_WIDTH: Option<&'static str> = None;
const STROKE_LINE_CAP: Option<&'static str> = None;
const STROKE_LINE_JOIN: Option<&'static str> = None;
const VIEW_BOX: Option<&'static str> = None;
const XMLNS: Option<&'static str> = Some("http://www.w3.org/2000/svg");
}
#[derive(Clone, PartialEq, Props)]
pub struct IconProps<T: IconShape> {
pub icon: T,
#[props(default = None)]
pub title: Option<&'static str>,
#[props(extends = GlobalAttributes)]
pub attributes: Vec<Attribute>,
}
#[allow(non_snake_case)]
pub fn Icon<T: IconShape>(props: IconProps<T>) -> Element {
rsx! {
svg {
width: T::WIDTH,
height: T::HEIGHT,
fill: T::FILL,
stroke: T::STROKE,
stroke_width: T::STROKE_WIDTH,
stroke_linecap: T::STROKE_LINE_CAP,
stroke_linejoin: T::STROKE_LINE_JOIN,
view_box: T::VIEW_BOX,
xmlns: T::XMLNS,
..props.attributes,
if let Some(title_text) = props.title {
title {{ title_text }}
} else if let Some(title_text) = T::TITLE {
title {{ title_text }}
}
{props.icon.child_elements()}
}
}
}