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