1use dioxus::prelude::*;
2use std::{borrow::Cow, rc::Rc};
3
4#[component]
8pub fn Theme(
9 #[props(into, default = Cow::Borrowed("#6750A4"))]
11 primary_color: Cow<'static, str>,
12
13 #[props(into, default = Cow::Borrowed("#eeeeee"))]
15 background_color: Cow<'static, str>,
16
17 #[props(into, default = Cow::Borrowed("#E8DEF8"))]
19 secondary_container_color: Cow<'static, str>,
20
21 #[props(into, default = Cow::Borrowed("25px"))]
23 border_radius_medium: Cow<'static, str>,
24
25 #[props(into, default = Cow::Borrowed("8px"))]
27 border_radius_small: Cow<'static, str>,
28
29 #[props(default = 12.)]
31 label_small: f32,
32
33 #[props(default = 16.)]
35 label_medium: f32,
36
37 children: Element,
38) -> Element {
39 use_context_provider(move || {
40 Rc::new(UseTheme {
41 primary_color: primary_color.clone(),
42 background_color: background_color.clone(),
43 secondary_container_color: secondary_container_color.clone(),
44 border_radius_medium: border_radius_medium.clone(),
45 border_radius_small: border_radius_small.clone(),
46 label_small,
47 label_medium,
48 })
49 });
50
51 children
52}
53
54pub struct UseTheme {
55 pub primary_color: Cow<'static, str>,
56 pub background_color: Cow<'static, str>,
57 pub secondary_container_color: Cow<'static, str>,
58 pub border_radius_medium: Cow<'static, str>,
59 pub border_radius_small: Cow<'static, str>,
60 pub label_small: f32,
61 pub label_medium: f32,
62}
63
64pub fn use_theme() -> Rc<UseTheme> {
65 use_context()
66}