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
pub mod default_ds;
use crate::prelude::*;
use savory_style as style;
use std::{ops::Deref, rc::Rc};
#[derive(Clone)]
pub struct DesignSystemChanged(pub DesignSystem);
#[derive(Clone)]
pub struct DesignSystem(Rc<dyn DesignSystemImpl>);
impl Default for DesignSystem {
fn default() -> Self {
DesignSystem::new(default_ds::SavoryDS::default())
}
}
impl DesignSystem {
pub fn new<DS: DesignSystemImpl + 'static>(ds: DS) -> Self {
Self(Rc::new(ds))
}
}
impl Deref for DesignSystem {
type Target = dyn DesignSystemImpl;
fn deref(&self) -> &Self::Target {
self.0.deref()
}
}
pub trait DesignSystemImpl {
fn text(&self, class: text::TextLens<'_>) -> style::Style;
fn button(&self, class: button::ButtonLens) -> style::Style;
fn switch(&self, class: switch::SwitchLens<'_>) -> switch::StyleMap;
fn radio(&self, class: radio::RadioLens<'_>) -> radio::StyleMap;
fn text_input(&self, class: text_input::TextInputLens) -> style::Style;
fn progress_bar(&self, class: progress_bar::ProgressBarLens) -> progress_bar::StyleMap;
}