eazygit 0.5.1

A fast TUI for Git with staging, conflicts, rebase, and palette-first UX
Documentation
use crate::config::ThemeConfig;
use ratatui::style::Style;
use ratatui::widgets::{Block, Borders};
use ratatui::widgets::block::Title;

/// Text emphasis mapped to theme roles.
#[allow(dead_code)]
pub enum Emphasis {
    Normal,
    Muted,
    Header,
    Title,
    Error,
    Warning,
    Success,
}

/// Diff kinds for coloring.
#[allow(dead_code)]
pub enum DiffKind {
    Add,
    Remove,
    Context,
    Hunk,
}

pub fn text(theme: &ThemeConfig, emphasis: Emphasis) -> Style {
    match emphasis {
        Emphasis::Normal => Style::default().fg(theme.fg_color()),
        Emphasis::Muted => Style::default().fg(theme.muted_color()),
        Emphasis::Header | Emphasis::Title => Style::default().fg(theme.header_color()),
        Emphasis::Error => Style::default().fg(theme.error_color()),
        Emphasis::Warning => Style::default().fg(theme.warning_color()),
        Emphasis::Success => Style::default().fg(theme.success_color()),
    }
}

pub fn border(theme: &ThemeConfig, focused: bool) -> Style {
    if focused {
        Style::default().fg(theme.border_focused_color())
    } else {
        Style::default().fg(theme.border_color())
    }
}

pub fn selection(theme: &ThemeConfig) -> Style {
    Style::default()
        .bg(theme.selection_bg_color())
        .fg(theme.selection_fg_color())
}

pub fn diff_style(theme: &ThemeConfig, kind: DiffKind) -> Style {
    match kind {
        DiffKind::Add => Style::default().fg(theme.diff_add_color()),
        DiffKind::Remove => Style::default().fg(theme.diff_remove_color()),
        DiffKind::Context => Style::default().fg(theme.diff_context_color()),
        DiffKind::Hunk => Style::default().fg(theme.diff_hunk_color()),
    }
}

pub fn body_style(theme: &ThemeConfig) -> Style {
    Style::default()
        .bg(theme.bg_color())  // Will be fixed by changing bg_color() to respect transparency
        .fg(theme.fg_color())
}

pub fn pane_block<'a>(theme: &ThemeConfig, title: impl Into<Title<'a>>, focused: bool) -> Block<'a> {
    Block::default()
        .borders(Borders::ALL)
        .border_style(border(theme, focused))
        .title(title)
}