Skip to content

Commit

Permalink
chore(tui): dim pane text helpers and remove dead code. (#9542)
Browse files Browse the repository at this point in the history
### Description

I started noticing that my logs and the text help were looking quite
similar. This differentiates the two so its more obvious at a glance.

### Testing Instructions

![CleanShot 2024-11-29 at 12 52
40](https://github.com/user-attachments/assets/fe1facaf-ca96-4318-a008-cac2322a0fe4)
  • Loading branch information
anthonyshew authored Nov 29, 2024
1 parent bd3fcf1 commit ed6bf33
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions crates/turborepo-ui/src/tui/pane.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use ratatui::{
style::Style,
style::{Modifier, Style, Stylize},
text::Line,
widgets::{Block, Widget},
};
Expand Down Expand Up @@ -34,12 +34,8 @@ impl<'a, W> TerminalPane<'a, W> {
}
}

fn highlight(&self) -> bool {
matches!(self.section, LayoutSections::Pane)
}

fn footer(&self) -> Line {
let build_message_vec = |footer_text: &str| -> String {
let build_message_vec = |footer_text: &str| -> Line {
let mut messages = vec![footer_text];

if !self.has_sidebar {
Expand All @@ -51,18 +47,18 @@ impl<'a, W> TerminalPane<'a, W> {
}

// Spaces are used to pad the footer text for aesthetics
format!(" {}", messages.join(", "))
let formatted_messages = format!(" {}", messages.join(", "));

Line::styled(
formatted_messages.to_string(),
Style::default().add_modifier(Modifier::DIM),
)
.left_aligned()
};

match self.section {
LayoutSections::Pane => {
let messages = build_message_vec(FOOTER_TEXT_ACTIVE);
Line::from(messages).left_aligned()
}
LayoutSections::TaskList => {
let messages = build_message_vec(FOOTER_TEXT_INACTIVE);
Line::from(messages).left_aligned()
}
LayoutSections::Pane => build_message_vec(FOOTER_TEXT_ACTIVE),
LayoutSections::TaskList => build_message_vec(FOOTER_TEXT_INACTIVE),
LayoutSections::Search { results, .. } => {
Line::from(format!("/ {}", results.query())).left_aligned()
}
Expand All @@ -77,13 +73,12 @@ impl<'a, W> Widget for &TerminalPane<'a, W> {
{
let screen = self.terminal_output.parser.screen();
let block = Block::default()
.title(self.terminal_output.title(self.task_name))
.title_bottom(self.footer())
.style(if self.highlight() {
Style::new().fg(ratatui::style::Color::Yellow)
} else {
Style::new()
});
.title(
self.terminal_output
.title(self.task_name)
.add_modifier(Modifier::DIM),
)
.title_bottom(self.footer());

let term = PseudoTerminal::new(screen).block(block);
term.render(area, buf)
Expand Down

0 comments on commit ed6bf33

Please sign in to comment.