2023-10-05 20:42:11 +00:00
|
|
|
mod rose_pine;
|
2023-09-26 19:42:58 +00:00
|
|
|
|
2023-10-05 20:42:11 +00:00
|
|
|
pub use rose_pine::*;
|
2023-10-09 20:37:20 +00:00
|
|
|
|
|
|
|
use gpui3::serde_json;
|
|
|
|
use serde::Deserialize;
|
|
|
|
use ui::Theme;
|
|
|
|
|
|
|
|
use crate::assets::Assets;
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
|
|
|
struct LegacyTheme {
|
|
|
|
pub base_theme: serde_json::Value,
|
|
|
|
}
|
|
|
|
|
2023-10-09 20:53:28 +00:00
|
|
|
/// Loads the [`Theme`] with the given name.
|
|
|
|
pub fn load_theme(name: String) -> Theme {
|
|
|
|
let theme_contents = Assets::get(&format!("themes/{name}.json"))
|
|
|
|
.unwrap_or_else(|| panic!("failed to load theme: {name}.json"));
|
2023-10-09 20:37:20 +00:00
|
|
|
|
2023-10-09 20:53:28 +00:00
|
|
|
let legacy_theme: LegacyTheme =
|
|
|
|
serde_json::from_str(std::str::from_utf8(&theme_contents.data).unwrap()).unwrap();
|
2023-10-09 20:37:20 +00:00
|
|
|
|
2023-10-09 20:53:28 +00:00
|
|
|
let theme: Theme = serde_json::from_value(legacy_theme.base_theme.clone()).unwrap();
|
2023-10-09 20:37:20 +00:00
|
|
|
|
|
|
|
theme
|
|
|
|
}
|