use ratatui::style::{Color, Modifier, Style};
#[derive(Debug, Clone)]
pub struct FormStyle {
pub title: Style,
pub label: Style,
pub label_focused: Style,
pub input: Style,
pub input_focused: Style,
pub placeholder: Style,
pub error: Style,
pub button: Style,
pub button_focused: Style,
pub border: Style,
pub border_focused: Style,
}
impl Default for FormStyle {
fn default() -> Self {
Self {
title: Style::default()
.fg(Color::Cyan)
.add_modifier(Modifier::BOLD),
label: Style::default().fg(Color::White),
label_focused: Style::default()
.fg(Color::Cyan)
.add_modifier(Modifier::BOLD),
input: Style::default().fg(Color::White).bg(Color::DarkGray),
input_focused: Style::default().fg(Color::White).bg(Color::Blue),
placeholder: Style::default().fg(Color::Gray),
error: Style::default().fg(Color::Red),
button: Style::default().fg(Color::White).bg(Color::DarkGray),
button_focused: Style::default()
.fg(Color::Black)
.bg(Color::Green)
.add_modifier(Modifier::BOLD),
border: Style::default().fg(Color::Gray),
border_focused: Style::default().fg(Color::Cyan),
}
}
}
impl FormStyle {
pub fn new() -> Self {
Self::default()
}
pub fn title(mut self, style: Style) -> Self {
self.title = style;
self
}
pub fn label(mut self, style: Style) -> Self {
self.label = style;
self
}
pub fn label_focused(mut self, style: Style) -> Self {
self.label_focused = style;
self
}
pub fn input(mut self, style: Style) -> Self {
self.input = style;
self
}
pub fn input_focused(mut self, style: Style) -> Self {
self.input_focused = style;
self
}
pub fn placeholder(mut self, style: Style) -> Self {
self.placeholder = style;
self
}
pub fn error(mut self, style: Style) -> Self {
self.error = style;
self
}
pub fn button(mut self, style: Style) -> Self {
self.button = style;
self
}
pub fn button_focused(mut self, style: Style) -> Self {
self.button_focused = style;
self
}
pub fn dark() -> Self {
Self::default()
}
pub fn light() -> Self {
Self {
title: Style::default()
.fg(Color::Blue)
.add_modifier(Modifier::BOLD),
label: Style::default().fg(Color::Black),
label_focused: Style::default()
.fg(Color::Blue)
.add_modifier(Modifier::BOLD),
input: Style::default().fg(Color::Black).bg(Color::White),
input_focused: Style::default().fg(Color::Black).bg(Color::LightBlue),
placeholder: Style::default().fg(Color::DarkGray),
error: Style::default().fg(Color::Red),
button: Style::default().fg(Color::Black).bg(Color::White),
button_focused: Style::default()
.fg(Color::White)
.bg(Color::Blue)
.add_modifier(Modifier::BOLD),
border: Style::default().fg(Color::DarkGray),
border_focused: Style::default().fg(Color::Blue),
}
}
}