Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(tui): dim pane text helpers and remove dead code. #9542

Merged
merged 2 commits into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead code! There's no border to highlight anymore.

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() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't do these yellow highlights. The only place in the program we do yellow highlights now is in the task table (not here), so we can remove this.

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
Loading