Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Load `Theme` from `theme2` into the storybook
Marshall Bowersdd34bb273e72
diff --git a/Cargo.lock b/Cargo.lockindex 3b14f2dbc32..9db01b9e078 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -9364,6 +9364,7 @@ dependencies = ["smallvec","strum","theme",+ "theme2",][[package]]diff --git a/crates/storybook2/src/storybook2.rs b/crates/storybook2/src/storybook2.rsindex 0d85119af30..7f7cbfa1507 100644--- a/crates/storybook2/src/storybook2.rs+++ b/crates/storybook2/src/storybook2.rs@@ -10,13 +10,15 @@ use std::sync::Arc;use clap::Parser;use gpui2::{- div, px, size, view, AnyView, AppContext, Bounds, Context, Element, ViewContext,- WindowBounds, WindowOptions,+ div, px, size, view, AnyView, AppContext, Bounds, Context, Element, ViewContext, WindowBounds,+ WindowOptions,};use log::LevelFilter;use simplelog::SimpleLogger;use story_selector::ComponentStory;+use theme2::ThemeRegistry;use ui::{prelude::*, themed};+use util::ResultExt;use crate::assets::Assets;use crate::story_selector::StorySelector;@@ -48,7 +50,7 @@ fn main() {let story_selector = args.story.clone();let theme_name = args.theme.unwrap_or("One Dark".to_string());- let theme = themes::load_theme(theme_name).unwrap();+ let theme = themes::load_theme(theme_name.clone()).unwrap();let asset_source = Arc::new(Assets);gpui2::App::production(asset_source).run(move |cx| {@@ -57,6 +59,12 @@ fn main() {let selector =story_selector.unwrap_or(StorySelector::Component(ComponentStory::Workspace));+ let theme_registry = cx.default_global::<ThemeRegistry>();++ if let Some(new_theme) = theme_registry.get(&theme_name).log_err() {+ cx.set_global(new_theme);+ }+cx.set_global(theme.clone());ui::settings::init(cx);diff --git a/crates/ui2/Cargo.toml b/crates/ui2/Cargo.tomlindex 3e9769a54c9..6778249c282 100644--- a/crates/ui2/Cargo.toml+++ b/crates/ui2/Cargo.toml@@ -14,6 +14,7 @@ settings = { path = "../settings" }smallvec.workspace = truestrum = { version = "0.25.0", features = ["derive"] }theme = { path = "../theme" }+theme2 = { path = "../theme2" }rand = "0.8"[features]