pub fn construct_theme(theme: Theme<'_>) -> StyleExpand description
Make classes available to a component using a given color theme.
Examples found in repository?
examples/gallery.rs (line 86)
22fn view(theme: Theme<'static>) -> impl IntoView {
23 let text = RwSignal::new(String::new());
24 let checked = RwSignal::new(false);
25 let slider_pct = RwSignal::new(Pct::from(50.0));
26 let active_id = RwSignal::new(1);
27
28 container(h_stack((
29 v_stack((
30 button("Button").class(Button),
31 label(|| "Label").class(Label),
32 text_input(text).placeholder("Text input").class(TextInput),
33 toggle_button(|| true).class(ToggleButton),
34 avatar(
35 || {
36 fs::read("examples/silly_robot_avatar.png")
37 .expect("failed to read avatar picture")
38 },
39 50,
40 theme,
41 ),
42 ))
43 .style(|s| s.padding(10).gap(10).width(150)),
44 separator(theme),
45 v_stack((
46 labeled_checkbox(checked, || "Checkbox", theme)
47 .style(|s| s.align_self(Some(floem::taffy::AlignItems::Start))),
48 labeled_radio_button(checked.get(), checked, || "Radio button", theme)
49 .class(RadioButton),
50 label(|| "Badge 1").class(BadgeOne),
51 label(|| "Badge 2").class(BadgeTwo),
52 label(|| "Badge 3").class(BadgeThree),
53 label(|| "Badge 4").class(BadgeFour),
54 label(|| "Badge 5").class(BadgeFive),
55 ))
56 .style(|s| s.padding(10).gap(10).width(150)),
57 separator(theme),
58 v_stack((
59 slider(slider_pct, theme),
60 progress_bar(slider_pct, theme),
61 accordion_item(
62 label(|| "I'm some text").class(Label),
63 || "Accordion item 0",
64 0,
65 active_id,
66 theme,
67 ),
68 accordion_item(
69 label(|| "I'm some more text").class(Label),
70 || "Accordion item 1",
71 1,
72 active_id,
73 theme,
74 ),
75 accordion_item(
76 label(|| "Fuck facists, btw").class(Label),
77 || "Accordion item 2",
78 2,
79 active_id,
80 theme,
81 ),
82 ))
83 .style(|s| s.padding(10).gap(10).width(150)),
84 )))
85 .style(move |_| {
86 construct_theme(theme)
87 .height_full()
88 .width_full()
89 .justify_center()
90 .items_center()
91 .background(Color::parse(theme.base00).unwrap())
92 })
93}