port bezel theme system into the theme crate

This commit is contained in:
2026-10-09 08:42:54 +07:00
parent 22f57def7d
commit 90377c8c76
14 changed files with 2121 additions and 566 deletions
+13 -2
View File
@@ -18,6 +18,15 @@ impl ThemeMode {
matches!(self, Self::Dark)
}
pub fn is_light(&self) -> bool {
matches!(self, Self::Light)
}
/// Map a gpui window appearance onto ours.
pub fn from_window(appearance: WindowAppearance) -> Self {
Self::from(appearance)
}
/// Return theme name: `light`, `dark`.
pub fn name(&self) -> &'static str {
match self {
@@ -117,9 +126,11 @@ impl ThemeFamily {
/// # Ok(())
/// # }
/// ```
pub(crate) fn from_file<P: AsRef<Path>>(path: P) -> anyhow::Result<Self> {
pub fn from_file<P: AsRef<Path>>(path: P) -> anyhow::Result<Self> {
let json_data = std::fs::read(path)?;
let theme_family = serde_json::from_slice(&json_data)?;
let mut theme_family: ThemeFamily = serde_json::from_slice(&json_data)?;
theme_family.light.rederive_tokens(ThemeMode::Light);
theme_family.dark.rederive_tokens(ThemeMode::Dark);
Ok(theme_family)
}