pub struct Theme {
pub dark_mode: DarkMode,
pub screens: Screens,
pub containers: Containers,
pub colors: Colors,
pub aria: Aria,
}Expand description
Configuration for the Config::theme field.
It defines some design system specific values like custom colors or screen breakpoints.
§Example
use encre_css::{Config, config::DarkMode};
let mut config = Config::default();
config.theme.dark_mode = DarkMode::new_class("body.dark");
config.theme.colors.add("primary", "#d3198c");
config.theme.screens.add("tablet", "640px");
config.theme.containers.add("medium", "640px");
config.theme.aria.add("current", r#"current="page""#);
let generated = encre_css::generate(
[r#"<div class="bg-primary tablet:block aria-current:text-primary"><button class="bg-white @medium:flex">Click me</button>"#],
&config,
);
assert!(generated.ends_with(r#"
.bg-primary {
background-color: #d3198c;
}
.bg-white {
background-color: #fff;
}
@media (width >= 640px) {
.tablet\:block {
display: block;
}
}
@container (width >= 640px) {
.\@medium\:flex {
display: flex;
}
}
.aria-current\:text-primary[aria-current="page"] {
color: #d3198c;
}"#));§Corresponding TOML configuration
[theme]
dark_mode = { class = "body.dark" }
[theme.colors]
primary = "#d3198c"
[theme.screens]
tablet = "640px"
[theme.containers]
medium = "640px"
[theme.aria]
current = 'current="page"'Fields§
§dark_mode: DarkModeDark mode configuration.
The default value is DarkMode::Media.
screens: ScreensCustom screen breakpoints configuration.
The default value is an empty map.
containers: ContainersCustom container size breakpoints configuration.
The default value is an empty map.
colors: ColorsCustom colors configuration.
The default value is an empty map.
aria: AriaCustom ARIA states.
The default value is an empty map.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Theme
impl<'de> Deserialize<'de> for Theme
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 Theme
impl StructuralPartialEq for Theme
Auto Trait Implementations§
impl Freeze for Theme
impl RefUnwindSafe for Theme
impl Send for Theme
impl Sync for Theme
impl Unpin for Theme
impl UnwindSafe for Theme
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