Skip to main content

stynx_code_tui/widgets/
banner.rs

1use ratatui::{
2    buffer::Buffer,
3    layout::{Alignment, Rect},
4    style::{Modifier, Style},
5    text::{Line, Span},
6    widgets::{Paragraph, Widget},
7};
8
9use crate::theme;
10
11pub struct Banner;
12
13impl Banner {
14    pub fn new() -> Self { Self }
15}
16
17impl Default for Banner {
18    fn default() -> Self { Self::new() }
19}
20
21const BANNER_ART: &[&str] = &[
22    r"  ____ _____ __   ___   __ __  ",
23    r" / ___|_   _\ \ / / \ | \ \ / / ",
24    r" \___ \ | |  \ V /|  \| |\ V /  ",
25    r"  ___) || |   | | | |\  | | |   ",
26    r" |____/ |_|   |_| |_| \_| |_|   ",
27    r"               c o d e          ",
28];
29
30impl Widget for Banner {
31    fn render(self, area: Rect, buf: &mut Buffer) {
32        let mut lines = vec![Line::from("")];
33        for art_line in BANNER_ART {
34            lines.push(Line::from(Span::styled(
35                *art_line,
36                Style::default().fg(theme::PINE()).add_modifier(Modifier::BOLD),
37            )));
38        }
39        lines.push(Line::from(""));
40        lines.push(Line::from(Span::styled(
41            format!("v{}", env!("CARGO_PKG_VERSION")),
42            Style::default().fg(theme::MUTED()),
43        )));
44        Paragraph::new(lines).alignment(Alignment::Center).render(area, buf);
45    }
46}