feat: combine button label config into an array

This commit is contained in:
greg 2024-10-17 07:59:18 +02:00 committed by sxyazi
parent cb27f5c74a
commit d2fe67ab86
No known key found for this signature in database
3 changed files with 14 additions and 16 deletions

View file

@ -101,13 +101,12 @@ selected = { reversed = true }
# : Confirm {{{
[confirm]
button_yes = " [Y]es "
button_no = " (N)o "
border = { fg = "blue" }
title = { fg = "blue" }
content = { }
list = { }
buttons = { reversed = true }
button_labels = [" [Y]es ", " (N)o "]
border = { fg = "blue" }
title = { fg = "blue" }
content = { }
list = { }
buttons = { reversed = true }
# : }}}

View file

@ -117,13 +117,12 @@ pub struct Input {
#[derive(Deserialize, Serialize)]
pub struct Confirm {
pub button_yes: String,
pub button_no: String,
pub border: Style,
pub title: Style,
pub content: Style,
pub list: Style,
pub buttons: Style,
pub button_labels: [String; 2],
pub border: Style,
pub title: Style,
pub content: Style,
pub list: Style,
pub buttons: Style,
}
#[derive(Deserialize, Serialize)]

View file

@ -14,10 +14,10 @@ impl Widget for Buttons {
let chunks =
ratatui::layout::Layout::horizontal([Constraint::Fill(1), Constraint::Fill(1)]).split(area);
Paragraph::new(Span::raw(&THEME.confirm.button_yes).style(THEME.confirm.buttons))
Paragraph::new(Span::raw(&THEME.confirm.button_labels[0]).style(THEME.confirm.buttons))
.centered()
.render(chunks[0], buf);
Paragraph::new(Span::raw(&THEME.confirm.button_no).style(THEME.confirm.buttons))
Paragraph::new(Span::raw(&THEME.confirm.button_labels[1]).style(THEME.confirm.buttons))
.centered()
.render(chunks[1], buf);
}