Separate resolved theme values from configuration resolution

This commit is contained in:
Samuel Onoja committed 2026-10-02 23:57:02 +01:00
1 parent 4c3e884438
commit 8195b82073
13 files changed
+509 -477

No files matched your search

+2 -51
View File
@@ -1,54 +1,5 @@
use serde::{Deserialize, Serialize};
use crate::theme::{Appearance, Tokens};
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
pub struct Palette {
pub background: String,
pub bar: String,
pub surface: String,
pub text: String,
pub muted: String,
pub accent: String,
}
impl From<&Tokens> for Palette {
fn from(tokens: &Tokens) -> Self {
Self {
background: tokens.colors.surface_base.clone(),
bar: tokens.surface.bar.background.clone(),
surface: tokens.colors.surface_raised.clone(),
text: tokens.colors.text_primary.clone(),
muted: tokens.colors.text_muted.clone(),
accent: tokens.colors.accent.clone(),
}
}
}
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
pub struct Family {
pub id: String,
pub name: String,
pub light: Option<Palette>,
pub dark: Option<Palette>,
}
impl Family {
pub fn palette(&self, appearance: Appearance) -> Option<&Palette> {
match appearance {
Appearance::Light => self.light.as_ref(),
Appearance::Dark => self.dark.as_ref(),
}
}
pub fn availability(&self) -> &'static str {
match (self.light.is_some(), self.dark.is_some()) {
(true, true) => "light and dark",
(true, false) => "light only",
_ => "dark only",
}
}
}
use crate::theme::Appearance;
pub use ferese_theme_model::families::{Family, Palette};
pub const BUILTINS: [(&str, &str, &str, &str); 6] = [
("ferese-blue", "Ferese Blue", "ferese-blue-light", "ferese-blue"),