From 936293bb8f8d12df58f9f4e6ce865b87e08afd83 Mon Sep 17 00:00:00 2001 From: pml68 Date: Thu, 15 May 2025 23:58:28 +0200 Subject: feat(material_theme): add `new_const` method to `Theme` --- crates/material_theme/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'crates/material_theme/src') diff --git a/crates/material_theme/src/lib.rs b/crates/material_theme/src/lib.rs index e59e1e9..6853931 100644 --- a/crates/material_theme/src/lib.rs +++ b/crates/material_theme/src/lib.rs @@ -69,6 +69,17 @@ impl Theme { }) } + pub const fn new_const( + name: &'static str, + colorscheme: ColorScheme, + ) -> Self { + Self::Custom(Custom { + name: Cow::Borrowed(name), + is_dark: lightness(colorscheme.surface.color) <= 0.5, + colorscheme, + }) + } + pub fn name(&self) -> Cow<'static, str> { match self { Self::Dark => "Dark".into(), -- cgit v1.2.3