feat: improve empty hint
This commit is contained in:
parent
c704dd1a47
commit
3ff7770471
18
src/lib.rs
18
src/lib.rs
@ -428,8 +428,10 @@ impl Widget for &mut App {
|
||||
Color::White
|
||||
};
|
||||
|
||||
let items: Vec<Row> = self
|
||||
.logs
|
||||
let items: Vec<Row> = if self.logs.is_empty() {
|
||||
vec![Row::new(vec!["Nothing here yet"])]
|
||||
} else {
|
||||
self.logs
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, item)| {
|
||||
@ -457,22 +459,16 @@ impl Widget for &mut App {
|
||||
.style(Style::new().fg(row_text_color))
|
||||
.height(2)
|
||||
})
|
||||
.collect();
|
||||
.collect()
|
||||
};
|
||||
|
||||
let empty = items.is_empty();
|
||||
|
||||
let mut table = Table::new(items, [Constraint::Min(200), Constraint::Min(20)])
|
||||
let table = Table::new(items, [Constraint::Min(200), Constraint::Min(20)])
|
||||
.block(block)
|
||||
.header(header)
|
||||
.highlight_symbol("> ")
|
||||
.row_highlight_style(highlight_style)
|
||||
.highlight_spacing(HighlightSpacing::Always);
|
||||
|
||||
if empty {
|
||||
table = table.footer(
|
||||
Row::new(vec!["Nothing here yet"]).style(Style::default().fg(COLOR_SECONDARY)),
|
||||
);
|
||||
}
|
||||
StatefulWidget::render(table, area, buf, &mut self.state);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user