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(default = None)]
pub width: Option<&'static str>,
#[props(default = None)]
pub height: Option<&'static str>,
#[props(default = None)]
pub fill: Option<&'static str>,
#[props(default = None)]
pub stroke: Option<&'static str>,
#[props(default = None)]
pub stroke_width: Option<&'static str>,
#[props(default = None)]
pub stroke_line_cap: Option<&'static str>,
#[props(default = None)]
pub stroke_line_join: 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: if props.width.is_some() {
props.width
} else {
T::WIDTH
},
height: if props.height.is_some() {
props.height
} else {
T::HEIGHT
},
fill: if props.fill.is_some() {
props.fill
} else {
T::FILL
},
stroke: if props.stroke.is_some() {
props.stroke
} else {
T::STROKE
},
stroke_width: if props.stroke_width.is_some() {
props.stroke_width
} else {
T::STROKE_WIDTH
},
stroke_linecap: if props.stroke_line_cap.is_some() {
props.stroke_line_cap
} else {
T::STROKE_LINE_CAP
},
stroke_linejoin: if props.stroke_line_join.is_some() {
props.stroke_line_join
} else {
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()}
}
}
}