Load Theme from theme2 into the storybook
This commit is contained in:
Generated
+1
@@ -9364,6 +9364,7 @@ dependencies = [
|
|||||||
"smallvec",
|
"smallvec",
|
||||||
"strum",
|
"strum",
|
||||||
"theme",
|
"theme",
|
||||||
|
"theme2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -10,13 +10,15 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use gpui2::{
|
use gpui2::{
|
||||||
div, px, size, view, AnyView, AppContext, Bounds, Context, Element, ViewContext,
|
div, px, size, view, AnyView, AppContext, Bounds, Context, Element, ViewContext, WindowBounds,
|
||||||
WindowBounds, WindowOptions,
|
WindowOptions,
|
||||||
};
|
};
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
use simplelog::SimpleLogger;
|
use simplelog::SimpleLogger;
|
||||||
use story_selector::ComponentStory;
|
use story_selector::ComponentStory;
|
||||||
|
use theme2::ThemeRegistry;
|
||||||
use ui::{prelude::*, themed};
|
use ui::{prelude::*, themed};
|
||||||
|
use util::ResultExt;
|
||||||
|
|
||||||
use crate::assets::Assets;
|
use crate::assets::Assets;
|
||||||
use crate::story_selector::StorySelector;
|
use crate::story_selector::StorySelector;
|
||||||
@@ -48,7 +50,7 @@ fn main() {
|
|||||||
|
|
||||||
let story_selector = args.story.clone();
|
let story_selector = args.story.clone();
|
||||||
let theme_name = args.theme.unwrap_or("One Dark".to_string());
|
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);
|
let asset_source = Arc::new(Assets);
|
||||||
gpui2::App::production(asset_source).run(move |cx| {
|
gpui2::App::production(asset_source).run(move |cx| {
|
||||||
@@ -57,6 +59,12 @@ fn main() {
|
|||||||
let selector =
|
let selector =
|
||||||
story_selector.unwrap_or(StorySelector::Component(ComponentStory::Workspace));
|
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());
|
cx.set_global(theme.clone());
|
||||||
ui::settings::init(cx);
|
ui::settings::init(cx);
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ settings = { path = "../settings" }
|
|||||||
smallvec.workspace = true
|
smallvec.workspace = true
|
||||||
strum = { version = "0.25.0", features = ["derive"] }
|
strum = { version = "0.25.0", features = ["derive"] }
|
||||||
theme = { path = "../theme" }
|
theme = { path = "../theme" }
|
||||||
|
theme2 = { path = "../theme2" }
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|||||||
Reference in New Issue
Block a user