freya_components/icons/
tick.rs

1use freya_core::prelude::*;
2use torin::{
3    gaps::Gaps,
4    size::Size,
5};
6
7#[derive(Clone, PartialEq)]
8pub struct TickIcon {
9    width: Size,
10    height: Size,
11    margin: Gaps,
12    fill: Color,
13}
14
15impl Default for TickIcon {
16    fn default() -> Self {
17        Self::new()
18    }
19}
20
21impl TickIcon {
22    pub fn new() -> Self {
23        Self {
24            width: Size::px(10.),
25            height: Size::px(10.),
26            margin: Gaps::new_all(0.),
27            fill: Color::BLACK,
28        }
29    }
30
31    pub fn width(mut self, width: impl Into<Size>) -> Self {
32        self.width = width.into();
33        self
34    }
35
36    pub fn height(mut self, height: impl Into<Size>) -> Self {
37        self.height = height.into();
38        self
39    }
40
41    pub fn margin(mut self, margin: impl Into<Gaps>) -> Self {
42        self.margin = margin.into();
43        self
44    }
45
46    pub fn fill(mut self, fill: impl Into<Color>) -> Self {
47        self.fill = fill.into();
48        self
49    }
50}
51
52impl Render for TickIcon {
53    fn render(&self) -> impl IntoElement {
54        svg(Bytes::from_static(
55            r#"
56            <svg viewBox="0 0 333 263" fill="none" xmlns="http://www.w3.org/2000/svg">
57                <path d="M304.109 0L333 28.8909L99.1812 262.71L70.2903 233.819L304.109 0Z"/>
58                <path d="M0 163.53L27.1003 136.429L126.003 235.332L98.9029 262.433L0 163.53Z"/>
59            </svg>
60        "#
61            .as_bytes(),
62        ))
63        .width(self.width.clone())
64        .height(self.height.clone())
65        .fill(self.fill)
66    }
67}