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 margin: Gaps,
12 fill: Color,
13}
14
15impl LayoutExt for TickIcon {
16 fn get_layout(&mut self) -> &mut LayoutData {
17 &mut self.layout
18 }
19}
20
21impl ContainerSizeExt for TickIcon {}
22
23impl Default for TickIcon {
24 fn default() -> Self {
25 Self::new()
26 }
27}
28
29impl TickIcon {
30 pub fn new() -> Self {
31 Self {
32 layout: Node {
33 width: Size::px(10.),
34 height: Size::px(10.),
35 ..Default::default()
36 }
37 .into(),
38 margin: Gaps::new_all(0.),
39 fill: Color::BLACK,
40 }
41 }
42
43 pub fn margin(mut self, margin: impl Into<Gaps>) -> Self {
44 self.margin = margin.into();
45 self
46 }
47
48 pub fn fill(mut self, fill: impl Into<Color>) -> Self {
49 self.fill = fill.into();
50 self
51 }
52}
53
54impl Component for TickIcon {
55 fn render(&self) -> impl IntoElement {
56 svg(Bytes::from_static(
57 r#"
58 <svg viewBox="0 0 333 263" fill="none" xmlns="http://www.w3.org/2000/svg">
59 <path d="M304.109 0L333 28.8909L99.1812 262.71L70.2903 233.819L304.109 0Z"/>
60 <path d="M0 163.53L27.1003 136.429L126.003 235.332L98.9029 262.433L0 163.53Z"/>
61 </svg>
62 "#
63 .as_bytes(),
64 ))
65 .width(self.layout.width.clone())
66 .height(self.layout.height.clone())
67 .fill(self.fill)
68 }
69}