windjammer_ui/components/generated/
stepper.rs1#![allow(clippy::all)]
2#![allow(noop_method_call)]
3use super::traits::Renderable;
4
5#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)]
6pub struct StepperStep {
7 pub label: String,
8 pub description: String,
9 pub completed: bool,
10}
11
12impl StepperStep {
13 #[inline]
14 pub fn new(label: String) -> StepperStep {
15 StepperStep {
16 label,
17 description: String::new(),
18 completed: false,
19 }
20 }
21 #[inline]
22 pub fn description(mut self, desc: String) -> StepperStep {
23 self.description = desc;
24 self
25 }
26 #[inline]
27 pub fn completed(mut self, completed: bool) -> StepperStep {
28 self.completed = completed;
29 self
30 }
31}
32
33#[derive(Debug, Clone)]
34pub struct Stepper {
35 pub steps: Vec<StepperStep>,
36 pub current_step: i32,
37}
38
39impl Stepper {
40 #[inline]
41 pub fn new() -> Stepper {
42 Stepper {
43 steps: Vec::new(),
44 current_step: 0,
45 }
46 }
47 #[inline]
48 pub fn step(mut self, step: StepperStep) -> Stepper {
49 self.steps.push(step);
50 self
51 }
52 #[inline]
53 pub fn current_step(mut self, index: i32) -> Stepper {
54 self.current_step = index;
55 self
56 }
57}
58
59impl Renderable for Stepper {
60 #[inline]
61 fn render(self) -> String {
62 let mut html = String::new();
63 html.push_str("<div style='display: flex; align-items: center; justify-content: space-between; padding: 24px 0;'>");
64 let total_steps = self.steps.len() as i32;
65 for (step_index, step) in self.steps.iter().enumerate() {
66 let step_index = step_index as i32;
67 let is_current = step_index == self.current_step;
68 let is_completed = step.completed || step_index < self.current_step;
69 html.push_str("<div style='display: flex; flex-direction: column; align-items: center; flex: 1;'>");
70 let bg_color = {
71 if is_completed {
72 "#10b981".to_string()
73 } else {
74 if is_current {
75 "#3b82f6".to_string()
76 } else {
77 "#e2e8f0".to_string()
78 }
79 }
80 };
81 let text_color = {
82 if is_completed || is_current {
83 "white".to_string()
84 } else {
85 "#718096".to_string()
86 }
87 };
88 html.push_str(
89 "<div style='width: 40px; height: 40px; border-radius: 50%; background: ",
90 );
91 html.push_str(&bg_color);
92 html.push_str("; color: ");
93 html.push_str(&text_color);
94 html.push_str("; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 16px; margin-bottom: 8px;'>");
95 if is_completed {
96 html.push('✓')
97 } else {
98 html.push_str(&format!("{}", step_index + 1))
99 }
100 html.push_str("</div>");
101 html.push_str("<div style='text-align: center;'>");
102 html.push_str("<div style='font-weight: 600; font-size: 14px; color: ");
103 if is_current {
104 html.push_str("#1a202c")
105 } else {
106 html.push_str("#718096")
107 }
108 html.push_str("; margin-bottom: 4px;'>");
109 html.push_str(&step.label);
110 html.push_str("</div>");
111 if step.description.len() > (0 as usize) {
112 html.push_str("<div style='font-size: 12px; color: #a0aec0;'>");
113 html.push_str(&step.description);
114 html.push_str("</div>")
115 }
116 html.push_str("</div>");
117 html.push_str("</div>");
118 if step_index < total_steps - 1 {
119 let line_color = {
120 if is_completed {
121 "#10b981".to_string()
122 } else {
123 "#e2e8f0".to_string()
124 }
125 };
126 html.push_str("<div style='flex: 1; height: 2px; background: ");
127 html.push_str(&line_color);
128 html.push_str("; margin: 0 8px; margin-bottom: 48px;'></div>")
129 }
130 }
131 html.push_str("</div>");
132 html
133 }
134}