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
//! StatCard component for displaying single metrics in a card format.
use *;
use component_doc;
use inline_style_sheet_values;
use ;
use crateCard;
use crate*;
/// Color variants for the StatCard value display.
/// Dashboard metric card with label, reactive value, and optional status coloring.
///
/// The caller owns number formatting — pass a `Signal<String>` with locale-aware or abbreviated values. Variants map to theme status colors (`Success`, `Danger`, `Warning`) for KPIs that need semantic emphasis.
///
/// # When to use
///
/// - Dashboard KPI rows and summary strips - Numeric or formatted string metrics that update reactively - Status-colored values (success rate, error count, warnings)
///
/// # Examples
///
/// ## Default
/// Single metric card with label and a reactive formatted value in neutral styling. Use for dashboard KPIs and summary rows where color coding is not needed.
/// <!-- default -->
/// <!-- preview -->
/// ```rust
/// view! {
/// <div data-testid="stat-card-preview">
/// <StatCard
/// label="Total Users"
/// value=Signal::derive(|| "1,234".to_string())
/// />
/// </div>
/// }
/// ```
///
/// ## With Icon
/// Stat card with an icon beside the label for quicker visual scanning. Use when the metric type is recognizable by icon, such as users or sessions.
/// <!-- preview -->
/// ```rust
/// view! {
/// <StatCard
/// label="Active Sessions"
/// value=Signal::derive(|| "1,234".to_string())
/// icon=icondata::LuUsers
/// />
/// }
/// ```
///
/// ## Color Variants
/// Success, danger, and warning value colors side by side for status-driven metrics. Use when the number itself conveys health, such as error counts or success rates.
/// <!-- preview -->
/// ```rust
/// use Flex;
///
/// view! {
/// <Flex gap=SpacingSize::Size160.flex_gap()>
/// <StatCard
/// label="Success Rate"
/// value=Signal::derive(|| "98.5%".to_string())
/// variant=StatCardVariant::Success
/// />
/// <StatCard
/// label="Errors"
/// value=Signal::derive(|| "12".to_string())
/// variant=StatCardVariant::Danger
/// />
/// <StatCard
/// label="Warnings"
/// value=Signal::derive(|| "3".to_string())
/// variant=StatCardVariant::Warning
/// />
/// </Flex>
/// }
/// ```
///
/// ## Dashboard Example
/// Wrapped row of stat cards combining icons and color variants on a typical dashboard. Use as a layout reference when building multi-metric summary strips.
/// <!-- preview -->
/// ```rust
/// use Flex;
/// use FlexWrap;
///
/// view! {
/// <Flex gap=SpacingSize::Size160.flex_gap() wrap=FlexWrap::Wrap>
/// <StatCard
/// label="Total Orders"
/// value=Signal::derive(|| "8,492".to_string())
/// icon=icondata::LuShoppingCart
/// />
/// <StatCard
/// label="Revenue"
/// value=Signal::derive(|| "$124.5K".to_string())
/// icon=icondata::LuDollarSign
/// variant=StatCardVariant::Success
/// />
/// <StatCard
/// label="Pending"
/// value=Signal::derive(|| "23".to_string())
/// icon=icondata::LuClock
/// variant=StatCardVariant::Warning
/// />
/// <StatCard
/// label="Failed"
/// value=Signal::derive(|| "5".to_string())
/// icon=icondata::LuAlertTriangle
/// variant=StatCardVariant::Danger
/// />
/// </Flex>
/// }
/// ```