add catppuccin themes

This commit is contained in:
Var Bhat 2024-02-03 23:49:56 +05:30 committed by Héctor Ramón Jiménez
parent 33066bca1a
commit 3513a4ad56
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 86 additions and 0 deletions

View file

@ -48,6 +48,14 @@ pub enum Theme {
GruvboxLight,
/// The built-in Gruvbox Dark variant.
GruvboxDark,
/// The built-in Catppuccin Latte variant.
CatppuccinLatte,
/// The built-in Catppuccin Frappé variant.
CatppuccinFrappe,
/// The built-in Catppuccin Macchiato variant.
CatppuccinMacchiato,
/// The built-in Catppuccin Mocha variant.
CatppuccinMocha,
/// A [`Theme`] that uses a [`Custom`] palette.
Custom(Arc<Custom>),
}
@ -63,6 +71,10 @@ impl Theme {
Self::SolarizedDark,
Self::GruvboxLight,
Self::GruvboxDark,
Self::CatppuccinLatte,
Self::CatppuccinFrappe,
Self::CatppuccinMacchiato,
Self::CatppuccinMocha,
];
/// Creates a new custom [`Theme`] from the given [`Palette`].
@ -91,6 +103,10 @@ impl Theme {
Self::SolarizedDark => Palette::SOLARIZED_DARK,
Self::GruvboxLight => Palette::GRUVBOX_LIGHT,
Self::GruvboxDark => Palette::GRUVBOX_DARK,
Self::CatppuccinLatte => Palette::CATPPUCCIN_LATTE,
Self::CatppuccinFrappe => Palette::CATPPUCCIN_FRAPPE,
Self::CatppuccinMacchiato => Palette::CATPPUCCIN_MACCHIATO,
Self::CatppuccinMocha => Palette::CATPPUCCIN_MOCHA,
Self::Custom(custom) => custom.palette,
}
}
@ -106,6 +122,12 @@ impl Theme {
Self::SolarizedDark => &palette::EXTENDED_SOLARIZED_DARK,
Self::GruvboxLight => &palette::EXTENDED_GRUVBOX_LIGHT,
Self::GruvboxDark => &palette::EXTENDED_GRUVBOX_DARK,
Self::CatppuccinLatte => &palette::EXTENDED_CATPPUCCIN_LATTE,
Self::CatppuccinFrappe => &palette::EXTENDED_CATPPUCCIN_FRAPPE,
Self::CatppuccinMacchiato => {
&palette::EXTENDED_CATPPUCCIN_MACCHIATO
}
Self::CatppuccinMocha => &palette::EXTENDED_CATPPUCCIN_MOCHA,
Self::Custom(custom) => &custom.extended,
}
}
@ -122,6 +144,10 @@ impl fmt::Display for Theme {
Self::SolarizedDark => write!(f, "Solarized Dark"),
Self::GruvboxLight => write!(f, "Gruvbox Light"),
Self::GruvboxDark => write!(f, "Gruvbox Dark"),
Self::CatppuccinLatte => write!(f, "Catppuccin Latte"),
Self::CatppuccinFrappe => write!(f, "Catppuccin Frappé"),
Self::CatppuccinMacchiato => write!(f, "Catppuccin Macchiato"),
Self::CatppuccinMocha => write!(f, "Catppuccin Mocha"),
Self::Custom(custom) => custom.fmt(f),
}
}

View file

@ -133,6 +133,50 @@ impl Palette {
success: color!(0x98971a), // dark GREEN_2
danger: color!(0xcc241d), // dark RED_1
};
/// The built-in Catppuccin Latte variant of a [`Palette`].
///
/// Source: https://github.com/catppuccin/catppuccin
pub const CATPPUCCIN_LATTE: Self = Self {
background: color!(0xeff1f5), // Base
text: color!(0x4c4f69), // Text
primary: color!(0x1e66f5), // Blue
success: color!(0x40a02b), // Green
danger: color!(0xd20f39), // Red
};
/// The built-in Catppuccin Frappé variant of a [`Palette`].
///
/// Source: https://github.com/catppuccin/catppuccin
pub const CATPPUCCIN_FRAPPE: Self = Self {
background: color!(0x303446), // Base
text: color!(0xc6d0f5), // Text
primary: color!(0x8caaee), // Blue
success: color!(0xa6d189), // Green
danger: color!(0xe78284), // Red
};
/// The built-in Catppuccin Macchiato variant of a [`Palette`].
///
/// Source: https://github.com/catppuccin/catppuccin
pub const CATPPUCCIN_MACCHIATO: Self = Self {
background: color!(0x24273a), // Base
text: color!(0xcad3f5), // Text
primary: color!(0x8aadf4), // Blue
success: color!(0xa6da95), // Green
danger: color!(0xed8796), // Red
};
/// The built-in Catppuccin Mocha variant of a [`Palette`].
///
/// Source: https://github.com/catppuccin/catppuccin
pub const CATPPUCCIN_MOCHA: Self = Self {
background: color!(0x1e1e2e), // Base
text: color!(0xcdd6f4), // Text
primary: color!(0x89b4fa), // Blue
success: color!(0xa6e3a1), // Green
danger: color!(0xf38ba8), // Red
};
}
/// An extended set of colors generated from a [`Palette`].
@ -184,6 +228,22 @@ pub static EXTENDED_GRUVBOX_LIGHT: Lazy<Extended> =
pub static EXTENDED_GRUVBOX_DARK: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::GRUVBOX_DARK));
/// The built-in Catppuccin Latte variant of an [`Extended`] palette.
pub static EXTENDED_CATPPUCCIN_LATTE: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::CATPPUCCIN_LATTE));
/// The built-in Catppuccin Frappé variant of an [`Extended`] palette.
pub static EXTENDED_CATPPUCCIN_FRAPPE: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::CATPPUCCIN_FRAPPE));
/// The built-in Catppuccin Macchiato variant of an [`Extended`] palette.
pub static EXTENDED_CATPPUCCIN_MACCHIATO: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::CATPPUCCIN_MACCHIATO));
/// The built-in Catppuccin Mocha variant of an [`Extended`] palette.
pub static EXTENDED_CATPPUCCIN_MOCHA: Lazy<Extended> =
Lazy::new(|| Extended::generate(Palette::CATPPUCCIN_MOCHA));
impl Extended {
/// Generates an [`Extended`] palette from a simple [`Palette`].
pub fn generate(palette: Palette) -> Self {