From 1f65effe57b85d126fcb5689d6d37ec3f768502e Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Tue, 25 Jul 2023 10:58:44 -0600 Subject: [PATCH] Update status bar theming Co-Authored-By: Nate Butler --- Cargo.lock | 1 + crates/theme/src/theme.rs | 2 +- crates/vim/Cargo.toml | 1 + crates/vim/src/mode_indicator.rs | 5 ++++- crates/vim/src/vim.rs | 5 ++--- crates/workspace/src/status_bar.rs | 8 ++------ styles/src/style_tree/status_bar.ts | 31 +++++++++++++---------------- 7 files changed, 25 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e805a87230..704eba74b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8514,6 +8514,7 @@ dependencies = [ "indoc", "itertools", "language", + "language_selector", "log", "nvim-rs", "parking_lot 0.11.2", diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 82c3f2a142..4766f636f3 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -402,7 +402,7 @@ pub struct StatusBar { pub height: f32, pub item_spacing: f32, pub cursor_position: TextStyle, - pub vim_mode_indicator: TextStyle, + pub vim_mode_indicator: ContainedText, pub active_language: Interactive, pub auto_update_progress_message: TextStyle, pub auto_update_done_message: TextStyle, diff --git a/crates/vim/Cargo.toml b/crates/vim/Cargo.toml index 3a5974d6c9..2d394e3dcf 100644 --- a/crates/vim/Cargo.toml +++ b/crates/vim/Cargo.toml @@ -33,6 +33,7 @@ search = { path = "../search" } settings = { path = "../settings" } workspace = { path = "../workspace" } theme = { path = "../theme" } +language_selector = { path = "../language_selector"} [dev-dependencies] indoc.workspace = true diff --git a/crates/vim/src/mode_indicator.rs b/crates/vim/src/mode_indicator.rs index 683024267c..e0d2b65955 100644 --- a/crates/vim/src/mode_indicator.rs +++ b/crates/vim/src/mode_indicator.rs @@ -40,7 +40,10 @@ impl View for ModeIndicator { Mode::Visual { line: false } => "-- VISUAL --", Mode::Visual { line: true } => "VISUAL LINE ", }; - Label::new(text, theme.vim_mode_indicator.clone()).into_any() + Label::new(text, theme.vim_mode_indicator.text.clone()) + .contained() + .with_style(theme.vim_mode_indicator.container) + .into_any() } } diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index 54d18825cd..363901d260 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -289,9 +289,8 @@ impl Vim { Some(cx.add_view(|_| ModeIndicator::new(vim.state.mode))); }; let mode_indicator = vim.mode_indicator.as_ref().unwrap(); - // TODO: would it be better to depend on the diagnostics crate - // so we can pass the type directly? - let position = status_bar.position_of_named_item("DiagnosticIndicator"); + let position = status_bar + .position_of_item::(); if let Some(position) = position { status_bar.insert_item_after(position, mode_indicator.clone(), cx) } else { diff --git a/crates/workspace/src/status_bar.rs b/crates/workspace/src/status_bar.rs index 8c3cfe2053..8726eaf569 100644 --- a/crates/workspace/src/status_bar.rs +++ b/crates/workspace/src/status_bar.rs @@ -107,17 +107,13 @@ impl StatusBar { where T: StatusItemView, { - self.position_of_named_item(T::ui_name()) - } - - pub fn position_of_named_item(&self, name: &str) -> Option { for (index, item) in self.left_items.iter().enumerate() { - if item.as_ref().ui_name() == name { + if item.as_ref().ui_name() == T::ui_name() { return Some(index); } } for (index, item) in self.right_items.iter().enumerate() { - if item.as_ref().ui_name() == name { + if item.as_ref().ui_name() == T::ui_name() { return Some(index + self.left_items.len()); } } diff --git a/styles/src/style_tree/status_bar.ts b/styles/src/style_tree/status_bar.ts index 74ad7064d1..06afc37823 100644 --- a/styles/src/style_tree/status_bar.ts +++ b/styles/src/style_tree/status_bar.ts @@ -1,6 +1,8 @@ import { background, border, foreground, text } from "./components" import { interactive, toggleable } from "../element" import { useTheme } from "../common" +import { text_button } from "../component/text_button" + export default function status_bar(): any { const theme = useTheme() @@ -26,21 +28,16 @@ export default function status_bar(): any { right: 6, }, border: border(layer, { top: true, overlay: true }), - cursor_position: text(layer, "sans", "variant"), - vim_mode_indicator: text(layer, "mono", "variant"), - active_language: interactive({ - base: { - padding: { left: 6, right: 6 }, - ...text(layer, "sans", "variant"), - }, - state: { - hovered: { - ...text(layer, "sans", "on"), - }, - }, + cursor_position: text(layer, "sans", "variant", { size: "xs" }), + vim_mode_indicator: { + margin: { left: 6 }, + ...text(layer, "mono", "variant", { size: "xs" }), + }, + active_language: text_button({ + color: "variant" }), - auto_update_progress_message: text(layer, "sans", "variant"), - auto_update_done_message: text(layer, "sans", "variant"), + auto_update_progress_message: text(layer, "sans", "variant", { size: "xs" }), + auto_update_done_message: text(layer, "sans", "variant", { size: "xs" }), lsp_status: interactive({ base: { ...diagnostic_status_container, @@ -60,9 +57,9 @@ export default function status_bar(): any { }), diagnostic_message: interactive({ base: { - ...text(layer, "sans"), + ...text(layer, "sans", { size: "xs" }), }, - state: { hovered: text(layer, "sans", "hovered") }, + state: { hovered: text(layer, "sans", "hovered", { size: "xs" }) }, }), diagnostic_summary: interactive({ base: { @@ -118,7 +115,7 @@ export default function status_bar(): any { icon_color: foreground(layer, "variant"), label: { margin: { left: 6 }, - ...text(layer, "sans", { size: "sm" }), + ...text(layer, "sans", { size: "xs" }), }, }, state: {