Merge remote-tracking branch 'origin/main' into gpui2-no-send

This commit is contained in:
Nathan Sobo 2023-11-01 21:10:31 -06:00
commit db9ccd7f34
133 changed files with 14910 additions and 7230 deletions

View file

@ -10,6 +10,7 @@ chrono = "0.4"
gpui2 = { path = "../gpui2" }
itertools = { version = "0.11.0", optional = true }
serde.workspace = true
settings2 = { path = "../settings2" }
smallvec.workspace = true
strum = { version = "0.25.0", features = ["derive"] }
theme2 = { path = "../theme2" }

View file

@ -19,24 +19,22 @@ impl Breadcrumb {
}
fn render_separator<V: 'static>(&self, cx: &WindowContext) -> Div<V> {
let theme = theme(cx);
div().child(" ").text_color(theme.text_muted)
div()
.child(" ")
.text_color(cx.theme().colors().text_muted)
}
fn render<V: 'static>(self, view_state: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
let symbols_len = self.symbols.len();
h_stack()
.id("breadcrumb")
.px_1()
.text_sm()
.text_color(theme.text_muted)
.text_color(cx.theme().colors().text_muted)
.rounded_md()
.hover(|style| style.bg(theme.ghost_element_hover))
.active(|style| style.bg(theme.ghost_element_active))
.hover(|style| style.bg(cx.theme().colors().ghost_element_hover))
.active(|style| style.bg(cx.theme().colors().ghost_element_active))
.child(self.path.clone().to_str().unwrap().to_string())
.child(if !self.symbols.is_empty() {
self.render_separator(cx)
@ -84,8 +82,6 @@ mod stories {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
let theme = theme(cx);
Story::container(cx)
.child(Story::title_for::<_, Breadcrumb>(cx))
.child(Story::label(cx, "Default"))
@ -95,21 +91,21 @@ mod stories {
Symbol(vec![
HighlightedText {
text: "impl ".to_string(),
color: theme.syntax.color("keyword"),
color: cx.theme().syntax_color("keyword"),
},
HighlightedText {
text: "BreadcrumbStory".to_string(),
color: theme.syntax.color("function"),
color: cx.theme().syntax_color("function"),
},
]),
Symbol(vec![
HighlightedText {
text: "fn ".to_string(),
color: theme.syntax.color("keyword"),
color: cx.theme().syntax_color("keyword"),
},
HighlightedText {
text: "render".to_string(),
color: theme.syntax.color("function"),
color: cx.theme().syntax_color("function"),
},
]),
],

View file

@ -155,18 +155,16 @@ impl Buffer {
}
fn render_row<V: 'static>(row: BufferRow, cx: &WindowContext) -> impl Component<V> {
let theme = theme(cx);
let line_background = if row.current {
theme.editor_active_line
cx.theme().colors().editor_active_line
} else {
theme.transparent
cx.theme().styles.system.transparent
};
let line_number_color = if row.current {
theme.text
cx.theme().colors().text
} else {
theme.syntax.get("comment").color.unwrap_or_default()
cx.theme().syntax_color("comment")
};
h_stack()
@ -216,14 +214,13 @@ impl Buffer {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
let rows = self.render_rows(cx);
v_stack()
.flex_1()
.w_full()
.h_full()
.bg(theme.editor)
.bg(cx.theme().colors().editor)
.children(rows)
}
}
@ -246,8 +243,6 @@ mod stories {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
let theme = theme(cx);
Story::container(cx)
.child(Story::title_for::<_, Buffer>(cx))
.child(Story::label(cx, "Default"))
@ -257,14 +252,14 @@ mod stories {
div()
.w(rems(64.))
.h_96()
.child(hello_world_rust_buffer_example(&theme)),
.child(hello_world_rust_buffer_example(cx)),
)
.child(Story::label(cx, "Hello World (Rust) with Status"))
.child(
div()
.w(rems(64.))
.h_96()
.child(hello_world_rust_buffer_with_status_example(&theme)),
.child(hello_world_rust_buffer_with_status_example(cx)),
)
}
}

View file

@ -30,9 +30,7 @@ impl Render for BufferSearch {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Div<Self> {
let theme = theme(cx);
h_stack().bg(theme.toolbar).p_2().child(
h_stack().bg(cx.theme().colors().toolbar).p_2().child(
h_stack().child(Input::new("Search")).child(
IconButton::<Self>::new("replace", Icon::Replace)
.when(self.is_replace_open, |this| this.color(IconColor::Accent))

View file

@ -15,27 +15,29 @@ impl CollabPanel {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
v_stack()
.id(self.id.clone())
.h_full()
.bg(theme.surface)
.bg(cx.theme().colors().surface)
.child(
v_stack()
.id("crdb")
.w_full()
.overflow_y_scroll()
.child(
div().pb_1().border_color(theme.border).border_b().child(
List::new(static_collab_panel_current_call())
.header(
ListHeader::new("CRDB")
.left_icon(Icon::Hash.into())
.toggle(ToggleState::Toggled),
)
.toggle(ToggleState::Toggled),
),
div()
.pb_1()
.border_color(cx.theme().colors().border)
.border_b()
.child(
List::new(static_collab_panel_current_call())
.header(
ListHeader::new("CRDB")
.left_icon(Icon::Hash.into())
.toggle(ToggleState::Toggled),
)
.toggle(ToggleState::Toggled),
),
)
.child(
v_stack().id("channels").py_1().child(
@ -71,13 +73,13 @@ impl CollabPanel {
.h_7()
.px_2()
.border_t()
.border_color(theme.border)
.border_color(cx.theme().colors().border)
.flex()
.items_center()
.child(
div()
.text_sm()
.text_color(theme.text_placeholder)
.text_color(cx.theme().colors().text_placeholder)
.child("Find..."),
),
)

View file

@ -44,13 +44,11 @@ impl ContextMenu {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
v_stack()
.flex()
.bg(theme.elevated_surface)
.bg(cx.theme().colors().elevated_surface)
.border()
.border_color(theme.border)
.border_color(cx.theme().colors().border)
.child(
List::new(
self.items

View file

@ -1,6 +1,6 @@
use std::sync::Arc;
use gpui2::MouseButton;
use gpui2::{rems, MouseButton};
use crate::{h_stack, prelude::*};
use crate::{ClickHandler, Icon, IconColor, IconElement};
@ -66,8 +66,6 @@ impl<V: 'static> IconButton<V> {
}
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
let icon_color = match (self.state, self.color) {
(InteractionState::Disabled, _) => IconColor::Disabled,
_ => self.color,
@ -75,14 +73,14 @@ impl<V: 'static> IconButton<V> {
let (bg_color, bg_hover_color, bg_active_color) = match self.variant {
ButtonVariant::Filled => (
theme.filled_element,
theme.filled_element_hover,
theme.filled_element_active,
cx.theme().colors().element,
cx.theme().colors().element_hover,
cx.theme().colors().element_active,
),
ButtonVariant::Ghost => (
theme.ghost_element,
theme.ghost_element_hover,
theme.ghost_element_active,
cx.theme().colors().ghost_element,
cx.theme().colors().ghost_element_hover,
cx.theme().colors().ghost_element_active,
),
};
@ -90,8 +88,8 @@ impl<V: 'static> IconButton<V> {
.id(self.id.clone())
.justify_center()
.rounded_md()
.py(ui_size(cx, 0.25))
.px(ui_size(cx, 6. / 14.))
.py(rems(0.21875))
.px(rems(0.375))
.bg(bg_color)
.hover(|style| style.bg(bg_hover_color))
.active(|style| style.bg(bg_active_color))

View file

@ -60,15 +60,13 @@ impl Key {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
div()
.px_2()
.py_0()
.rounded_md()
.text_sm()
.text_color(theme.text)
.bg(theme.filled_element)
.text_color(cx.theme().colors().text)
.bg(cx.theme().colors().element)
.child(self.key.clone())
}
}

View file

@ -89,8 +89,6 @@ impl ListHeader {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
let is_toggleable = self.toggleable != Toggleable::NotToggleable;
let is_toggled = self.toggleable.is_toggled();
@ -99,9 +97,10 @@ impl ListHeader {
h_stack()
.flex_1()
.w_full()
.bg(theme.surface)
.bg(cx.theme().colors().surface)
.when(self.state == InteractionState::Focused, |this| {
this.border().border_color(theme.border_focused)
this.border()
.border_color(cx.theme().colors().border_focused)
})
.relative()
.child(
@ -363,7 +362,6 @@ impl ListEntry {
fn render<V: 'static>(mut self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let settings = user_settings(cx);
let theme = theme(cx);
let left_content = match self.left_content.clone() {
Some(LeftContent::Icon(i)) => Some(
@ -385,9 +383,10 @@ impl ListEntry {
div()
.relative()
.group("")
.bg(theme.surface)
.bg(cx.theme().colors().surface)
.when(self.state == InteractionState::Focused, |this| {
this.border().border_color(theme.border_focused)
this.border()
.border_color(cx.theme().colors().border_focused)
})
.child(
sized_item
@ -399,11 +398,11 @@ impl ListEntry {
.h_full()
.flex()
.justify_center()
.group_hover("", |style| style.bg(theme.border_focused))
.group_hover("", |style| style.bg(cx.theme().colors().border_focused))
.child(
h_stack()
.child(div().w_px().h_full())
.child(div().w_px().h_full().bg(theme.border)),
.child(div().w_px().h_full().bg(cx.theme().colors().border)),
)
}))
.flex()
@ -472,19 +471,18 @@ impl<V: 'static> ListDetailsEntry<V> {
}
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
let settings = user_settings(cx);
let (item_bg, item_bg_hover, item_bg_active) = match self.seen {
true => (
theme.ghost_element,
theme.ghost_element_hover,
theme.ghost_element_active,
cx.theme().colors().ghost_element,
cx.theme().colors().ghost_element_hover,
cx.theme().colors().ghost_element_active,
),
false => (
theme.filled_element,
theme.filled_element_hover,
theme.filled_element_active,
cx.theme().colors().element,
cx.theme().colors().element_hover,
cx.theme().colors().element_active,
),
};
@ -524,9 +522,7 @@ impl ListSeparator {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
div().h_px().w_full().bg(theme.border)
div().h_px().w_full().bg(cx.theme().colors().border)
}
}

View file

@ -39,22 +39,20 @@ impl<V: 'static> Modal<V> {
}
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
v_stack()
.id(self.id.clone())
.w_96()
// .rounded_xl()
.bg(theme.background)
.bg(cx.theme().colors().background)
.border()
.border_color(theme.border)
.border_color(cx.theme().colors().border)
.shadow_2xl()
.child(
h_stack()
.justify_between()
.p_1()
.border_b()
.border_color(theme.border)
.border_color(cx.theme().colors().border)
.child(div().children(self.title.clone().map(|t| Label::new(t))))
.child(IconButton::new("close", Icon::Close)),
)
@ -65,7 +63,7 @@ impl<V: 'static> Modal<V> {
this.child(
h_stack()
.border_t()
.border_color(theme.border)
.border_color(cx.theme().colors().border)
.p_1()
.justify_end()
.children(self.secondary_action)

View file

@ -12,8 +12,6 @@ impl MultiBuffer {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
v_stack()
.w_full()
.h_full()
@ -26,7 +24,7 @@ impl MultiBuffer {
.items_center()
.justify_between()
.p_4()
.bg(theme.editor_subheader)
.bg(cx.theme().colors().editor_subheader)
.child(Label::new("main.rs"))
.child(IconButton::new("arrow_up_right", Icon::ArrowUpRight)),
)
@ -50,17 +48,15 @@ mod stories {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
let theme = theme(cx);
Story::container(cx)
.child(Story::title_for::<_, MultiBuffer>(cx))
.child(Story::label(cx, "Default"))
.child(MultiBuffer::new(vec![
hello_world_rust_buffer_example(&theme),
hello_world_rust_buffer_example(&theme),
hello_world_rust_buffer_example(&theme),
hello_world_rust_buffer_example(&theme),
hello_world_rust_buffer_example(&theme),
hello_world_rust_buffer_example(cx),
hello_world_rust_buffer_example(cx),
hello_world_rust_buffer_example(cx),
hello_world_rust_buffer_example(cx),
hello_world_rust_buffer_example(cx),
]))
}
}

View file

@ -1,6 +1,7 @@
use gpui2::rems;
use crate::{h_stack, prelude::*, Icon};
use crate::prelude::*;
use crate::{h_stack, Icon};
#[derive(Component)]
pub struct NotificationToast {
@ -22,8 +23,6 @@ impl NotificationToast {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
h_stack()
.z_index(5)
.absolute()
@ -35,7 +34,7 @@ impl NotificationToast {
.px_1p5()
.rounded_lg()
.shadow_md()
.bg(theme.elevated_surface)
.bg(cx.theme().colors().elevated_surface)
.child(div().size_full().child(self.label.clone()))
}
}

View file

@ -12,15 +12,13 @@ impl NotificationsPanel {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
div()
.id(self.id.clone())
.flex()
.flex_col()
.w_full()
.h_full()
.bg(theme.surface)
.bg(cx.theme().colors().surface)
.child(
div()
.id("header")

View file

@ -43,22 +43,20 @@ impl Palette {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
v_stack()
.id(self.id.clone())
.w_96()
.rounded_lg()
.bg(theme.elevated_surface)
.bg(cx.theme().colors().elevated_surface)
.border()
.border_color(theme.border)
.border_color(cx.theme().colors().border)
.child(
v_stack()
.gap_px()
.child(v_stack().py_0p5().px_1().child(div().px_2().py_0p5().child(
Label::new(self.input_placeholder.clone()).color(LabelColor::Placeholder),
)))
.child(div().h_px().w_full().bg(theme.filled_element))
.child(div().h_px().w_full().bg(cx.theme().colors().element))
.child(
v_stack()
.id("items")
@ -88,8 +86,12 @@ impl Palette {
.px_2()
.py_0p5()
.rounded_lg()
.hover(|style| style.bg(theme.ghost_element_hover))
.active(|style| style.bg(theme.ghost_element_active))
.hover(|style| {
style.bg(cx.theme().colors().ghost_element_hover)
})
.active(|style| {
style.bg(cx.theme().colors().ghost_element_active)
})
.child(item)
})),
),

View file

@ -93,8 +93,6 @@ impl<V: 'static> Panel<V> {
}
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
let current_size = self.width.unwrap_or(self.initial_width);
v_stack()
@ -111,8 +109,8 @@ impl<V: 'static> Panel<V> {
.when(self.current_side == PanelSide::Bottom, |this| {
this.border_b().w_full().h(current_size)
})
.bg(theme.surface)
.border_color(theme.border)
.bg(cx.theme().colors().surface)
.border_color(cx.theme().colors().border)
.children(self.children)
}
}

View file

@ -90,8 +90,6 @@ impl<V: 'static> PaneGroup<V> {
}
fn render(self, view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
if !self.panes.is_empty() {
let el = div()
.flex()
@ -115,7 +113,7 @@ impl<V: 'static> PaneGroup<V> {
.gap_px()
.w_full()
.h_full()
.bg(theme.editor)
.bg(cx.theme().colors().editor)
.children(self.groups.into_iter().map(|group| group.render(view, cx)));
if self.split_direction == SplitDirection::Horizontal {

View file

@ -14,9 +14,7 @@ impl PlayerStack {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
let player = self.player_with_call_status.get_player();
self.player_with_call_status.get_call_status();
let followers = self
.player_with_call_status
@ -50,7 +48,7 @@ impl PlayerStack {
.pl_1()
.rounded_lg()
.bg(if followers.is_none() {
theme.transparent
cx.theme().styles.system.transparent
} else {
player.selection_color(cx)
})

View file

@ -14,15 +14,13 @@ impl ProjectPanel {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
div()
.id(self.id.clone())
.flex()
.flex_col()
.w_full()
.h_full()
.bg(theme.surface)
.bg(cx.theme().colors().surface)
.child(
div()
.id("project-panel-contents")

View file

@ -86,8 +86,6 @@ impl StatusBar {
view: &mut Workspace,
cx: &mut ViewContext<Workspace>,
) -> impl Component<Workspace> {
let theme = theme(cx);
div()
.py_0p5()
.px_1()
@ -95,7 +93,7 @@ impl StatusBar {
.items_center()
.justify_between()
.w_full()
.bg(theme.status_bar)
.bg(cx.theme().colors().status_bar)
.child(self.left_tools(view, cx))
.child(self.right_tools(view, cx))
}

View file

@ -87,7 +87,6 @@ impl Tab {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
let has_fs_conflict = self.fs_status == FileSystemStatus::Conflict;
let is_deleted = self.fs_status == FileSystemStatus::Deleted;
@ -110,14 +109,14 @@ impl Tab {
let (tab_bg, tab_hover_bg, tab_active_bg) = match self.current {
true => (
theme.ghost_element,
theme.ghost_element_hover,
theme.ghost_element_active,
cx.theme().colors().ghost_element,
cx.theme().colors().ghost_element_hover,
cx.theme().colors().ghost_element_active,
),
false => (
theme.filled_element,
theme.filled_element_hover,
theme.filled_element_active,
cx.theme().colors().element,
cx.theme().colors().element_hover,
cx.theme().colors().element_active,
),
};

View file

@ -24,15 +24,13 @@ impl TabBar {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
let (can_navigate_back, can_navigate_forward) = self.can_navigate;
div()
.id(self.id.clone())
.w_full()
.flex()
.bg(theme.tab_bar)
.bg(cx.theme().colors().tab_bar)
// Left Side
.child(
div()

View file

@ -12,8 +12,6 @@ impl Terminal {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
let can_navigate_back = true;
let can_navigate_forward = false;
@ -26,7 +24,7 @@ impl Terminal {
div()
.w_full()
.flex()
.bg(theme.surface)
.bg(cx.theme().colors().surface)
.child(
div().px_1().flex().flex_none().gap_2().child(
div()
@ -73,7 +71,7 @@ impl Terminal {
height: rems(36.).into(),
},
)
.child(crate::static_data::terminal_buffer(&theme)),
.child(crate::static_data::terminal_buffer(cx)),
)
}
}

View file

@ -89,7 +89,6 @@ impl Render for TitleBar {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Div<Self> {
let theme = theme(cx);
let settings = user_settings(cx);
// let has_focus = cx.window_is_active();
@ -106,7 +105,7 @@ impl Render for TitleBar {
.items_center()
.justify_between()
.w_full()
.bg(theme.background)
.bg(cx.theme().colors().background)
.py_1()
.child(
div()

View file

@ -37,8 +37,6 @@ impl<V: 'static> Toast<V> {
}
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
let mut div = div();
if self.origin == ToastOrigin::Bottom {
@ -56,7 +54,7 @@ impl<V: 'static> Toast<V> {
.rounded_lg()
.shadow_md()
.overflow_hidden()
.bg(theme.elevated_surface)
.bg(cx.theme().colors().elevated_surface)
.children(self.children)
}
}

View file

@ -55,10 +55,8 @@ impl<V: 'static> Toolbar<V> {
}
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
div()
.bg(theme.toolbar)
.bg(cx.theme().colors().toolbar)
.p_2()
.flex()
.justify_between()
@ -87,8 +85,6 @@ mod stories {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
let theme = theme(cx);
Story::container(cx)
.child(Story::title_for::<_, Toolbar<Self>>(cx))
.child(Story::label(cx, "Default"))
@ -100,21 +96,21 @@ mod stories {
Symbol(vec![
HighlightedText {
text: "impl ".to_string(),
color: theme.syntax.color("keyword"),
color: cx.theme().syntax_color("keyword"),
},
HighlightedText {
text: "ToolbarStory".to_string(),
color: theme.syntax.color("function"),
color: cx.theme().syntax_color("function"),
},
]),
Symbol(vec![
HighlightedText {
text: "fn ".to_string(),
color: theme.syntax.color("keyword"),
color: cx.theme().syntax_color("keyword"),
},
HighlightedText {
text: "render".to_string(),
color: theme.syntax.color("function"),
color: cx.theme().syntax_color("function"),
},
]),
],

View file

@ -22,13 +22,13 @@ impl TrafficLight {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
let system_colors = &cx.theme().styles.system;
let fill = match (self.window_has_focus, self.color) {
(true, TrafficLightColor::Red) => theme.mac_os_traffic_light_red,
(true, TrafficLightColor::Yellow) => theme.mac_os_traffic_light_yellow,
(true, TrafficLightColor::Green) => theme.mac_os_traffic_light_green,
(false, _) => theme.filled_element,
(true, TrafficLightColor::Red) => system_colors.mac_os_traffic_light_red,
(true, TrafficLightColor::Yellow) => system_colors.mac_os_traffic_light_yellow,
(true, TrafficLightColor::Green) => system_colors.mac_os_traffic_light_green,
(false, _) => cx.theme().colors().element,
};
div().w_3().h_3().rounded_full().bg(fill)

View file

@ -1,14 +1,16 @@
use std::sync::Arc;
use chrono::DateTime;
use gpui2::{px, relative, rems, Div, Render, Size, View, VisualContext};
use gpui2::{px, relative, Div, Render, Size, View, VisualContext};
use settings2::Settings;
use theme2::ThemeSettings;
use crate::{prelude::*, NotificationsPanel};
use crate::prelude::*;
use crate::{
static_livestream, user_settings_mut, v_stack, AssistantPanel, Button, ChatMessage, ChatPanel,
CollabPanel, EditorPane, FakeSettings, Label, LanguageSelector, Pane, PaneGroup, Panel,
PanelAllowedSides, PanelSide, ProjectPanel, SettingValue, SplitDirection, StatusBar, Terminal,
TitleBar, Toast, ToastOrigin,
static_livestream, v_stack, AssistantPanel, Button, ChatMessage, ChatPanel, CollabPanel,
EditorPane, Label, LanguageSelector, NotificationsPanel, Pane, PaneGroup, Panel,
PanelAllowedSides, PanelSide, ProjectPanel, SplitDirection, StatusBar, Terminal, TitleBar,
Toast, ToastOrigin,
};
#[derive(Clone)]
@ -150,6 +152,18 @@ impl Workspace {
pub fn debug_toggle_user_settings(&mut self, cx: &mut ViewContext<Self>) {
self.debug.enable_user_settings = !self.debug.enable_user_settings;
let mut theme_settings = ThemeSettings::get_global(cx).clone();
if self.debug.enable_user_settings {
theme_settings.ui_font_size = 18.0.into();
} else {
theme_settings.ui_font_size = 16.0.into();
}
ThemeSettings::override_global(theme_settings.clone(), cx);
cx.set_rem_size(theme_settings.ui_font_size);
cx.notify();
}
@ -179,22 +193,6 @@ impl Render for Workspace {
type Element = Div<Self>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Div<Self> {
let theme = theme(cx);
// HACK: This should happen inside of `debug_toggle_user_settings`, but
// we don't have `cx.global::<FakeSettings>()` in event handlers at the moment.
// Need to talk with Nathan/Antonio about this.
{
let settings = user_settings_mut(cx);
if self.debug.enable_user_settings {
settings.list_indent_depth = SettingValue::UserDefined(rems(0.5).into());
settings.ui_scale = SettingValue::UserDefined(1.25);
} else {
*settings = FakeSettings::default();
}
}
let root_group = PaneGroup::new_panes(
vec![Pane::new(
"pane-0",
@ -216,8 +214,8 @@ impl Render for Workspace {
.gap_0()
.justify_start()
.items_start()
.text_color(theme.text)
.bg(theme.background)
.text_color(cx.theme().colors().text)
.bg(cx.theme().colors().background)
.child(self.title_bar.clone())
.child(
div()
@ -228,7 +226,7 @@ impl Render for Workspace {
.overflow_hidden()
.border_t()
.border_b()
.border_color(theme.border)
.border_color(cx.theme().colors().border)
.children(
Some(
Panel::new("project-panel-outer", cx)
@ -323,7 +321,7 @@ impl Render for Workspace {
v_stack()
.z_index(9)
.absolute()
.bottom_10()
.top_20()
.left_1_4()
.w_40()
.gap_2()

View file

@ -22,8 +22,6 @@ impl Avatar {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
let mut img = img();
if self.shape == Shape::Circle {
@ -34,7 +32,8 @@ impl Avatar {
img.uri(self.src.clone())
.size_4()
.bg(theme.image_fallback_background)
// todo!(Pull the avatar fallback background from the theme.)
.bg(gpui2::red())
}
}

View file

@ -1,9 +1,9 @@
use std::sync::Arc;
use gpui2::{div, DefiniteLength, Hsla, MouseButton, WindowContext};
use gpui2::{div, rems, DefiniteLength, Hsla, MouseButton, WindowContext};
use crate::{h_stack, Icon, IconColor, IconElement, Label, LabelColor};
use crate::{prelude::*, LineHeightStyle};
use crate::prelude::*;
use crate::{h_stack, Icon, IconColor, IconElement, Label, LabelColor, LineHeightStyle};
#[derive(Default, PartialEq, Clone, Copy)]
pub enum IconPosition {
@ -21,29 +21,23 @@ pub enum ButtonVariant {
impl ButtonVariant {
pub fn bg_color(&self, cx: &mut WindowContext) -> Hsla {
let theme = theme(cx);
match self {
ButtonVariant::Ghost => theme.ghost_element,
ButtonVariant::Filled => theme.filled_element,
ButtonVariant::Ghost => cx.theme().colors().ghost_element,
ButtonVariant::Filled => cx.theme().colors().element,
}
}
pub fn bg_color_hover(&self, cx: &mut WindowContext) -> Hsla {
let theme = theme(cx);
match self {
ButtonVariant::Ghost => theme.ghost_element_hover,
ButtonVariant::Filled => theme.filled_element_hover,
ButtonVariant::Ghost => cx.theme().colors().ghost_element_hover,
ButtonVariant::Filled => cx.theme().colors().element_hover,
}
}
pub fn bg_color_active(&self, cx: &mut WindowContext) -> Hsla {
let theme = theme(cx);
match self {
ButtonVariant::Ghost => theme.ghost_element_active,
ButtonVariant::Filled => theme.filled_element_active,
ButtonVariant::Ghost => cx.theme().colors().ghost_element_active,
ButtonVariant::Filled => cx.theme().colors().element_active,
}
}
}
@ -157,7 +151,7 @@ impl<V: 'static> Button<V> {
.relative()
.id(SharedString::from(format!("{}", self.label)))
.p_1()
.text_size(ui_size(cx, 1.))
.text_size(rems(1.))
.rounded_md()
.bg(self.variant.bg_color(cx))
.hover(|style| style.bg(self.variant.bg_color_hover(cx)))
@ -204,7 +198,7 @@ impl<V: 'static> ButtonGroup<V> {
}
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let mut el = h_stack().text_size(ui_size(cx, 1.));
let mut el = h_stack().text_size(rems(1.));
for button in self.buttons {
el = el.child(button.render(_view, cx));

View file

@ -1,4 +1,5 @@
use crate::{prelude::*, v_stack, ButtonGroup};
use crate::prelude::*;
use crate::{v_stack, ButtonGroup};
#[derive(Component)]
pub struct Details<V: 'static> {
@ -27,13 +28,11 @@ impl<V: 'static> Details<V> {
}
fn render(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
v_stack()
.p_1()
.gap_0p5()
.text_xs()
.text_color(theme.text)
.text_color(cx.theme().colors().text)
.size_full()
.child(self.text)
.children(self.meta.map(|m| m))

View file

@ -1,4 +1,4 @@
use gpui2::{svg, Hsla};
use gpui2::{rems, svg, Hsla};
use strum::EnumIter;
use crate::prelude::*;
@ -26,13 +26,14 @@ pub enum IconColor {
impl IconColor {
pub fn color(self, cx: &WindowContext) -> Hsla {
let theme = theme(cx);
let theme_colors = cx.theme().colors();
match self {
IconColor::Default => gpui2::red(),
IconColor::Muted => gpui2::red(),
IconColor::Disabled => gpui2::red(),
IconColor::Placeholder => gpui2::red(),
IconColor::Accent => gpui2::red(),
IconColor::Default => theme_colors.icon,
IconColor::Muted => theme_colors.icon_muted,
IconColor::Disabled => theme_colors.icon_disabled,
IconColor::Placeholder => theme_colors.icon_placeholder,
IconColor::Accent => theme_colors.icon_accent,
IconColor::Error => gpui2::red(),
IconColor::Warning => gpui2::red(),
IconColor::Success => gpui2::red(),
@ -174,8 +175,8 @@ impl IconElement {
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let fill = self.color.color(cx);
let svg_size = match self.size {
IconSize::Small => ui_size(cx, 12. / 14.),
IconSize::Medium => ui_size(cx, 15. / 14.),
IconSize::Small => rems(0.75),
IconSize::Medium => rems(0.9375),
};
svg()

View file

@ -57,18 +57,16 @@ impl Input {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
let (input_bg, input_hover_bg, input_active_bg) = match self.variant {
InputVariant::Ghost => (
theme.ghost_element,
theme.ghost_element_hover,
theme.ghost_element_active,
cx.theme().colors().ghost_element,
cx.theme().colors().ghost_element_hover,
cx.theme().colors().ghost_element_active,
),
InputVariant::Filled => (
theme.filled_element,
theme.filled_element_hover,
theme.filled_element_active,
cx.theme().colors().element,
cx.theme().colors().element_hover,
cx.theme().colors().element_active,
),
};
@ -90,7 +88,7 @@ impl Input {
.w_full()
.px_2()
.border()
.border_color(theme.transparent)
.border_color(cx.theme().styles.system.transparent)
.bg(input_bg)
.hover(|style| style.bg(input_hover_bg))
.active(|style| style.bg(input_active_bg))

View file

@ -1,4 +1,4 @@
use gpui2::{relative, Hsla, WindowContext};
use gpui2::{relative, rems, Hsla, WindowContext};
use smallvec::SmallVec;
use crate::prelude::*;
@ -18,18 +18,16 @@ pub enum LabelColor {
impl LabelColor {
pub fn hsla(&self, cx: &WindowContext) -> Hsla {
let theme = theme(cx);
match self {
Self::Default => theme.text,
Self::Muted => theme.text_muted,
Self::Default => cx.theme().colors().text,
Self::Muted => cx.theme().colors().text_muted,
Self::Created => gpui2::red(),
Self::Modified => gpui2::red(),
Self::Deleted => gpui2::red(),
Self::Disabled => theme.text_disabled,
Self::Disabled => cx.theme().colors().text_disabled,
Self::Hidden => gpui2::red(),
Self::Placeholder => theme.text_placeholder,
Self::Accent => gpui2::red(),
Self::Placeholder => cx.theme().colors().text_placeholder,
Self::Accent => cx.theme().colors().text_accent,
}
}
}
@ -88,7 +86,7 @@ impl Label {
.bg(LabelColor::Hidden.hsla(cx)),
)
})
.text_size(ui_size(cx, 1.))
.text_size(rems(1.))
.when(self.line_height_style == LineHeightStyle::UILabel, |this| {
this.line_height(relative(1.))
})
@ -126,9 +124,7 @@ impl HighlightedLabel {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
let highlight_color = theme.text_accent;
let highlight_color = cx.theme().colors().text_accent;
let mut highlight_indices = self.highlight_indices.iter().copied().peekable();

View file

@ -1,6 +1,6 @@
use gpui2::{Hsla, ViewContext};
use crate::theme;
use crate::prelude::*;
#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
pub enum PlayerStatus {
@ -139,13 +139,11 @@ impl Player {
}
pub fn cursor_color<V: 'static>(&self, cx: &mut ViewContext<V>) -> Hsla {
let theme = theme(cx);
theme.players[self.index].cursor
cx.theme().styles.player.0[self.index].cursor
}
pub fn selection_color<V: 'static>(&self, cx: &mut ViewContext<V>) -> Hsla {
let theme = theme(cx);
theme.players[self.index].selection
cx.theme().styles.player.0[self.index].selection
}
pub fn avatar_src(&self) -> &str {

View file

@ -9,8 +9,6 @@ impl ToolDivider {
}
fn render<V: 'static>(self, _view: &mut V, cx: &mut ViewContext<V>) -> impl Component<V> {
let theme = theme(cx);
div().w_px().h_3().bg(theme.border)
div().w_px().h_3().bg(cx.theme().colors().border)
}
}

View file

@ -4,21 +4,12 @@ pub use gpui2::{
};
pub use crate::elevation::*;
use crate::settings::user_settings;
pub use crate::ButtonVariant;
pub use theme2::theme;
pub use theme2::ActiveTheme;
use gpui2::{rems, Hsla, Rems};
use gpui2::Hsla;
use strum::EnumIter;
pub fn ui_size(cx: &mut WindowContext, size: f32) -> Rems {
const UI_SCALE_RATIO: f32 = 0.875;
let settings = user_settings(cx);
rems(*settings.ui_scale * UI_SCALE_RATIO * size)
}
#[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, EnumIter)]
pub enum FileSystemStatus {
#[default]
@ -54,15 +45,13 @@ pub enum GitStatus {
impl GitStatus {
pub fn hsla(&self, cx: &WindowContext) -> Hsla {
let theme = theme(cx);
match self {
Self::None => theme.transparent,
Self::Created => theme.git_created,
Self::Modified => theme.git_modified,
Self::Deleted => theme.git_deleted,
Self::Conflict => theme.git_conflict,
Self::Renamed => theme.git_renamed,
Self::None => cx.theme().styles.system.transparent,
Self::Created => cx.theme().styles.git.created,
Self::Modified => cx.theme().styles.git.modified,
Self::Deleted => cx.theme().styles.git.deleted,
Self::Conflict => cx.theme().styles.git.conflict,
Self::Renamed => cx.theme().styles.git.renamed,
}
}
}

View file

@ -58,7 +58,6 @@ pub struct FakeSettings {
pub list_disclosure_style: SettingValue<DisclosureControlStyle>,
pub list_indent_depth: SettingValue<AbsoluteLength>,
pub titlebar: TitlebarSettings,
pub ui_scale: SettingValue<f32>,
}
impl Default for FakeSettings {
@ -68,7 +67,6 @@ impl Default for FakeSettings {
list_disclosure_style: SettingValue::Default(DisclosureControlStyle::ChevronOnHover),
list_indent_depth: SettingValue::Default(rems(0.3).into()),
default_panel_size: SettingValue::Default(rems(16.).into()),
ui_scale: SettingValue::Default(1.),
}
}
}

View file

@ -1,12 +1,12 @@
use std::path::PathBuf;
use std::str::FromStr;
use gpui2::ViewContext;
use gpui2::{AppContext, ViewContext};
use rand::Rng;
use theme2::Theme;
use theme2::ActiveTheme;
use crate::{
theme, Buffer, BufferRow, BufferRows, Button, EditorPane, FileSystemStatus, GitStatus,
Buffer, BufferRow, BufferRows, Button, EditorPane, FileSystemStatus, GitStatus,
HighlightedLine, Icon, Keybinding, Label, LabelColor, ListEntry, ListEntrySize, ListItem,
Livestream, MicStatus, ModifierKeys, PaletteItem, Player, PlayerCallStatus,
PlayerWithCallStatus, ScreenShareStatus, Symbol, Tab, ToggleState, VideoStatus,
@ -643,8 +643,6 @@ pub fn empty_buffer_example() -> Buffer {
}
pub fn hello_world_rust_editor_example(cx: &mut ViewContext<EditorPane>) -> EditorPane {
let theme = theme(cx);
EditorPane::new(
cx,
static_tabs_example(),
@ -652,29 +650,29 @@ pub fn hello_world_rust_editor_example(cx: &mut ViewContext<EditorPane>) -> Edit
vec![Symbol(vec![
HighlightedText {
text: "fn ".to_string(),
color: theme.syntax.color("keyword"),
color: cx.theme().syntax_color("keyword"),
},
HighlightedText {
text: "main".to_string(),
color: theme.syntax.color("function"),
color: cx.theme().syntax_color("function"),
},
])],
hello_world_rust_buffer_example(&theme),
hello_world_rust_buffer_example(cx),
)
}
pub fn hello_world_rust_buffer_example(theme: &Theme) -> Buffer {
pub fn hello_world_rust_buffer_example(cx: &AppContext) -> Buffer {
Buffer::new("hello-world-rust-buffer")
.set_title("hello_world.rs".to_string())
.set_path("src/hello_world.rs".to_string())
.set_language("rust".to_string())
.set_rows(Some(BufferRows {
show_line_numbers: true,
rows: hello_world_rust_buffer_rows(theme),
rows: hello_world_rust_buffer_rows(cx),
}))
}
pub fn hello_world_rust_buffer_rows(theme: &Theme) -> Vec<BufferRow> {
pub fn hello_world_rust_buffer_rows(cx: &AppContext) -> Vec<BufferRow> {
let show_line_number = true;
vec![
@ -686,15 +684,15 @@ pub fn hello_world_rust_buffer_rows(theme: &Theme) -> Vec<BufferRow> {
highlighted_texts: vec![
HighlightedText {
text: "fn ".to_string(),
color: theme.syntax.color("keyword"),
color: cx.theme().syntax_color("keyword"),
},
HighlightedText {
text: "main".to_string(),
color: theme.syntax.color("function"),
color: cx.theme().syntax_color("function"),
},
HighlightedText {
text: "() {".to_string(),
color: theme.text,
color: cx.theme().colors().text,
},
],
}),
@ -710,7 +708,7 @@ pub fn hello_world_rust_buffer_rows(theme: &Theme) -> Vec<BufferRow> {
highlighted_texts: vec![HighlightedText {
text: " // Statements here are executed when the compiled binary is called."
.to_string(),
color: theme.syntax.color("comment"),
color: cx.theme().syntax_color("comment"),
}],
}),
cursors: None,
@ -733,7 +731,7 @@ pub fn hello_world_rust_buffer_rows(theme: &Theme) -> Vec<BufferRow> {
line: Some(HighlightedLine {
highlighted_texts: vec![HighlightedText {
text: " // Print text to the console.".to_string(),
color: theme.syntax.color("comment"),
color: cx.theme().syntax_color("comment"),
}],
}),
cursors: None,
@ -748,15 +746,15 @@ pub fn hello_world_rust_buffer_rows(theme: &Theme) -> Vec<BufferRow> {
highlighted_texts: vec![
HighlightedText {
text: " println!(".to_string(),
color: theme.text,
color: cx.theme().colors().text,
},
HighlightedText {
text: "\"Hello, world!\"".to_string(),
color: theme.syntax.color("string"),
color: cx.theme().syntax_color("string"),
},
HighlightedText {
text: ");".to_string(),
color: theme.text,
color: cx.theme().colors().text,
},
],
}),
@ -771,7 +769,7 @@ pub fn hello_world_rust_buffer_rows(theme: &Theme) -> Vec<BufferRow> {
line: Some(HighlightedLine {
highlighted_texts: vec![HighlightedText {
text: "}".to_string(),
color: theme.text,
color: cx.theme().colors().text,
}],
}),
cursors: None,
@ -782,8 +780,6 @@ pub fn hello_world_rust_buffer_rows(theme: &Theme) -> Vec<BufferRow> {
}
pub fn hello_world_rust_editor_with_status_example(cx: &mut ViewContext<EditorPane>) -> EditorPane {
let theme = theme(cx);
EditorPane::new(
cx,
static_tabs_example(),
@ -791,29 +787,29 @@ pub fn hello_world_rust_editor_with_status_example(cx: &mut ViewContext<EditorPa
vec![Symbol(vec![
HighlightedText {
text: "fn ".to_string(),
color: theme.syntax.color("keyword"),
color: cx.theme().syntax_color("keyword"),
},
HighlightedText {
text: "main".to_string(),
color: theme.syntax.color("function"),
color: cx.theme().syntax_color("function"),
},
])],
hello_world_rust_buffer_with_status_example(&theme),
hello_world_rust_buffer_with_status_example(cx),
)
}
pub fn hello_world_rust_buffer_with_status_example(theme: &Theme) -> Buffer {
pub fn hello_world_rust_buffer_with_status_example(cx: &AppContext) -> Buffer {
Buffer::new("hello-world-rust-buffer-with-status")
.set_title("hello_world.rs".to_string())
.set_path("src/hello_world.rs".to_string())
.set_language("rust".to_string())
.set_rows(Some(BufferRows {
show_line_numbers: true,
rows: hello_world_rust_with_status_buffer_rows(theme),
rows: hello_world_rust_with_status_buffer_rows(cx),
}))
}
pub fn hello_world_rust_with_status_buffer_rows(theme: &Theme) -> Vec<BufferRow> {
pub fn hello_world_rust_with_status_buffer_rows(cx: &AppContext) -> Vec<BufferRow> {
let show_line_number = true;
vec![
@ -825,15 +821,15 @@ pub fn hello_world_rust_with_status_buffer_rows(theme: &Theme) -> Vec<BufferRow>
highlighted_texts: vec![
HighlightedText {
text: "fn ".to_string(),
color: theme.syntax.color("keyword"),
color: cx.theme().syntax_color("keyword"),
},
HighlightedText {
text: "main".to_string(),
color: theme.syntax.color("function"),
color: cx.theme().syntax_color("function"),
},
HighlightedText {
text: "() {".to_string(),
color: theme.text,
color: cx.theme().colors().text,
},
],
}),
@ -849,7 +845,7 @@ pub fn hello_world_rust_with_status_buffer_rows(theme: &Theme) -> Vec<BufferRow>
highlighted_texts: vec![HighlightedText {
text: "// Statements here are executed when the compiled binary is called."
.to_string(),
color: theme.syntax.color("comment"),
color: cx.theme().syntax_color("comment"),
}],
}),
cursors: None,
@ -872,7 +868,7 @@ pub fn hello_world_rust_with_status_buffer_rows(theme: &Theme) -> Vec<BufferRow>
line: Some(HighlightedLine {
highlighted_texts: vec![HighlightedText {
text: " // Print text to the console.".to_string(),
color: theme.syntax.color("comment"),
color: cx.theme().syntax_color("comment"),
}],
}),
cursors: None,
@ -887,15 +883,15 @@ pub fn hello_world_rust_with_status_buffer_rows(theme: &Theme) -> Vec<BufferRow>
highlighted_texts: vec![
HighlightedText {
text: " println!(".to_string(),
color: theme.text,
color: cx.theme().colors().text,
},
HighlightedText {
text: "\"Hello, world!\"".to_string(),
color: theme.syntax.color("string"),
color: cx.theme().syntax_color("string"),
},
HighlightedText {
text: ");".to_string(),
color: theme.text,
color: cx.theme().colors().text,
},
],
}),
@ -910,7 +906,7 @@ pub fn hello_world_rust_with_status_buffer_rows(theme: &Theme) -> Vec<BufferRow>
line: Some(HighlightedLine {
highlighted_texts: vec![HighlightedText {
text: "}".to_string(),
color: theme.text,
color: cx.theme().colors().text,
}],
}),
cursors: None,
@ -924,7 +920,7 @@ pub fn hello_world_rust_with_status_buffer_rows(theme: &Theme) -> Vec<BufferRow>
line: Some(HighlightedLine {
highlighted_texts: vec![HighlightedText {
text: "".to_string(),
color: theme.text,
color: cx.theme().colors().text,
}],
}),
cursors: None,
@ -938,7 +934,7 @@ pub fn hello_world_rust_with_status_buffer_rows(theme: &Theme) -> Vec<BufferRow>
line: Some(HighlightedLine {
highlighted_texts: vec![HighlightedText {
text: "// Marshall and Nate were here".to_string(),
color: theme.syntax.color("comment"),
color: cx.theme().syntax_color("comment"),
}],
}),
cursors: None,
@ -948,16 +944,16 @@ pub fn hello_world_rust_with_status_buffer_rows(theme: &Theme) -> Vec<BufferRow>
]
}
pub fn terminal_buffer(theme: &Theme) -> Buffer {
pub fn terminal_buffer(cx: &AppContext) -> Buffer {
Buffer::new("terminal")
.set_title("zed — fish".to_string())
.set_rows(Some(BufferRows {
show_line_numbers: false,
rows: terminal_buffer_rows(theme),
rows: terminal_buffer_rows(cx),
}))
}
pub fn terminal_buffer_rows(theme: &Theme) -> Vec<BufferRow> {
pub fn terminal_buffer_rows(cx: &AppContext) -> Vec<BufferRow> {
let show_line_number = false;
vec![
@ -969,31 +965,31 @@ pub fn terminal_buffer_rows(theme: &Theme) -> Vec<BufferRow> {
highlighted_texts: vec![
HighlightedText {
text: "maxdeviant ".to_string(),
color: theme.syntax.color("keyword"),
color: cx.theme().syntax_color("keyword"),
},
HighlightedText {
text: "in ".to_string(),
color: theme.text,
color: cx.theme().colors().text,
},
HighlightedText {
text: "profaned-capital ".to_string(),
color: theme.syntax.color("function"),
color: cx.theme().syntax_color("function"),
},
HighlightedText {
text: "in ".to_string(),
color: theme.text,
color: cx.theme().colors().text,
},
HighlightedText {
text: "~/p/zed ".to_string(),
color: theme.syntax.color("function"),
color: cx.theme().syntax_color("function"),
},
HighlightedText {
text: "on ".to_string(),
color: theme.text,
color: cx.theme().colors().text,
},
HighlightedText {
text: " gpui2-ui ".to_string(),
color: theme.syntax.color("keyword"),
color: cx.theme().syntax_color("keyword"),
},
],
}),
@ -1008,7 +1004,7 @@ pub fn terminal_buffer_rows(theme: &Theme) -> Vec<BufferRow> {
line: Some(HighlightedLine {
highlighted_texts: vec![HighlightedText {
text: "λ ".to_string(),
color: theme.syntax.color("string"),
color: cx.theme().syntax_color("string"),
}],
}),
cursors: None,

View file

@ -6,8 +6,6 @@ pub struct Story {}
impl Story {
pub fn container<V: 'static>(cx: &mut ViewContext<V>) -> Div<V> {
let theme = theme(cx);
div()
.size_full()
.flex()
@ -15,15 +13,13 @@ impl Story {
.pt_2()
.px_4()
.font("Zed Mono")
.bg(theme.background)
.bg(cx.theme().colors().background)
}
pub fn title<V: 'static>(cx: &mut ViewContext<V>, title: &str) -> impl Component<V> {
let theme = theme(cx);
div()
.text_xl()
.text_color(theme.text)
.text_color(cx.theme().colors().text)
.child(title.to_owned())
}
@ -32,13 +28,11 @@ impl Story {
}
pub fn label<V: 'static>(cx: &mut ViewContext<V>, label: &str) -> impl Component<V> {
let theme = theme(cx);
div()
.mt_4()
.mb_2()
.text_xs()
.text_color(theme.text)
.text_color(cx.theme().colors().text)
.child(label.to_owned())
}
}