theme importer

Conrad Irwin created

Change summary

crates/theme/src/schema.rs                    | 41 ++------------------
crates/theme_importer/src/vscode/converter.rs |  4 +-
2 files changed, 6 insertions(+), 39 deletions(-)

Detailed changes

crates/theme/src/schema.rs 🔗

@@ -1,12 +1,12 @@
 #![allow(missing_docs)]
 
-use gpui::{FontStyle, FontWeight, HighlightStyle, Hsla, WindowBackgroundAppearance};
+use gpui::{FontStyle, FontWeight, HighlightStyle, Hsla};
 use indexmap::IndexMap;
 use palette::FromColor;
-use schemars::{JsonSchema, JsonSchema_repr};
+use schemars::JsonSchema;
 use serde::{Deserialize, Serialize};
-use serde_repr::{Deserialize_repr, Serialize_repr};
 use settings::{AccentContent, PlayerColorContent};
+pub use settings::{FontWeightContent, WindowBackgroundContent};
 
 use crate::{StatusColorsRefinement, ThemeColorsRefinement};
 
@@ -33,25 +33,6 @@ pub enum AppearanceContent {
     Dark,
 }
 
-/// The background appearance of the window.
-#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize, JsonSchema)]
-#[serde(rename_all = "snake_case")]
-pub enum WindowBackgroundContent {
-    Opaque,
-    Transparent,
-    Blurred,
-}
-
-impl From<WindowBackgroundContent> for WindowBackgroundAppearance {
-    fn from(value: WindowBackgroundContent) -> Self {
-        match value {
-            WindowBackgroundContent::Opaque => WindowBackgroundAppearance::Opaque,
-            WindowBackgroundContent::Transparent => WindowBackgroundAppearance::Transparent,
-            WindowBackgroundContent::Blurred => WindowBackgroundAppearance::Blurred,
-        }
-    }
-}
-
 /// The content of a serialized theme family.
 #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
 pub struct ThemeFamilyContent {
@@ -73,7 +54,7 @@ pub struct ThemeContent {
 #[serde(default)]
 pub struct ThemeStyleContent {
     #[serde(default, rename = "background.appearance")]
-    pub window_background_appearance: Option<WindowBackgroundContent>,
+    pub window_background_appearance: Option<settings::WindowBackgroundContent>,
 
     #[serde(default)]
     pub accents: Vec<AccentContent>,
@@ -290,20 +271,6 @@ pub fn status_colors_refinement(colors: &settings::StatusColorsContent) -> Statu
     }
 }
 
-#[derive(Debug, Clone, Copy, Serialize_repr, Deserialize_repr, JsonSchema_repr, PartialEq)]
-#[repr(u16)]
-pub enum FontWeightContent {
-    Thin = 100,
-    ExtraLight = 200,
-    Light = 300,
-    Normal = 400,
-    Medium = 500,
-    Semibold = 600,
-    Bold = 700,
-    ExtraBold = 800,
-    Black = 900,
-}
-
 pub fn theme_colors_refinement(
     this: &settings::ThemeColorsContent,
     status_colors: &StatusColorsRefinement,

crates/theme_importer/src/vscode/converter.rs 🔗

@@ -3,7 +3,7 @@ use indexmap::IndexMap;
 use strum::IntoEnumIterator;
 use theme::{
     FontStyleContent, FontWeightContent, HighlightStyleContent, StatusColorsContent,
-    ThemeColorsContent, ThemeContent, ThemeStyleContent,
+    ThemeColorsContent, ThemeContent, ThemeStyleContent, WindowBackgroundContent,
 };
 
 use crate::ThemeMetadata;
@@ -56,7 +56,7 @@ impl VsCodeThemeConverter {
             name: self.theme_metadata.name,
             appearance,
             style: ThemeStyleContent {
-                window_background_appearance: Some(theme::WindowBackgroundContent::Opaque),
+                window_background_appearance: Some(WindowBackgroundContent::Opaque),
                 accents: Vec::new(), //TODO can we read this from the theme?
                 colors: theme_colors,
                 status: status_colors,