Skip to content

Commit

Permalink
fix: finalise color scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
nagyben committed May 27, 2024
1 parent 41ce73d commit 6d7ff0f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 41 deletions.
24 changes: 15 additions & 9 deletions src/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ use ratatui::style::Color;

// based on the catpuccin-mocha color theme
// https://github.com/catppuccin/catppuccin/blob/main/docs/style-guide.md
pub(crate) const BG_COLOR: Color = Color::from_u32(0x001e1e2e);
pub(crate) const BODY_COLOR: Color = Color::from_u32(0x00cdd6f4);
pub(crate) const ACTIVE_BORDER_COLOR: Color = Color::from_u32(0x00f5e0dc);
pub(crate) const INACTIVE_BORDER_COLOR: Color = Color::from_u32(0x006c7086);
pub(crate) const BASE: Color = Color::from_u32(0x001e1e2e);
pub(crate) const TEXT: Color = Color::from_u32(0x00cdd6f4);
pub(crate) const OVERLAY0: Color = Color::from_u32(0x006c7086);
pub(crate) const SURFACE0: Color = Color::from_u32(0x00313244);

pub(crate) const RED_COLOR: Color = Color::from_u32(0x00f38ba8);
pub(crate) const GREEN_COLOR: Color = Color::from_u32(0x00a6e3a1);
pub(crate) const YELLOW_COLOR: Color = Color::from_u32(0x00f9e2af);
pub(crate) const BLUE_COLOR: Color = Color::from_u32(0x0089b4fa);
pub(crate) const PINK_COLOR: Color = Color::from_u32(0x00f5c2e7);
pub(crate) const ROSEWATER: Color = Color::from_u32(0x00f5e0dc);
pub(crate) const RED: Color = Color::from_u32(0x00f38ba8);
pub(crate) const GREEN: Color = Color::from_u32(0x00a6e3a1);
pub(crate) const YELLOW: Color = Color::from_u32(0x00f9e2af);
pub(crate) const BLUE: Color = Color::from_u32(0x0089b4fa);
pub(crate) const PINK: Color = Color::from_u32(0x00f5c2e7);
pub(crate) const PEACH: Color = Color::from_u32(0x00fab387);
pub(crate) const TEAL: Color = Color::from_u32(0x0094e2d5);
pub(crate) const SAPPHIRE: Color = Color::from_u32(0x0074c7ec);
pub(crate) const LAVENDER: Color = Color::from_u32(0x00b4befe);
pub(crate) const CRUST: Color = Color::from_u32(0x0011111b);
10 changes: 5 additions & 5 deletions src/components/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use tracing::debug;
use super::Component;
use crate::{
action::Action,
colors::{BG_COLOR, BLUE_COLOR, PINK_COLOR, YELLOW_COLOR},
colors::{BASE, BLUE, PINK, YELLOW},
tui::Frame,
};

