-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporary commit for development on another machine
- Loading branch information
Showing
3 changed files
with
235 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
version: "1" | ||
|
||
# fg_color: name | hex | integer | ||
# bg_color: name | hex | integer | ||
# modifier: "bold" | "dim" | "italic" | "underlined" | "slow_blink" | "rapid_blink" | "reversed" | "hidden" | "crossed_out" | ||
|
||
theme: | ||
tab: | ||
divider: "|" | ||
base: | ||
fg_color: darkgray | ||
bg_color: default | ||
modifier: reversed | ||
active: | ||
fg_color: default | ||
bg_color: default | ||
modifier: reversed | ||
mouse_over: | ||
fg_color: green | ||
bg_color: default | ||
modifier: reversed | ||
# context: | ||
# fg_color: default | ||
# bg_color: default | ||
# modifier: none | ||
# component: | ||
# title: | ||
# fg_color: default | ||
# bg_color: default | ||
# modifier: none | ||
# border: | ||
# active: | ||
# fg_color: default | ||
# bg_color: default | ||
# modifier: none | ||
# inactive: | ||
# fg_color: default | ||
# bg_color: default | ||
# modifier: none | ||
# mouse_over: | ||
# fg_color: default | ||
# bg_color: default | ||
# modifier: none | ||
# body: | ||
# fg_color: default | ||
# bg_color: default | ||
# pod: | ||
# table_header: | ||
# fg_color: default | ||
# bg_color: default | ||
# modifier: none | ||
# job_pod: | ||
# fg_color: default | ||
# bg_color: default | ||
# modifier: none | ||
# error_pod: | ||
# fg_color: default | ||
# bg_color: default | ||
# modifier: none | ||
# event: | ||
# summary: | ||
# fg_color: default | ||
# bg_color: default | ||
# modifier: none | ||
# message: | ||
# fg_color: default | ||
# bg_color: default | ||
# modifier: none | ||
# list: | ||
# resouce: | ||
# fg_color: default | ||
# bg_color: default | ||
# modifier: none | ||
# table_header: | ||
# fg_color: default | ||
# bg_color: default | ||
# modifier: none | ||
# table_item: | ||
# fg_color: default | ||
# bg_color: default | ||
# modifier: none | ||
|
||
# system: | ||
# event: | ||
# polling_interval: 5 | ||
# | ||
# keybinding: | ||
# up: | ||
# - "up" | ||
# - "k" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::{FocusableThemeStyle, ThemeStyle}; | ||
|
||
/// コンポーネントのテーマ | ||
#[derive(Default, Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] | ||
pub struct ComponentTheme { | ||
pub title: ThemeStyle, | ||
|
||
pub border: FocusableThemeStyle, | ||
|
||
pub body: ThemeStyle, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
use indoc::indoc; | ||
use pretty_assertions::assert_eq; | ||
use ratatui::style::{Color, Modifier}; | ||
|
||
#[test] | ||
fn default_event_theme() { | ||
let actual = ComponentTheme::default(); | ||
|
||
let expected = ComponentTheme { | ||
title: ThemeStyle::default(), | ||
border: FocusableThemeStyle::default(), | ||
body: ThemeStyle::default(), | ||
}; | ||
|
||
assert_eq!(actual, expected); | ||
} | ||
|
||
#[test] | ||
fn test_serialize_event_theme() { | ||
let theme = ComponentTheme { | ||
title: ThemeStyle { | ||
fg_color: Color::Red, | ||
bg_color: Color::Blue, | ||
modifier: Modifier::BOLD, | ||
}, | ||
border: FocusableThemeStyle { | ||
active: ThemeStyle { | ||
fg_color: Color::Green, | ||
bg_color: Color::Yellow, | ||
modifier: Modifier::ITALIC, | ||
}, | ||
inactive: ThemeStyle { | ||
fg_color: Color::DarkGray, | ||
bg_color: Color::default(), | ||
modifier: Modifier::default(), | ||
}, | ||
mouse_over: ThemeStyle::default(), | ||
}, | ||
body: ThemeStyle { | ||
fg_color: Color::Blue, | ||
bg_color: Color::Red, | ||
modifier: Modifier::ITALIC, | ||
}, | ||
}; | ||
|
||
let actual = serde_yaml::to_string(&theme).unwrap(); | ||
|
||
let expected = indoc! {r#" | ||
title: | ||
fg_color: red | ||
bg_color: blue | ||
modifier: bold | ||
border: | ||
active: | ||
fg_color: green | ||
bg_color: yellow | ||
modifier: italic | ||
inactive: | ||
fg_color: darkgray | ||
bg_color: default | ||
modifier: none | ||
mouse_over: | ||
fg_color: default | ||
bg_color: default | ||
modifier: none | ||
body: | ||
fg_color: blue | ||
bg_color: red | ||
modifier: italic | ||
"#}; | ||
|
||
assert_eq!(actual, expected); | ||
} | ||
|
||
#[test] | ||
fn test_deserialize_event_theme() { | ||
let data = indoc! {r#" | ||
title: | ||
fg_color: red | ||
bg_color: blue | ||
modifier: bold | ||
border: | ||
active: | ||
fg_color: green | ||
bg_color: yellow | ||
modifier: italic | ||
inactive: | ||
fg_color: default | ||
bg_color: default | ||
modifier: none | ||
body: | ||
fg_color: blue | ||
bg_color: red | ||
modifier: italic | ||
"#}; | ||
|
||
let actual: ComponentTheme = serde_yaml::from_str(data).unwrap(); | ||
|
||
let expected = ComponentTheme { | ||
title: ThemeStyle { | ||
fg_color: Color::Red, | ||
bg_color: Color::Blue, | ||
modifier: Modifier::BOLD, | ||
}, | ||
border: FocusableThemeStyle { | ||
active: ThemeStyle { | ||
fg_color: Color::Green, | ||
bg_color: Color::Yellow, | ||
modifier: Modifier::ITALIC, | ||
}, | ||
inactive: ThemeStyle::default(), | ||
mouse_over: ThemeStyle::default(), | ||
}, | ||
body: ThemeStyle { | ||
fg_color: Color::Blue, | ||
bg_color: Color::Red, | ||
modifier: Modifier::ITALIC, | ||
}, | ||
}; | ||
|
||
assert_eq!(actual, expected); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters