From 04b9dc4e2de4d36c2de7d537bb71694278bb79f0 Mon Sep 17 00:00:00 2001 From: Var Bhat Date: Fri, 22 Dec 2023 02:10:53 +0530 Subject: Add Dracula, Nord, Solarized and Grubvox variants to `Theme` --- style/src/theme/palette.rs | 86 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) (limited to 'style/src/theme/palette.rs') diff --git a/style/src/theme/palette.rs b/style/src/theme/palette.rs index 76977a29..65a39ce7 100644 --- a/style/src/theme/palette.rs +++ b/style/src/theme/palette.rs @@ -1,5 +1,5 @@ //! Define the colors of a theme. -use iced_core::Color; +use iced_core::{color, Color}; use once_cell::sync::Lazy; use palette::color_difference::Wcag21RelativeContrast; @@ -67,6 +67,66 @@ impl Palette { 0x3F as f32 / 255.0, ), }; + + /// The built-in dracula variant of a [`Palette`]. + /// theme source: https://draculatheme.com + pub const DRACULA: Self = Self { + background: color!(0x282A36), // BACKGROUND + text: color!(0xf8f8f2), // FOREGROUND + primary: color!(0xbd93f9), // PURPLE + success: color!(0x50fa7b), // GREEN + danger: color!(0xff5555), // RED + }; + + /// The built-in nord variant of a [`Palette`]. + /// theme source: https://www.nordtheme.com/docs/colors-and-palettes + pub const NORD: Self = Self { + background: color!(0x2e3440), // nord0 + text: color!(0xeceff4), // nord6 + primary: color!(0x8fbcbb), // nord7 + success: color!(0xa3be8c), // nord14 + danger: color!(0xbf616a), // nord11 + }; + + /// The built-in solarized light variant of a [`Palette`]. + /// light variant of https://ethanschoonover.com/solarized + pub const SOLARIZED_LIGHT: Self = Self { + background: color!(0xfdf6e3), // base3 + text: color!(0x657b83), // base00 + primary: color!(0x2aa198), // cyan + success: color!(0x859900), // green + danger: color!(0xdc322f), // red + }; + + /// The built-in solarized dark variant of a [`Palette`]. + /// dark variant of https://ethanschoonover.com/solarized + pub const SOLARIZED_DARK: Self = Self { + background: color!(0x002b36), // base03 + text: color!(0x839496), // base0 + primary: color!(0x2aa198), // cyan + success: color!(0x859900), // green + danger: color!(0xdc322f), // red + }; + + /// The built-in gruvbox light variant of a [`Palette`]. + /// light variant of https://github.com/morhetz/gruvbox + pub const GRUVBOX_LIGHT: Self = Self { + background: color!(0xfbf1c7), // light BG_0 + text: color!(0x282828), // light FG0_29 + primary: color!(0x458588), // light BLUE_4 + success: color!(0x98971a), // light GREEN_2 + danger: color!(0xcc241d), // light RED_1 + }; + + /// The built-in gruvbox dark variant of a [`Palette`]. + /// dark variant of https://github.com/morhetz/gruvbox + pub const GRUVBOX_DARK: Self = Self { + background: color!(0x282828), // dark BG_0 + text: color!(0xfbf1c7), // dark FG0_29 + primary: color!(0x458588), // dark BLUE_4 + success: color!(0x98971a), // dark GREEN_2 + danger: color!(0xcc241d), // dark RED_1 + }; } /// An extended set of colors generated from a [`Palette`]. @@ -94,6 +154,30 @@ pub static EXTENDED_LIGHT: Lazy = pub static EXTENDED_DARK: Lazy = Lazy::new(|| Extended::generate(Palette::DARK)); +/// The built-in dracula variant of an [`Extended`] palette. +pub static EXTENDED_DRACULA: Lazy = + Lazy::new(|| Extended::generate(Palette::DRACULA)); + +/// The built-in nord variant of an [`Extended`] palette. +pub static EXTENDED_NORD: Lazy = + Lazy::new(|| Extended::generate(Palette::NORD)); + +/// The built-in solarized light variant of an [`Extended`] palette. +pub static EXTENDED_SOLARIZED_LIGHT: Lazy = + Lazy::new(|| Extended::generate(Palette::SOLARIZED_LIGHT)); + +/// The built-in solarized dark variant of an [`Extended`] palette. +pub static EXTENDED_SOLARIZED_DARK: Lazy = + Lazy::new(|| Extended::generate(Palette::SOLARIZED_DARK)); + +/// The built-in gruvbox light variant of an [`Extended`] palette. +pub static EXTENDED_GRUVBOX_LIGHT: Lazy = + Lazy::new(|| Extended::generate(Palette::GRUVBOX_LIGHT)); + +/// The built-in gruvbox dark variant of an [`Extended`] palette. +pub static EXTENDED_GRUVBOX_DARK: Lazy = + Lazy::new(|| Extended::generate(Palette::GRUVBOX_DARK)); + impl Extended { /// Generates an [`Extended`] palette from a simple [`Palette`]. pub fn generate(palette: Palette) -> Self { -- cgit From 5770efe06dc552409daf586590d4f477206c732b Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 3 Feb 2024 18:41:06 +0100 Subject: Capitalize theme names in `style::theme::palette` --- style/src/theme/palette.rs | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'style/src/theme/palette.rs') diff --git a/style/src/theme/palette.rs b/style/src/theme/palette.rs index 65a39ce7..50846d43 100644 --- a/style/src/theme/palette.rs +++ b/style/src/theme/palette.rs @@ -68,8 +68,9 @@ impl Palette { ), }; - /// The built-in dracula variant of a [`Palette`]. - /// theme source: https://draculatheme.com + /// The built-in Dracula variant of a [`Palette`]. + /// + /// Source: https://draculatheme.com pub const DRACULA: Self = Self { background: color!(0x282A36), // BACKGROUND text: color!(0xf8f8f2), // FOREGROUND @@ -78,8 +79,9 @@ impl Palette { danger: color!(0xff5555), // RED }; - /// The built-in nord variant of a [`Palette`]. - /// theme source: https://www.nordtheme.com/docs/colors-and-palettes + /// The built-in Nord variant of a [`Palette`]. + /// + /// Source: https://www.nordtheme.com/docs/colors-and-palettes pub const NORD: Self = Self { background: color!(0x2e3440), // nord0 text: color!(0xeceff4), // nord6 @@ -88,8 +90,9 @@ impl Palette { danger: color!(0xbf616a), // nord11 }; - /// The built-in solarized light variant of a [`Palette`]. - /// light variant of https://ethanschoonover.com/solarized + /// The built-in Solarized Light variant of a [`Palette`]. + /// + /// Source: https://ethanschoonover.com/solarized pub const SOLARIZED_LIGHT: Self = Self { background: color!(0xfdf6e3), // base3 text: color!(0x657b83), // base00 @@ -98,8 +101,9 @@ impl Palette { danger: color!(0xdc322f), // red }; - /// The built-in solarized dark variant of a [`Palette`]. - /// dark variant of https://ethanschoonover.com/solarized + /// The built-in Solarized Dark variant of a [`Palette`]. + /// + /// Source: https://ethanschoonover.com/solarized pub const SOLARIZED_DARK: Self = Self { background: color!(0x002b36), // base03 text: color!(0x839496), // base0 @@ -108,8 +112,9 @@ impl Palette { danger: color!(0xdc322f), // red }; - /// The built-in gruvbox light variant of a [`Palette`]. - /// light variant of https://github.com/morhetz/gruvbox + /// The built-in Gruvbox Light variant of a [`Palette`]. + /// + /// Source: https://github.com/morhetz/gruvbox pub const GRUVBOX_LIGHT: Self = Self { background: color!(0xfbf1c7), // light BG_0 text: color!(0x282828), // light FG0_29 @@ -118,8 +123,9 @@ impl Palette { danger: color!(0xcc241d), // light RED_1 }; - /// The built-in gruvbox dark variant of a [`Palette`]. - /// dark variant of https://github.com/morhetz/gruvbox + /// The built-in Gruvbox Dark variant of a [`Palette`]. + /// + /// Source: https://github.com/morhetz/gruvbox pub const GRUVBOX_DARK: Self = Self { background: color!(0x282828), // dark BG_0 text: color!(0xfbf1c7), // dark FG0_29 @@ -154,27 +160,27 @@ pub static EXTENDED_LIGHT: Lazy = pub static EXTENDED_DARK: Lazy = Lazy::new(|| Extended::generate(Palette::DARK)); -/// The built-in dracula variant of an [`Extended`] palette. +/// The built-in Dracula variant of an [`Extended`] palette. pub static EXTENDED_DRACULA: Lazy = Lazy::new(|| Extended::generate(Palette::DRACULA)); -/// The built-in nord variant of an [`Extended`] palette. +/// The built-in Nord variant of an [`Extended`] palette. pub static EXTENDED_NORD: Lazy = Lazy::new(|| Extended::generate(Palette::NORD)); -/// The built-in solarized light variant of an [`Extended`] palette. +/// The built-in Solarized Light variant of an [`Extended`] palette. pub static EXTENDED_SOLARIZED_LIGHT: Lazy = Lazy::new(|| Extended::generate(Palette::SOLARIZED_LIGHT)); -/// The built-in solarized dark variant of an [`Extended`] palette. +/// The built-in Solarized Dark variant of an [`Extended`] palette. pub static EXTENDED_SOLARIZED_DARK: Lazy = Lazy::new(|| Extended::generate(Palette::SOLARIZED_DARK)); -/// The built-in gruvbox light variant of an [`Extended`] palette. +/// The built-in Gruvbox Light variant of an [`Extended`] palette. pub static EXTENDED_GRUVBOX_LIGHT: Lazy = Lazy::new(|| Extended::generate(Palette::GRUVBOX_LIGHT)); -/// The built-in gruvbox dark variant of an [`Extended`] palette. +/// The built-in Gruvbox Dark variant of an [`Extended`] palette. pub static EXTENDED_GRUVBOX_DARK: Lazy = Lazy::new(|| Extended::generate(Palette::GRUVBOX_DARK)); -- cgit From ed159cb9630b951ccfc705938bb6d9fab1662a5b Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 3 Feb 2024 18:52:48 +0100 Subject: Fix import style in `style::theme::palette` --- style/src/theme/palette.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'style/src/theme/palette.rs') diff --git a/style/src/theme/palette.rs b/style/src/theme/palette.rs index 50846d43..d5a1a5d9 100644 --- a/style/src/theme/palette.rs +++ b/style/src/theme/palette.rs @@ -1,5 +1,5 @@ //! Define the colors of a theme. -use iced_core::{color, Color}; +use crate::core::{color, Color}; use once_cell::sync::Lazy; use palette::color_difference::Wcag21RelativeContrast; -- cgit