Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Remove `themed` wrapper
Marshall Bowers7b4e699d0ee4
diff --git a/crates/storybook2/src/storybook2.rs b/crates/storybook2/src/storybook2.rsindex a06a1392b23..493997ccfe4 100644--- a/crates/storybook2/src/storybook2.rs+++ b/crates/storybook2/src/storybook2.rs@@ -18,7 +18,7 @@ use settings2::{default_settings, Settings, SettingsStore};use simplelog::SimpleLogger;use story_selector::ComponentStory;use theme2::{ThemeRegistry, ThemeSettings};-use ui::{prelude::*, themed};+use ui::prelude::*;use crate::assets::Assets;use crate::story_selector::StorySelector;@@ -86,7 +86,7 @@ fn main() {},move |cx| {cx.build_view(- |cx| StoryWrapper::new(selector.story(cx), theme),+ |cx| StoryWrapper::new(selector.story(cx)),StoryWrapper::render,)},@@ -99,22 +99,19 @@ fn main() {#[derive(Clone)]pub struct StoryWrapper {story: AnyView,- theme: Theme,}impl StoryWrapper {- pub(crate) fn new(story: AnyView, theme: Theme) -> Self {- Self { story, theme }+ pub(crate) fn new(story: AnyView) -> Self {+ Self { story }}fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Component<Self> {- themed(self.theme.clone(), cx, |cx| {- div()- .flex()- .flex_col()- .size_full()- .child(self.story.clone())- })+ div()+ .flex()+ .flex_col()+ .size_full()+ .child(self.story.clone())}}diff --git a/crates/ui2/src/prelude.rs b/crates/ui2/src/prelude.rsindex b8143b6e504..95cd6ffa6dc 100644--- a/crates/ui2/src/prelude.rs+++ b/crates/ui2/src/prelude.rs@@ -5,7 +5,7 @@ pub use gpui2::{pub use crate::elevation::*;use crate::settings::user_settings;-pub use crate::{old_theme, theme, ButtonVariant, Theme};+pub use crate::{old_theme, theme, ButtonVariant};use gpui2::{rems, Hsla, Rems};use strum::EnumIter;diff --git a/crates/ui2/src/theme.rs b/crates/ui2/src/theme.rsindex cc46ddcb17b..f160a24da37 100644--- a/crates/ui2/src/theme.rs+++ b/crates/ui2/src/theme.rs@@ -1,7 +1,4 @@-use gpui2::{- AnyElement, AppContext, Bounds, Component, Element, Hsla, LayoutId, Pixels, Result,- ViewContext, WindowContext,-};+use gpui2::{AppContext, Hsla, Result, WindowContext};use serde::{de::Visitor, Deserialize, Deserializer};use std::collections::HashMap;use std::fmt;@@ -132,90 +129,6 @@ wheredeserializer.deserialize_map(SyntaxVisitor)}-pub fn themed<V, E, F>(theme: Theme, cx: &mut ViewContext<V>, build_child: F) -> Themed<E>-where- V: 'static,- E: Element<V>,- F: FnOnce(&mut ViewContext<V>) -> E,-{- cx.default_global::<ThemeStack>().0.push(theme.clone());- let child = build_child(cx);- cx.default_global::<ThemeStack>().0.pop();- Themed { theme, child }-}--pub struct Themed<E> {- pub(crate) theme: Theme,- pub(crate) child: E,-}--impl<V, E> Component<V> for Themed<E>-where- V: 'static,- E: 'static + Element<V> + Send,- E::ElementState: Send,-{- fn render(self) -> AnyElement<V> {- AnyElement::new(self)- }-}--#[derive(Default)]-struct ThemeStack(Vec<Theme>);--impl<V, E: 'static + Element<V> + Send> Element<V> for Themed<E>-where- V: 'static,- E::ElementState: Send,-{- type ElementState = E::ElementState;-- fn id(&self) -> Option<gpui2::ElementId> {- None- }-- fn initialize(- &mut self,- view_state: &mut V,- element_state: Option<Self::ElementState>,- cx: &mut ViewContext<V>,- ) -> Self::ElementState {- cx.default_global::<ThemeStack>().0.push(self.theme.clone());- let element_state = self.child.initialize(view_state, element_state, cx);- cx.default_global::<ThemeStack>().0.pop();- element_state- }-- fn layout(- &mut self,- view_state: &mut V,- element_state: &mut Self::ElementState,- cx: &mut ViewContext<V>,- ) -> LayoutId- where- Self: Sized,- {- cx.default_global::<ThemeStack>().0.push(self.theme.clone());- let layout_id = self.child.layout(view_state, element_state, cx);- cx.default_global::<ThemeStack>().0.pop();- layout_id- }-- fn paint(- &mut self,- bounds: Bounds<Pixels>,- view_state: &mut V,- frame_state: &mut Self::ElementState,- cx: &mut ViewContext<V>,- ) where- Self: Sized,- {- cx.default_global::<ThemeStack>().0.push(self.theme.clone());- self.child.paint(bounds, view_state, frame_state, cx);- cx.default_global::<ThemeStack>().0.pop();- }-}-pub fn old_theme(cx: &WindowContext) -> Arc<Theme> {Arc::new(cx.global::<Theme>().clone())}