Expand Down Expand Up @@ -71,11 +71,11 @@ impl Component for Notifications {
.style(
Style::default()
.fg(match &notification.0 {
Notification::Info(_) => BLUE_COLOR,
Notification::Warning(_) => YELLOW_COLOR,
Notification::Error(_) => PINK_COLOR,
Notification::Info(_) => BLUE,
Notification::Warning(_) => YELLOW,
Notification::Error(_) => PINK,
})
.bg(BG_COLOR),
.bg(BASE),
)
.alignment(Alignment::Right);

Expand Down
11 changes: 6 additions & 5 deletions src/components/pull_request_info_overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use tracing::{debug, info};
use super::pull_request::{self, pull_requests_query::PullRequestState};
use crate::{
action::Action,
colors::{BASE, TEXT},
components::{
pull_request::{
pull_requests_query::{self, PullRequestReviewState},
Expand Down Expand Up @@ -88,7 +89,8 @@ impl Component for PullRequestInfoOverlay {
let block = Block::default()
.borders(Borders::ALL)
.border_type(BorderType::Rounded)
.border_style(Style::default().fg(Color::White).bg(Color::Black));
.border_style(Style::default().fg(TEXT).bg(BASE))
.bg(BASE);
f.render_widget(Clear, area);
f.render_widget(block, area);

Expand All @@ -112,14 +114,13 @@ impl Component for PullRequestInfoOverlay {
})
.into(),
])
.style(Style::default().fg(Color::White).add_modifier(Modifier::BOLD))
.style(Style::default().fg(TEXT).add_modifier(Modifier::BOLD))
.alignment(Alignment::Left);

let horizontal_separator =
Paragraph::new("─".repeat(area.width as usize)).style(Style::default().fg(Color::White));
let horizontal_separator = Paragraph::new("─".repeat(area.width as usize)).style(Style::default().fg(TEXT));

let body = Paragraph::new(&*pr.body)
.style(Style::default().fg(Color::White))
.style(Style::default().fg(TEXT))
.alignment(Alignment::Left)
.scroll((self.scroll_offset, 0));

Expand Down
35 changes: 13 additions & 22 deletions src/components/pull_request_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use super::{
};
use crate::{
action::Action,
colors::{ACTIVE_BORDER_COLOR, BG_COLOR, BLUE_COLOR, BODY_COLOR},
colors::{BASE, BLUE, GREEN, LAVENDER, OVERLAY0, PEACH, PINK, RED, ROSEWATER, SURFACE0, TEXT, YELLOW},
components::{
pull_request::{
pull_requests_query::{self, PullRequestReviewState},
Expand Down Expand Up @@ -98,13 +98,9 @@ impl PullRequestList {
.enumerate()
.map(|(i, &column)| {
if i == selected_column {
Cell::from(Line::from(vec![
Span::from("[").style(Style::default().fg(BLUE_COLOR)),
Span::from(column),
Span::from("]*").style(Style::default().fg(BLUE_COLOR)),
]))
Cell::from(column).style(Style::new().fg(PEACH))
} else {
Cell::from(column)
Cell::from(column).style(Style::new().fg(TEXT))
}
})
.collect()
Expand All @@ -124,11 +120,8 @@ impl PullRequestList {
Cell::from(format!("{}", pr.created_at.format("%Y-%m-%d %H:%M"))),
Cell::from(format!("{}", pr.updated_at.format("%Y-%m-%d %H:%M"))),
Cell::from(Line::from(vec![
Span::styled(format!("{:+}", pr.additions), Style::new().fg(Color::LightGreen)),
Span::styled(
format!("{:+}", (0 - pr.deletions as isize)),
Style::new().fg(Color::LightRed),
),
Span::styled(format!("{:+}", pr.additions), Style::new().fg(GREEN)),
Span::styled(format!("{:+}", (0 - pr.deletions as isize)), Style::new().fg(RED)),
])),
Cell::from(match pr.state {
pull_requests_query::PullRequestState::OPEN => {
Expand All @@ -146,11 +139,9 @@ impl PullRequestList {
.flat_map(|prr| {
vec![
Span::styled(prr.author.clone(), match prr.state {
PullRequestReviewState::COMMENTED => Style::new().fg(Color::LightBlue),
PullRequestReviewState::APPROVED => Style::new().fg(Color::LightGreen),
PullRequestReviewState::CHANGES_REQUESTED => {
Style::new().fg(Color::LightYellow)
},
PullRequestReviewState::COMMENTED => Style::new().fg(BLUE),
PullRequestReviewState::APPROVED => Style::new().fg(GREEN),
PullRequestReviewState::CHANGES_REQUESTED => Style::new().fg(YELLOW),
_ => Style::new().fg(Color::Gray),
}),
Span::raw(" "),
Expand Down Expand Up @@ -179,10 +170,10 @@ impl PullRequestList {
Block::default()
.borders(Borders::ALL)
.border_type(BorderType::Rounded)
.border_style(ACTIVE_BORDER_COLOR)
.style(Style::default().bg(BG_COLOR).fg(BODY_COLOR)),
.border_style(ROSEWATER)
.style(Style::default().bg(BASE).fg(TEXT)),
)
.highlight_style(Style::new().reversed().add_modifier(Modifier::BOLD))
.highlight_style(Style::new().bg(SURFACE0).fg(TEXT).add_modifier(Modifier::BOLD))
.highlight_symbol(">> ");

f.render_stateful_widget(table, area, &mut table_state);
Expand All @@ -199,7 +190,7 @@ impl PullRequestList {
String::from("Error: refresh key not bound in the config!")
},
)
.style(Style::default().fg(Color::White))
.style(Style::default().fg(TEXT))
.alignment(Alignment::Center);
f.render_widget(text, centered_rect(area, 100, 10))
}
Expand Down Expand Up @@ -241,7 +232,7 @@ impl PullRequestList {
Line::from("Error: GITHUB_TOKEN is not set!"),
Line::from("Create a Personal Access Token in the GitHub UI and set the GITHUB_TOKEN environment variable to its value before running ghtui"),
Line::from("Press 'q' or 'ctrl-c' to quit"),
]).style(Style::default().fg(Color::Red))
]).style(Style::default().fg(RED))
.alignment(Alignment::Center);
f.render_widget(text, centered_rect(area, 100, 10));
}
Expand Down

0 comments on commit 6d7ff0f

Please sign in to comment.