beuvy_runtime/stylesheet/
model.rs1use crate::style::UiThemeConfig;
2use std::collections::{HashMap, HashSet};
3
4#[derive(Debug, Clone)]
5pub struct UiStyleSheet {
6 pub(super) config: UiThemeConfig,
7 pub(super) color_tokens: HashSet<String>,
8 pub(super) text_tokens: HashSet<String>,
9 pub(super) radius_tokens: HashSet<String>,
10 pub(super) utilities: HashMap<String, Vec<String>>,
11}
12
13impl UiStyleSheet {
14 pub fn config(&self) -> &UiThemeConfig {
15 &self.config
16 }
17}
18
19#[derive(Debug, Clone, PartialEq, Eq)]
20pub enum RuntimeStyleSource {
21 BuiltIn,
22 File(String),
23}
24
25impl RuntimeStyleSource {
26 pub fn built_in() -> Self {
27 Self::BuiltIn
28 }
29
30 pub fn file(path: impl Into<String>) -> Self {
31 Self::File(path.into())
32 }
33}
34
35impl Default for RuntimeStyleSource {
36 fn default() -> Self {
37 Self::BuiltIn
38 }
39}
40
41impl Default for UiStyleSheet {
42 fn default() -> Self {
43 Self {
44 config: UiThemeConfig::default(),
45 color_tokens: HashSet::new(),
46 text_tokens: HashSet::new(),
47 radius_tokens: HashSet::new(),
48 utilities: HashMap::new(),
49 }
50 }
51}
52
53#[derive(Debug, Clone, PartialEq, Eq)]
54pub struct StyleSheetError {
55 pub reason: String,
56}
57
58impl StyleSheetError {
59 pub(super) fn new(reason: impl Into<String>) -> Self {
60 Self {
61 reason: reason.into(),
62 }
63 }
64}
65
66impl std::fmt::Display for StyleSheetError {
67 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
68 self.reason.fmt(f)
69 }
70}
71
72impl std::error::Error for StyleSheetError {}