Skip to content

Commit 47fc19c

Browse files
authored
feat(tui): add branded start screen (#39)
* feat(tui): add branded start screen * fix(tui): satisfy clippy for start width
1 parent 0dd7923 commit 47fc19c

4 files changed

Lines changed: 279 additions & 75 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "kit"
3-
version = "0.1.100"
3+
version = "0.1.101"
44
edition = "2024"
55
rust-version = "1.94.0"
66
publish = false

src/tui/theme.rs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,23 @@ pub fn bar() -> Style {
141141
Style::default()
142142
}
143143

144+
/// Raised surface for the prompt composer.
145+
pub fn composer() -> Style {
146+
composer_for(crossterm::style::available_color_count())
147+
}
148+
149+
fn composer_for(color_count: u16) -> Style {
150+
match color_count {
151+
u16::MAX => Style::default()
152+
.fg(Color::Rgb(0xf2, 0xf2, 0xf2))
153+
.bg(Color::Rgb(0x32, 0x36, 0x3d)),
154+
colors if colors >= 256 => Style::default()
155+
.fg(Color::Indexed(255))
156+
.bg(Color::Indexed(238)),
157+
_ => Style::default().fg(Color::White).bg(Color::DarkGray),
158+
}
159+
}
160+
144161
pub fn selection() -> Style {
145162
Style::default().add_modifier(Modifier::REVERSED)
146163
}
@@ -183,9 +200,12 @@ pub fn duration(millis: u64) -> String {
183200

184201
#[cfg(test)]
185202
mod tests {
186-
use ratatui::style::{Color, Modifier};
203+
use ratatui::style::{Color, Modifier, Style};
187204

188-
use super::{BRAND_ANSI, BRAND_RGB, bar, brand_rainbow_for, code, duration, selection, text};
205+
use super::{
206+
BRAND_ANSI, BRAND_RGB, bar, brand_rainbow_for, code, composer, composer_for, duration,
207+
selection, text,
208+
};
189209

190210
#[test]
191211
fn formats_turn_durations_through_weeks() {
@@ -215,6 +235,20 @@ mod tests {
215235
);
216236
}
217237

238+
#[test]
239+
fn composer_uses_a_contrasting_surface() {
240+
assert!(composer().fg.is_some());
241+
assert!(composer().bg.is_some());
242+
assert_eq!(
243+
composer_for(u16::MAX),
244+
Style::default()
245+
.fg(Color::Rgb(0xf2, 0xf2, 0xf2))
246+
.bg(Color::Rgb(0x32, 0x36, 0x3d))
247+
);
248+
assert_eq!(composer_for(256).bg, Some(Color::Indexed(238)));
249+
assert_eq!(composer_for(8).bg, Some(Color::DarkGray));
250+
}
251+
218252
#[test]
219253
fn true_colour_uses_the_speakeasy_brand_ramp() {
220254
assert_eq!(brand_rainbow_for(u16::MAX), &BRAND_RGB);

0 commit comments

Comments
 (0)