Repository navigation
Minimal custom themes implementation #330
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
Merged
GyulyVGC
merged 22 commits into
GyulyVGC:v1.2.2
from
joshuamegnauth54:custom_themes_minimal
Aug 7, 2023
Merged
Changes from 10 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
2d00141
Define palette extension structs.
joshuamegnauth54 54b4abf
Draft out skeleton for minimal custom themes.
joshuamegnauth54 3efdceb
Add `Dracula` as an example theme to test.
joshuamegnauth54 5e333e3
Automatically append custom styles to settings.
joshuamegnauth54 2044602
Add gruvbox.
joshuamegnauth54 5722964
Fix deserializing `StyleType::Custom`.
joshuamegnauth54 474aaeb
Merge remote-tracking branch 'upstream/main' into custom_themes_minimal
joshuamegnauth54 e1a1c7f
Add style Solarized light.
joshuamegnauth54 5386d87
improvements to style settings page layout
GyulyVGC dd3f5ac
format files and fix lints
GyulyVGC 85a6596
use StyleType::is_nightly to determine font weights
GyulyVGC b165fcd
fix tests
GyulyVGC 306c46d
Add style Solarized dark.
joshuamegnauth54 d677171
Add Nord and update solarized.
joshuamegnauth54 2a4ca7f
improvements to overall palettes structure and colors
GyulyVGC 09deb57
Add Nord (Day) as a light theme.
joshuamegnauth54 5004407
Add Gruvbox light.
joshuamegnauth54 a344376
fixed highlighted text and minor palettes improvements
GyulyVGC ff0c702
Add a light variation of Dracula.
joshuamegnauth54 32ec19f
fix Dracula Light palette
GyulyVGC 66f1b8d
refactoring
GyulyVGC 0b56a2a
some more refactoring
GyulyVGC 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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 @@ | ||
| mod dracula; | ||
| mod gruvbox; | ||
| mod solarized; | ||
|
|
||
| use std::fmt; | ||
|
|
||
| use iced::Color; | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| use super::palette::Palette; | ||
|
|
||
| /// Custom style with any relevant metadata | ||
| pub struct CustomPalette { | ||
| /// Displayable name of the style (i.e. "Catppuccin (Mocha)") | ||
| name: &'static str, | ||
| /// Color scheme's palette | ||
| palette: Palette, | ||
| /// Extra colors such as the favorites star | ||
| extension: PaletteExtension, | ||
| } | ||
|
|
||
| /// Extension color for themes. | ||
| pub struct PaletteExtension { | ||
| /// Color of favorites star | ||
| pub starred: Color, | ||
| /// Badge/logo alpha | ||
| pub badge_alpha: f32, | ||
| /// Traffic chart color mixing | ||
| pub color_mixing: f64, | ||
| } | ||
|
|
||
| /// Built in extra styles | ||
| #[derive(Clone, Copy, Serialize, Deserialize, Debug, Hash, PartialEq)] | ||
| #[serde(tag = "custom")] | ||
| pub enum ExtraStyles { | ||
| Dracula, | ||
| Gruvbox, | ||
| SolarizedLight, | ||
| } | ||
|
|
||
| impl ExtraStyles { | ||
| /// [`Palette`] of the [`ExtraStyles`] variant | ||
| #[inline] | ||
| pub fn to_palette(self) -> Palette { | ||
| match self { | ||
| ExtraStyles::Dracula => dracula::dracula().palette, | ||
| ExtraStyles::Gruvbox => gruvbox::gruvbox_dark().palette, | ||
| ExtraStyles::SolarizedLight => solarized::solarized_light().palette, | ||
| } | ||
| } | ||
|
|
||
| /// Extension colors for the current [`ExtraStyles`] variant | ||
| #[inline] | ||
| pub fn to_ext(self) -> PaletteExtension { | ||
| match self { | ||
| ExtraStyles::Dracula => dracula::dracula().extension, | ||
| ExtraStyles::Gruvbox => gruvbox::gruvbox_dark().extension, | ||
| ExtraStyles::SolarizedLight => solarized::solarized_light().extension, | ||
| } | ||
| } | ||
|
|
||
| /// Theme is a night/dark style | ||
| #[inline] | ||
| pub const fn is_nightly(self) -> bool { | ||
| match self { | ||
| ExtraStyles::Dracula | ExtraStyles::Gruvbox => true, | ||
| ExtraStyles::SolarizedLight => false, | ||
| } | ||
| } | ||
|
|
||
| /// Slice of all implemented custom styles | ||
| #[inline] | ||
| pub const fn all_styles() -> &'static [Self] { | ||
| &[ | ||
| ExtraStyles::Dracula, | ||
| ExtraStyles::Gruvbox, | ||
| ExtraStyles::SolarizedLight, | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| impl fmt::Display for ExtraStyles { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| match *self { | ||
| ExtraStyles::Dracula => write!(f, "Dracula"), | ||
| ExtraStyles::Gruvbox => write!(f, "Gruvbox (Dark)"), | ||
| ExtraStyles::SolarizedLight => write!(f, "Solarized (Light)"), | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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,28 @@ | ||
| #![allow(clippy::unreadable_literal)] | ||
|
|
||
| //! Dracula theme | ||
| //! <https://draculatheme.com/> | ||
| use iced::color; | ||
|
|
||
| use super::{CustomPalette, Palette, PaletteExtension}; | ||
|
|
||
| pub(super) fn dracula() -> CustomPalette { | ||
| CustomPalette { | ||
| name: "Dracula", | ||
| palette: Palette { | ||
| primary: color!(0x44475a), // Current line | ||
| secondary: color!(0xff79c6), // Pink | ||
| outgoing: color!(0x8be9fd), // Cyan | ||
| buttons: color!(0x6272a4), // Comments | ||
| text_headers: color!(0x44475a), // Current line | ||
| text_body: color!(0xf8f8f2), // Foreground | ||
| round_borders: color!(0xbd93f9), // Purple | ||
|
GyulyVGC marked this conversation as resolved.
Resolved
|
||
| round_containers: color!(0x44475a), // Current line | ||
| }, | ||
| extension: PaletteExtension { | ||
| starred: color!(0xf1fa8c), | ||
| badge_alpha: 0.75, | ||
| color_mixing: 0.3, | ||
| }, | ||
| } | ||
| } | ||
This file contains hidden or 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,29 @@ | ||
| #![allow(clippy::unreadable_literal)] | ||
|
|
||
| //! Gruvbox | ||
| //! <https://github.com/morhetz/gruvbox> | ||
|
|
||
| use iced::color; | ||
|
|
||
| use super::{CustomPalette, Palette, PaletteExtension}; | ||
|
|
||
| pub(super) fn gruvbox_dark() -> CustomPalette { | ||
| CustomPalette { | ||
| name: "Gruvbox (Dark)", | ||
| palette: Palette { | ||
| primary: color!(0x282828), // bg | ||
| secondary: color!(0xfe8019), // orange | ||
| outgoing: color!(0x8ec07c), // aqua | ||
| buttons: color!(0x928374), // gray | ||
| text_headers: color!(0x1d2021), // bg0_h | ||
| text_body: color!(0xebdbb2), // fg | ||
| round_borders: color!(0x98971a), // green | ||
| round_containers: color!(0x504945), // bg2 | ||
| }, | ||
| extension: PaletteExtension { | ||
| starred: color!(0xd79921), | ||
| badge_alpha: 0.75, | ||
| color_mixing: 0.3, | ||
| }, | ||
| } | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.