Skip to main content

endpoint_validator/tui/widgets/
button.rs

1use ratatui::{
2    style::{Color, Modifier, Style},
3    text::Span,
4    widgets::{Block, Borders, Paragraph},
5};
6
7pub fn create_button<'a>(label: &'a str, is_active: bool, is_focused: bool) -> Paragraph<'a> {
8    let style = if is_active {
9        Style::default()
10            .fg(Color::Gray)
11            .bg(Color::Green)
12            .add_modifier(Modifier::BOLD)
13    } else {
14        Style::default().fg(Color::Gray).bg(Color::DarkGray)
15    };
16
17    let block = Block::default()
18        .borders(Borders::ALL)
19        .border_style(Style::default().fg(if is_focused {
20            Color::Yellow
21        } else {
22            Color::Gray
23        }));
24
25    Paragraph::new(Span::styled(label, style))
26        .alignment(ratatui::layout::Alignment::Center)
27        .block(block)
28}