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
+6 -3
View File
@@ -5,7 +5,7 @@ use std::sync::Arc;
use anyhow::{Context as AnyhowContext, Error};
use gpui::{App, AppContext, AssetSource, Context, Entity, Global, SharedString};
use crate::ThemeFamily;
use crate::{ThemeFamily, ThemeMode};
pub fn init(cx: &mut App) {
ThemeRegistry::set_global(cx.new(ThemeRegistry::new), cx);
@@ -57,8 +57,11 @@ impl ThemeRegistry {
// Load the theme file from the assets
let content = asset.load(path)?.context("Theme not found")?;
// Parse the JSON content into a Theme Family struct
let theme: ThemeFamily = serde_json::from_slice(&content)?;
// Parse the JSON content into a Theme Family struct, and re-derive the
// tokens from the legacy fields the file carries.
let mut theme: ThemeFamily = serde_json::from_slice(&content)?;
theme.light.rederive_tokens(ThemeMode::Light);
theme.dark.rederive_tokens(ThemeMode::Dark);
Ok(theme)
}