use dioxus::prelude::*;
use std::{borrow::Cow, rc::Rc};
#[component]
pub fn Theme(
#[props(into, default = Cow::Borrowed("#6750A4"))]
primary_color: Cow<'static, str>,
#[props(into, default = Cow::Borrowed("#eeeeee"))]
background_color: Cow<'static, str>,
#[props(into, default = Cow::Borrowed("#E8DEF8"))]
secondary_container_color: Cow<'static, str>,
#[props(into, default = Cow::Borrowed("25px"))]
border_radius_medium: Cow<'static, str>,
#[props(into, default = Cow::Borrowed("8px"))]
border_radius_small: Cow<'static, str>,
#[props(default = 12.)]
label_small: f32,
#[props(default = 16.)]
label_medium: f32,
children: Element,
) -> Element {
use_context_provider(move || {
Rc::new(UseTheme {
primary_color: primary_color.clone(),
background_color: background_color.clone(),
secondary_container_color: secondary_container_color.clone(),
border_radius_medium: border_radius_medium.clone(),
border_radius_small: border_radius_small.clone(),
label_small,
label_medium,
})
});
children
}
pub struct UseTheme {
pub primary_color: Cow<'static, str>,
pub background_color: Cow<'static, str>,
pub secondary_container_color: Cow<'static, str>,
pub border_radius_medium: Cow<'static, str>,
pub border_radius_small: Cow<'static, str>,
pub label_small: f32,
pub label_medium: f32,
}
pub fn use_theme() -> Rc<UseTheme> {
use_context()
}