1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
use blaeck::prelude::*;
const TASKS: &[(&str, Option<Color>)] = &[
("Initializing...", None),
("Scanning directory", None),
("Read(/blaeck/src/lib.rs)", Some(Color::DarkGray)),
("Read(/blaeck/src/main.rs)", Some(Color::DarkGray)),
("Error reading file", Some(Color::Red)),
("Glob(**/*.rs)", Some(Color::DarkGray)),
("Found 42 files", None),
("Analyzing imports", None),
("Building dependency graph", None),
("Optimization complete", Some(Color::Green)),
];
fn make_lines(count: usize) -> Vec<LogLine> {
TASKS
.iter()
.take(count)
.map(|(msg, color)| {
if let Some(c) = color {
LogLine::new(*msg).color(*c)
} else {
LogLine::new(*msg)
}
})
.collect()
}
/// Animated preview — lines appear one by one, then shows multi-variant final state.
pub fn build_ui_with_timer(timer: &AnimationTimer) -> Element {
let elapsed = timer.elapsed_ms() as usize;
// Phase 1: streaming (400ms per line, 10 lines = 4000ms)
// Phase 2: hold final state for 1000ms
// Phase 3: multi-variant view for 3000ms
// Then loop (cycle = 8000ms)
let cycle_ms = 8000;
let phase_time = elapsed % cycle_ms;
if phase_time < 4000 {
// Streaming phase
let line_count = (phase_time / 400 + 1).min(TASKS.len());
let lines = make_lines(line_count);
build_streaming_ui(&lines, line_count, TASKS.len())
} else {
// Final multi-variant view
build_final_ui()
}
}
fn build_streaming_ui(lines: &[LogLine], step: usize, total: usize) -> Element {
Element::node::<Box>(
BoxProps {
flex_direction: FlexDirection::Column,
padding: 1.0,
border_style: BorderStyle::Round,
..Default::default()
},
vec![
Element::node::<Box>(
BoxProps {
flex_direction: FlexDirection::Row,
..Default::default()
},
vec![
Element::node::<Text>(
TextProps {
content: "●".into(),
color: Some(Color::Yellow),
..Default::default()
},
vec![],
),
Element::node::<Text>(
TextProps {
content: " Explore".into(),
bold: true,
..Default::default()
},
vec![],
),
Element::node::<Text>(
TextProps {
content: "(Explore /blaeck repository)".into(),
dim: true,
..Default::default()
},
vec![],
),
],
),
Element::node::<LogBox>(
LogBoxProps::with_lines(lines.to_vec())
.max_lines(5)
.tree_style(TreeStyle::Unicode)
.indent(1),
vec![],
),
Element::text(""),
Element::node::<Text>(
TextProps {
content: format!("Step {}/{}", step, total),
dim: true,
..Default::default()
},
vec![],
),
],
)
}
/// Final state showing three LogBox variants.
pub fn build_final_ui() -> Element {
let lines = make_lines(TASKS.len());
Element::node::<Box>(
BoxProps {
flex_direction: FlexDirection::Column,
gap: 1.0,
..Default::default()
},
vec![
// Example 1: Completed explore task
Element::node::<Box>(
BoxProps {
flex_direction: FlexDirection::Column,
padding: 1.0,
border_style: BorderStyle::Round,
border_color: Some(Color::Green),
..Default::default()
},
vec![
Element::node::<Box>(
BoxProps {
flex_direction: FlexDirection::Row,
..Default::default()
},
vec![
Element::node::<Text>(
TextProps {
content: "●".into(),
color: Some(Color::Green),
..Default::default()
},
vec![],
),
Element::node::<Text>(
TextProps {
content: " Explore".into(),
bold: true,
..Default::default()
},
vec![],
),
Element::node::<Text>(
TextProps {
content: "(completed)".into(),
dim: true,
..Default::default()
},
vec![],
),
],
),
Element::node::<LogBox>(
LogBoxProps::with_lines(lines)
.max_lines(5)
.tree_style(TreeStyle::Unicode)
.indent(1),
vec![],
),
],
),
// Example 2: Simple log without tree style
Element::node::<Box>(
BoxProps {
flex_direction: FlexDirection::Column,
border_style: BorderStyle::Single,
padding: 1.0,
..Default::default()
},
vec![
Element::node::<Text>(
TextProps {
content: "Build Output (no tree, max 3 lines):".into(),
bold: true,
color: Some(Color::Cyan),
..Default::default()
},
vec![],
),
Element::node::<LogBox>(
LogBoxProps::new()
.line("Compiling blaeck v0.1.0")
.line("Compiling blaeck-macros v0.1.0")
.line(LogLine::warning("warning: unused import"))
.line("Compiling example v0.1.0")
.line(LogLine::success("Finished dev [unoptimized] in 2.34s"))
.max_lines(3),
vec![],
),
],
),
// Example 3: Error log
Element::node::<Box>(
BoxProps {
flex_direction: FlexDirection::Column,
border_style: BorderStyle::Single,
border_color: Some(Color::Red),
padding: 1.0,
..Default::default()
},
vec![
Element::node::<Text>(
TextProps {
content: "Error Log:".into(),
bold: true,
color: Some(Color::Red),
..Default::default()
},
vec![],
),
Element::node::<LogBox>(
LogBoxProps::new()
.line(LogLine::error("Error: Connection refused"))
.line(LogLine::muted(" at src/network.rs:42"))
.line(LogLine::muted(" at src/main.rs:15"))
.line(LogLine::warning("Retrying in 5s..."))
.max_lines(10)
.tree_style(TreeStyle::Unicode),
vec![],
),
],
),
],
)
}