-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Alternating Colors for Help Table #466
Merged
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
dccbe93
add alternating row colors for help table
przb f787a96
add support for dark gray coloring
przb 3535a91
add secondary row to the ComponentStyle struct
przb 06f21e1
run cargo fmt
przb 121f965
remove dark gray from coloring for rgb values instead
przb 28d01b8
disable alternate row coloring by default
przb 6b2b714
add secondary row to the component styles docs
przb 1173bf0
add extended dracula theme with secondary row styling
przb a02fd3c
Merge branch 'alternating_help_table_colors' of github.com:przb/spoti…
przb dec43d0
add brief description for dracula2
przb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -58,6 +58,9 @@ pub struct Palette { | |
pub bright_blue: Color, | ||
#[serde(default = "Color::bright_yellow")] | ||
pub bright_yellow: Color, | ||
|
||
#[serde(default = "Color::dark_gray")] | ||
pub dark_gray: Color, | ||
} | ||
|
||
#[derive(Clone, Debug, Default, Deserialize)] | ||
|
@@ -74,6 +77,7 @@ pub struct ComponentStyle { | |
pub playlist_desc: Option<Style>, | ||
pub table_header: Option<Style>, | ||
pub selection: Option<Style>, | ||
pub secondary_row: Option<Style>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I named this secondary row because I thought it could be used in more places than just the help table, but let me know if it should just be for the help table. |
||
} | ||
|
||
#[derive(Default, Clone, Debug, Deserialize)] | ||
|
@@ -102,6 +106,7 @@ pub enum StyleColor { | |
BrightCyan, | ||
BrightBlue, | ||
BrightYellow, | ||
DarkGray, | ||
Rgb { r: u8, g: u8, b: u8 }, | ||
} | ||
|
||
|
@@ -284,6 +289,12 @@ impl Theme { | |
Some(s) => s.style(&self.palette), | ||
} | ||
} | ||
pub fn secondary_row(&self) -> tui::style::Style { | ||
match &self.component_style.secondary_row { | ||
None => Style::default().bg(StyleColor::DarkGray).style(&self.palette), | ||
Some(s) => s.style(&self.palette), | ||
} | ||
} | ||
} | ||
|
||
impl Style { | ||
|
@@ -379,6 +390,7 @@ impl StyleColor { | |
Self::BrightCyan => palette.bright_cyan.color, | ||
Self::BrightBlue => palette.bright_blue.color, | ||
Self::BrightYellow => palette.bright_yellow.color, | ||
Self::DarkGray => style::Color::DarkGray, | ||
Self::Rgb { r, g, b } => style::Color::Rgb(r, g, b), | ||
} | ||
} | ||
|
@@ -463,6 +475,9 @@ impl Color { | |
pub fn bright_white() -> Self { | ||
style::Color::White.into() | ||
} | ||
pub fn dark_gray() -> Self { | ||
style::Color::DarkGray.into() | ||
} | ||
} | ||
|
||
impl From<&str> for Color { | ||
|
@@ -519,6 +534,7 @@ impl Default for Palette { | |
bright_magenta: Color::bright_magenta(), | ||
bright_cyan: Color::bright_cyan(), | ||
bright_white: Color::bright_white(), | ||
dark_gray: Color::dark_gray(), | ||
} | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added support for dark gray coloring, but is there a better way to add support for coloring modifications? Dark and Bright colors seem to have some repetition. And should other dark colors be added as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No you shouldn't add new field to the palette, it represents the basic 16-color palette with additional fields for background and foreground.