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
use crateTheme;
use crateView;
/// A self-contained UI component that owns its state and knows how to render itself.
///
/// Implement this on any struct that holds `Signal` fields. `render` receives the
/// active `Theme` so components can read semantic color tokens instead of
/// hardcoding values. It is called every frame and should return a fresh `View`
/// tree.
///
/// # Example
///
/// ```rust
/// use core_glyph::{Component, Signal, Theme, View, button, column, text};
///
/// struct Counter { count: Signal<i32> }
///
/// impl Component for Counter {
/// fn render(&self, theme: &Theme) -> View {
/// let count = self.count.clone();
/// column(vec![
/// text(format!("{}", self.count.get()), 32.0).into(),
/// button("Add", move || count.set(count.get() + 1))
/// .bg(theme.primary)
/// .text_color(theme.on_primary)
/// .radius(theme.radius)
/// .into(),
/// ]).into()
/// }
/// }
/// ```