pub enum DarkMode {
Class(Cow<'static, str>),
Media,
}Expand description
Configuration for the Theme::dark_mode field.
It defines how the dark: variant should behave.
The default value is DarkMode::Media which enables the automatic detection of the theme based
on user preference.
Variants§
Class(Cow<'static, str>)
The dark: variant will modify the class of the selector. You’ll then need to toggle this
class to enable the dark theme.
§Example
use encre_css::{Config, config::DarkMode};
let mut config = Config::default();
config.theme.dark_mode = DarkMode::new_class("body.dark");
let generated = encre_css::generate(
["dark:text-white"],
&config,
);
assert!(generated.ends_with(r#"body.dark .dark\:text-white {
color: #fff;
}"#));Media
The dark: variant will generates a @media (prefers-color-scheme: dark) rule to enable
the dark theme following user preference.
This is the default value.
§Example
use encre_css::{Config, config::DarkMode};
let mut config = Config::default();
config.theme.dark_mode = DarkMode::Media;
let generated = encre_css::generate(
["dark:text-white"],
&config,
);
assert!(generated.ends_with(r#"@media (prefers-color-scheme: dark) {
.dark\:text-white {
color: #fff;
}
}"#));Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for DarkMode
impl<'de> Deserialize<'de> for DarkMode
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for DarkMode
impl StructuralPartialEq for DarkMode
Auto Trait Implementations§
impl Freeze for DarkMode
impl RefUnwindSafe for DarkMode
impl Send for DarkMode
impl Sync for DarkMode
impl Unpin for DarkMode
impl UnwindSafe for DarkMode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more