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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
//! Stack widget demos
use crate::example::Example;
use crate::theme_colors;
use revue::prelude::*;
pub fn examples() -> Vec<Example> {
let (primary, _success, _warning, _error, _info, muted, text, _) = theme_colors();
vec![
Example::new(
"VStack",
"Vertical stack layout arranging children top to bottom",
Border::rounded().title(" VStack ").child(
vstack()
.gap(1)
.child(Text::new("Vertical stack:").fg(primary))
.child(Text::new("Item 1").fg(text))
.child(Text::new("Item 2").fg(text))
.child(Text::new("Item 3").fg(text))
.child(Text::new("Item 4").fg(text))
.child(Text::new(""))
.child(Text::new("• Vertical arrangement").fg(muted))
.child(Text::new("• Top to bottom").fg(muted))
.child(Text::new("• Gap control").fg(muted)),
),
),
Example::new(
"HStack",
"Horizontal stack layout arranging children left to right",
Border::rounded().title(" HStack ").child(
vstack()
.gap(1)
.child(Text::new("Horizontal stack:").fg(primary))
.child(
hstack()
.gap(2)
.child(Text::new("A").fg(text))
.child(Text::new("B").fg(text))
.child(Text::new("C").fg(text))
.child(Text::new("D").fg(text)),
)
.child(Text::new(""))
.child(
hstack()
.gap(1)
.child(Button::new("1"))
.child(Button::new("2"))
.child(Button::new("3")),
)
.child(Text::new(""))
.child(Text::new("• Horizontal arrangement").fg(muted))
.child(Text::new("• Left to right").fg(muted))
.child(Text::new("• Responsive sizing").fg(muted)),
),
),
Example::new(
"Layers",
"Overlapping layer stack with z-index ordering",
Border::rounded().title(" Layers ").child(
vstack()
.gap(1)
.child(Text::new("Overlapping layers:").fg(primary))
.child(
Layers::new()
.child(
Border::rounded()
.title("Back")
.child(Text::new("Layer 1").fg(text)),
)
.child(
Border::rounded()
.title("Middle")
.child(Text::new("Layer 2").fg(text)),
)
.child(
Border::rounded()
.title("Front")
.child(Text::new("Layer 3").fg(text)),
),
)
.child(Text::new(""))
.child(Text::new("• Z-index stacking").fg(muted))
.child(Text::new("• Overlay support").fg(muted))
.child(Text::new("• Modal patterns").fg(muted)),
),
),
Example::new(
"Gap Variations",
"Controlling spacing between stack children",
Border::rounded().title(" Gap Variations ").child(
vstack()
.gap(1)
.child(Text::new("Gap = 0:").fg(primary))
.child(
vstack()
.gap(0)
.child(Text::new("A"))
.child(Text::new("B"))
.child(Text::new("C")),
)
.child(Text::new(""))
.child(Text::new("Gap = 1:").fg(primary))
.child(
vstack()
.gap(1)
.child(Text::new("A"))
.child(Text::new("B"))
.child(Text::new("C")),
)
.child(Text::new(""))
.child(Text::new("Gap = 2:").fg(primary))
.child(
vstack()
.gap(2)
.child(Text::new("A"))
.child(Text::new("B"))
.child(Text::new("C")),
)
.child(Text::new(""))
.child(Text::new("• Spacing control").fg(muted))
.child(Text::new("• Tight to loose").fg(muted)),
),
),
Example::new(
"Alignment",
"Text and child alignment within stacks",
Border::rounded().title(" Alignment ").child(
vstack()
.gap(1)
.child(Text::new("VStack alignment:").fg(primary))
.child(
vstack()
.child(Text::new("Left").fg(text))
.child(Text::new("Aligned").fg(text)),
)
.child(
vstack()
.child(Text::new("Center").fg(text))
.child(Text::new("Aligned").fg(text)),
)
.child(
vstack()
.child(Text::new("Right").fg(text))
.child(Text::new("Aligned").fg(text)),
)
.child(Text::new(""))
.child(Text::new("• Text alignment").fg(muted))
.child(Text::new("• Child positioning").fg(muted)),
),
),
Example::new(
"Spacing",
"Space distribution between children",
Border::rounded().title(" Spacing ").child(
vstack()
.gap(1)
.child(Text::new("Space between:").fg(primary))
.child(
hstack()
.gap(4)
.child(Text::new("Left").fg(text))
.child(Text::new("Right").fg(text)),
)
.child(Text::new(""))
.child(Text::new("Space around:").fg(primary))
.child(
hstack()
.gap(2)
.child(Text::new("A").fg(text))
.child(Text::new("B").fg(text))
.child(Text::new("C").fg(text)),
)
.child(Text::new(""))
.child(Text::new("• Distribution").fg(muted))
.child(Text::new("• Flexible spacing").fg(muted)),
),
),
Example::new(
"Constrained Stack",
"Stacks with min/max size constraints",
Border::rounded().title(" Constrained Stack ").child(
vstack()
.gap(1)
.child(Text::new("Size-limited stack:").fg(primary))
.child(
vstack()
.gap(1)
.min_width(15)
.max_width(25)
.child(Text::new("Min 15w, Max 25w").fg(text))
.child(Text::new("Constrained width").fg(muted)),
)
.child(Text::new(""))
.child(
hstack()
.gap(1)
.min_height(2)
.max_height(3)
.child(Text::new("A").fg(text))
.child(Text::new("B").fg(text))
.child(Text::new("Min 2h, Max 3h").fg(muted)),
)
.child(Text::new(""))
.child(Text::new("• min_width() / min_height()").fg(muted))
.child(Text::new("• max_width() / max_height()").fg(muted))
.child(Text::new("• Responsive sizing").fg(muted)),
),
),
Example::new(
"Constrained Layers",
"Layers with min/max size constraints",
Border::rounded().title(" Constrained Layers ").child(
vstack()
.gap(1)
.child(Text::new("Size-limited layers:").fg(primary))
.child(
Layers::new()
.min_size(20, 3)
.max_size(35, 5)
.child(Border::rounded().child(Text::new("Layer 1")))
.child(Border::rounded().child(Text::new("Layer 2"))),
)
.child(Text::new(""))
.child(Text::new("• Min/max dimensions").fg(muted))
.child(Text::new("• Overlay constraints").fg(muted))
.child(Text::new("• Prevent overflow").fg(muted)),
),
),
Example::new(
"constrain() Helper",
"Set all size limits with a single call",
Border::rounded().title(" constrain() Helper ").child(
vstack()
.gap(1)
.child(Text::new("Set all at once:").fg(primary))
.child(
vstack()
.gap(0)
.constrain(10, 2, 30, 5)
.child(Text::new("10-30w, 2-5h").fg(text))
.child(Text::new("Constrained stack").fg(muted)),
)
.child(Text::new(""))
.child(Text::new("• .constrain(min_w, min_h, max_w, max_h)").fg(muted))
.child(Text::new("• One call for all limits").fg(muted))
.child(Text::new("• Cleaner code").fg(muted)),
),
),
]
}