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
//! Button 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(
"Button Variants",
"Standard button styles",
Border::rounded()
.title(" Button Variants ")
.min_width(35)
.min_height(14)
.child(
vstack()
.gap(1)
.child(Text::new("Standard button styles:").fg(primary))
.child(Text::new(""))
.child(
hstack()
.gap(2)
.child(Button::primary("Primary"))
.child(Button::new("Default"))
.child(Button::new("Danger").variant(ButtonVariant::Danger)),
)
.child(
hstack()
.gap(2)
.child(Button::new("Success").variant(ButtonVariant::Success))
.child(Button::new("Danger").variant(ButtonVariant::Danger))
.child(Button::new("Ghost").variant(ButtonVariant::Ghost)),
)
.child(Text::new(""))
.child(Text::new("• Primary: Main call-to-action").fg(muted))
.child(Text::new("• Default: Standard actions").fg(muted))
.child(Text::new("• Danger: Destructive actions").fg(muted))
.child(Text::new("• Success: Positive actions").fg(muted))
.child(Text::new("• Ghost: Subtle/minimal actions").fg(muted)),
),
),
Example::new(
"Button Sizes",
"Different sizes for various contexts",
Border::rounded()
.title(" Button Sizes ")
.min_width(30)
.min_height(14)
.child(
vstack()
.gap(1)
.child(Text::new("Different sizes:").fg(primary))
.child(Text::new(""))
.child(
hstack()
.gap(2)
.child(Button::new("Small"))
.child(Button::new("Medium"))
.child(Button::new("Large")),
)
.child(Text::new(""))
.child(Text::new("• Compact UIs").fg(muted))
.child(Text::new("• Standard size").fg(muted))
.child(Text::new("• Emphasis/importance").fg(muted)),
),
),
Example::new(
"Icon Buttons",
"Buttons with icons and symbols",
Border::rounded()
.title(" Icon Buttons ")
.min_width(35)
.min_height(14)
.child(
vstack()
.gap(1)
.child(Text::new("Buttons with icons:").fg(primary))
.child(Text::new(""))
.child(
hstack()
.gap(2)
.child(Button::new("♥ Like"))
.child(Button::new("★ Star"))
.child(Button::new("✓ Done"))
.child(Button::new("✕ Cancel")),
)
.child(Text::new(""))
.child(Text::new("• Combine text with symbols").fg(muted))
.child(Text::new("• Use Unicode characters").fg(muted))
.child(Text::new("• Icon-only buttons supported").fg(muted)),
),
),
Example::new(
"Interactive States",
"Button states and interactions",
Border::rounded()
.title(" Interactive States ")
.min_width(35)
.min_height(12)
.child(
vstack()
.gap(1)
.child(Text::new("Button states:").fg(primary))
.child(Text::new(""))
.child(
hstack()
.gap(2)
.child(Button::new("Normal"))
.child(Button::new("Disabled").disabled(true)),
)
.child(Text::new(""))
.child(Text::new("• Normal: Default interactive").fg(muted))
.child(Text::new("• Hover: When focused (see focus ring)").fg(muted))
.child(Text::new("• Disabled: Non-interactive").fg(muted))
.child(Text::new("• Pressed: During click action").fg(muted)),
),
),
Example::new(
"Button Groups",
"Grouped and connected buttons",
Border::rounded()
.title(" Button Groups ")
.min_width(40)
.min_height(12)
.child(
vstack()
.gap(1)
.child(Text::new("Grouped buttons:").fg(primary))
.child(Text::new(""))
.child(
hstack()
.gap(0)
.child(Button::new("Left"))
.child(Button::new("Center"))
.child(Button::new("Right")),
)
.child(Text::new(""))
.child(
hstack()
.gap(1)
.child(Button::new("◄ Prev"))
.child(Button::new("1"))
.child(Button::new("2"))
.child(Button::new("3"))
.child(Button::new("Next ►")),
),
),
),
]
}