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