windjammer_ui/components/generated/
skeleton.rs

1#![allow(clippy::all)]
2#![allow(noop_method_call)]
3#[derive(Debug, Clone, PartialEq)]
4pub struct Skeleton {
5    pub variant: SkeletonVariant,
6    pub width: String,
7    pub height: String,
8    pub class: String,
9}
10
11#[derive(Clone, Debug, PartialEq, Copy)]
12pub enum SkeletonVariant {
13    Text,
14    Circle,
15    Rectangle,
16}
17
18impl Skeleton {
19    #[inline]
20    pub fn new() -> Skeleton {
21        Skeleton {
22            variant: SkeletonVariant::Text,
23            width: "100%".to_string(),
24            height: "20px".to_string(),
25            class: String::new(),
26        }
27    }
28    #[inline]
29    pub fn variant(mut self, variant: SkeletonVariant) -> Skeleton {
30        self.variant = variant;
31        self
32    }
33    #[inline]
34    pub fn width(mut self, width: String) -> Skeleton {
35        self.width = width;
36        self
37    }
38    #[inline]
39    pub fn height(mut self, height: String) -> Skeleton {
40        self.height = height;
41        self
42    }
43    #[inline]
44    pub fn class(mut self, class: String) -> Skeleton {
45        self.class = class;
46        self
47    }
48    #[inline]
49    pub fn render(&self) -> String {
50        let border_radius = match self.variant {
51            SkeletonVariant::Text => "4px".to_string(),
52            SkeletonVariant::Circle => "50%".to_string(),
53            SkeletonVariant::Rectangle => "8px".to_string(),
54        };
55        let mut html = String::new();
56        html.push_str("<div class=\"wj-skeleton ");
57        html.push_str(&self.class.as_str());
58        html.push_str("\" style=\"width: ");
59        html.push_str(&self.width.as_str());
60        html.push_str("; height: ");
61        html.push_str(&self.height.as_str());
62        html.push_str("; border-radius: ");
63        html.push_str(&border_radius);
64        html.push_str("; background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%); background-size: 200% 100%; animation: skeleton-loading 1.5s ease-in-out infinite;\"></div>");
65        html.push_str("<style>@keyframes skeleton-loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }</style>");
66        html
67    }
68}