freya_components/icons/
tick.rs1use freya_core::prelude::*;
2use torin::{
3 gaps::Gaps,
4 node::Node,
5 size::Size,
6};
7
8#[derive(Clone, PartialEq)]
9pub struct TickIcon {
10 layout: LayoutData,
11 fill: Color,
12}
13
14impl LayoutExt for TickIcon {
15 fn get_layout(&mut self) -> &mut LayoutData {
16 &mut self.layout
17 }
18}
19
20impl ContainerSizeExt for TickIcon {}
21
22impl Default for TickIcon {
23 fn default() -> Self {
24 Self::new()
25 }
26}
27
28impl TickIcon {
29 pub fn new() -> Self {
30 Self {
31 layout: Node {
32 width: Size::px(10.),
33 height: Size::px(10.),
34 ..Default::default()
35 }
36 .into(),
37 fill: Color::BLACK,
38 }
39 }
40
41 pub fn margin(mut self, margin: impl Into<Gaps>) -> Self {
42 self.layout.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 Component 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.layout.width.clone())
64 .height(self.layout.height.clone())
65 .margin(self.layout.margin)
66 .fill(self.fill)
67 }
68}