windjammer_ui/components/generated/
timeline.rs1#![allow(clippy::all)]
2#![allow(noop_method_call)]
3use super::traits::Renderable;
4
5#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)]
6pub struct TimelineEvent {
7 pub title: String,
8 pub description: String,
9 pub timestamp: String,
10 pub icon: String,
11 pub color: String,
12}
13
14impl TimelineEvent {
15 #[inline]
16 pub fn new(title: String, timestamp: String) -> TimelineEvent {
17 TimelineEvent {
18 title,
19 description: String::new(),
20 timestamp,
21 icon: "●".to_string(),
22 color: "#3b82f6".to_string(),
23 }
24 }
25 #[inline]
26 pub fn description(mut self, desc: String) -> TimelineEvent {
27 self.description = desc;
28 self
29 }
30 #[inline]
31 pub fn icon(mut self, icon: String) -> TimelineEvent {
32 self.icon = icon;
33 self
34 }
35 #[inline]
36 pub fn color(mut self, color: String) -> TimelineEvent {
37 self.color = color;
38 self
39 }
40}
41
42#[derive(Debug, Clone, Default)]
43pub struct Timeline {
44 pub events: Vec<TimelineEvent>,
45}
46
47impl Timeline {
48 #[inline]
49 pub fn new() -> Timeline {
50 Timeline { events: Vec::new() }
51 }
52 #[inline]
53 pub fn event(mut self, event: TimelineEvent) -> Timeline {
54 self.events.push(event);
55 self
56 }
57}
58
59impl Renderable for Timeline {
60 #[inline]
61 fn render(self) -> String {
62 let mut html = String::new();
63 html.push_str("<div style='position: relative; padding-left: 32px;'>");
64 html.push_str("<div style='position: absolute; left: 8px; top: 0; bottom: 0; width: 2px; background: #e2e8f0;'></div>");
65 for (_event_index, event) in self.events.iter().enumerate() {
66 html.push_str("<div style='position: relative; padding-bottom: 32px;'>");
67 html.push_str("<div style='position: absolute; left: -24px; width: 16px; height: 16px; border-radius: 50%; background: ");
68 html.push_str(&event.color);
69 html.push_str("; border: 2px solid white; display: flex; align-items: center; justify-content: center; color: white; font-size: 10px;'>");
70 html.push_str(&event.icon);
71 html.push_str("</div>");
72 html.push_str("<div style='background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);'>");
73 html.push_str("<div style='font-size: 12px; color: #718096; margin-bottom: 4px;'>");
74 html.push_str(&event.timestamp);
75 html.push_str("</div>");
76 html.push_str("<div style='font-weight: 600; font-size: 16px; color: #1a202c; margin-bottom: 8px;'>");
77 html.push_str(&event.title);
78 html.push_str("</div>");
79 if event.description.len() > (0 as usize) {
80 html.push_str("<div style='font-size: 14px; color: #4a5568;'>");
81 html.push_str(&event.description);
82 html.push_str("</div>")
83 }
84 html.push_str("</div>");
85 html.push_str("</div>");
86 }
87 html.push_str("</div>");
88 html
89 }
90}