port bezel theme system into the theme crate
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user