fix(ui): render detail popup labels in bold
Span::style assigns rather than patches, so chaining it after bold() discarded the modifier that bold() had just set and every detail popup label rendered plain. Apply the modifier to the style itself instead. Snapshots compare rendered text and cannot observe styling, so this is pinned by asserting the label span's modifier directly.
This commit is contained in:
5 files changed
+16
-6
No files matched your search
@@ -13,7 +13,7 @@ use crate::ui::widgets::popup::{Popup, Size};
|
||||
use crate::ui::{DrawUi, draw_popup, draw_tabs};
|
||||
use ratatui::Frame;
|
||||
use ratatui::layout::{Alignment, Constraint, Rect};
|
||||
use ratatui::style::{Style, Stylize};
|
||||
use ratatui::style::Style;
|
||||
use ratatui::text::{Line, Span, Text};
|
||||
use ratatui::widgets::{Cell, Paragraph, Row, Wrap};
|
||||
|
||||
@@ -97,7 +97,7 @@ fn draw_track_details(f: &mut Frame<'_>, app: &App<'_>, area: Rect) {
|
||||
let style = style_from_status(&track);
|
||||
|
||||
Line::from(vec![
|
||||
title.bold().style(style),
|
||||
Span::styled(title, style.bold()),
|
||||
Span::styled(split[1..].join(":"), style),
|
||||
])
|
||||
})
|
||||
|
||||
@@ -204,7 +204,7 @@ fn draw_movie_details(f: &mut Frame<'_>, app: &App<'_>, area: Rect) {
|
||||
let style = style_from_download_status(download_status, is_monitored, status.clone());
|
||||
|
||||
Line::from(vec![
|
||||
title.bold().style(style),
|
||||
Span::styled(title, style.bold()),
|
||||
Span::styled(split[1..].join(":"), style),
|
||||
])
|
||||
})
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::ui::widgets::popup::Size;
|
||||
use crate::ui::{DrawUi, draw_popup};
|
||||
use ratatui::Frame;
|
||||
use ratatui::layout::Rect;
|
||||
use ratatui::style::{Style, Stylize};
|
||||
use ratatui::style::Style;
|
||||
use ratatui::text::{Line, Span, Text};
|
||||
use ratatui::widgets::{Paragraph, Wrap};
|
||||
|
||||
@@ -97,7 +97,7 @@ fn edition_detail_line(line: &str, style: Style) -> Line<'static> {
|
||||
|
||||
match line.split_once(':') {
|
||||
Some((label, value)) => Line::from(vec![
|
||||
format!("{label}:").bold().style(style),
|
||||
Span::styled(format!("{label}:"), style.bold()),
|
||||
Span::styled(value.to_owned(), style),
|
||||
]),
|
||||
None => Line::from(Span::styled(line.to_owned(), style)),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use pretty_assertions::assert_eq;
|
||||
use ratatui::style::Modifier;
|
||||
use ratatui::text::Line;
|
||||
use strum::IntoEnumIterator;
|
||||
|
||||
@@ -58,6 +59,15 @@ mod tests {
|
||||
assert_eq!(span_contents(&line), vec!["Title:", " Test Edition"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_edition_detail_line_renders_the_label_in_bold() {
|
||||
let line = edition_detail_line("Title: Test Edition", unmonitored_style());
|
||||
|
||||
assert!(line.spans[0].style.add_modifier.contains(Modifier::BOLD));
|
||||
assert_eq!(line.spans[0].style.fg, unmonitored_style().fg);
|
||||
assert!(!line.spans[1].style.add_modifier.contains(Modifier::BOLD));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_edition_detail_line_keeps_colons_within_a_value() {
|
||||
let line = edition_detail_line("Release Date: 2023-01-05 15:00:00 UTC", primary_style());
|
||||
|
||||
@@ -157,7 +157,7 @@ fn draw_episode_details(f: &mut Frame<'_>, app: &App<'_>, area: Rect) {
|
||||
let style = style_from_status(download, &episode);
|
||||
|
||||
Line::from(vec![
|
||||
title.bold().style(style),
|
||||
Span::styled(title, style.bold()),
|
||||
Span::styled(split[1..].join(":"), style),
|
||||
])
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user