zen_rs/components/
icon.rspub mod github;
use crate::aspects::{Height, Path, Size, StrokeLinecap, StrokeLinejoin, SvgColor, Width};
pub static XMLNS: &str = r"http://www.w3.org/2000/svg";
#[inline]
pub fn icon() -> Icon {
Icon::default()
}
#[derive(Debug, Default, Clone, PartialEq, PartialOrd)]
pub struct Icon {
content: Vec<Path>,
foreground_color: SvgColor,
background_color: SvgColor,
width: Width,
height: Height,
stroke_linecap: Option<StrokeLinecap>,
stroke_linejoin: Option<StrokeLinejoin>,
stroke_width: Option<f64>,
view_box: (u8, u8, u8, u8),
}
impl Icon {
#[inline]
pub fn get_content(&self) -> &[String] {
&(self).content
}
#[inline]
pub fn get_foreground_color(&self) -> &SvgColor {
&self.foreground_color
}
#[inline]
pub fn get_background_color(&self) -> &SvgColor {
&self.background_color
}
#[inline]
pub fn get_width(&self) -> Width {
self.width
}
#[inline]
pub fn get_height(&self) -> Height {
self.height
}
#[inline]
pub fn content(mut self, content: impl ToString) -> Self {
self.content.push(content.to_string());
self
}
#[inline]
pub fn contents(mut self, content: Vec<impl ToString>) -> Self {
self.content
.append(&mut content.iter().map(|x| x.to_string()).collect());
self
}
#[inline]
pub fn foreground_color(mut self, foreground_color: impl ToString) -> Self {
self.foreground_color = SvgColor::Color(foreground_color.to_string());
self
}
#[inline]
pub fn foreground_color_none(mut self) -> Self {
self.foreground_color = SvgColor::None;
self
}
#[inline]
pub fn foreground_color_current_color(mut self) -> Self {
self.foreground_color = SvgColor::CurrentColor;
self
}
#[inline]
pub fn background_color(mut self, background_color: impl ToString) -> Self {
self.background_color = SvgColor::Color(background_color.to_string());
self
}
#[inline]
pub fn background_color_none(mut self) -> Self {
self.background_color = SvgColor::None;
self
}
#[inline]
pub fn background_color_current_color(mut self) -> Self {
self.background_color = SvgColor::CurrentColor;
self
}
#[inline]
pub fn width(mut self, width: Width) -> Self {
self.width = width;
self
}
#[inline]
pub fn height(mut self, height: Height) -> Self {
self.height = height;
self
}
#[inline]
pub fn size(mut self, size: Size) -> Self {
self.width = size;
self.height = size;
self
}
#[inline]
pub fn get_stroke_linejoin(&self) -> Option<StrokeLinejoin> {
self.stroke_linejoin
}
#[inline]
pub fn get_stroke_width(&self) -> Option<f64> {
self.stroke_width
}
#[inline]
pub fn get_view_box(&self) -> (u8, u8, u8, u8) {
self.view_box
}
#[inline]
pub fn get_stroke_linecap(&self) -> Option<StrokeLinecap> {
self.stroke_linecap
}
#[inline]
pub fn stroke_linejoin(mut self, stroke_linejoin: StrokeLinejoin) -> Self {
self.stroke_linejoin = Some(stroke_linejoin);
self
}
#[inline]
pub fn stroke_width(mut self, stroke_width: f64) -> Self {
self.stroke_width = Some(stroke_width);
self
}
#[inline]
pub fn view_box(mut self, view_box: (u8, u8, u8, u8)) -> Self {
self.view_box = view_box;
self
}
#[inline]
pub fn stroke_linecap(mut self, stroke_linecap: StrokeLinecap) -> Self {
self.stroke_linecap = Some(stroke_linecap);
self
}
}