#[repr(C)]pub struct CssMockEnvironment {
pub theme: OptionThemeCondition,
pub language: OptionString,
pub os_version: OptionOsVersion,
pub os: OptionOsCondition,
pub desktop_env: OptionLinuxDesktopEnv,
pub viewport_width: OptionF32,
pub viewport_height: OptionF32,
pub prefers_reduced_motion: OptionBool,
pub prefers_high_contrast: OptionBool,
}Expand description
Mock environment for CSS evaluation.
Allows overriding auto-detected system properties for testing and development.
Any field set to None will use the auto-detected value.
Any field set to Some(...) will override the auto-detected value.
§Example
use azul_css::dynamic_selector::{
OsCondition, ThemeCondition, OsVersion,
OptionOsCondition, OptionThemeCondition, OptionOsVersion,
};
// Mock a Linux dark theme environment on any platform
let mock = CssMockEnvironment {
os: OptionOsCondition::Some(OsCondition::Linux),
theme: OptionThemeCondition::Some(ThemeCondition::Dark),
..Default::default()
};
// Mock Windows XP for retro testing
let mock = CssMockEnvironment {
os: OptionOsCondition::Some(OsCondition::Windows),
os_version: OptionOsVersion::Some(OsVersion::WIN_XP),
..Default::default()
};Fields§
§theme: OptionThemeConditionOverride the current theme (light/dark)
language: OptionStringOverride the current language (BCP 47 tag, e.g., “de-DE”, “en-US”)
os_version: OptionOsVersionOverride the detected OS version
os: OptionOsConditionOverride the detected operating system
desktop_env: OptionLinuxDesktopEnvOverride the Linux desktop environment (only applies when os = Linux)
viewport_width: OptionF32Override viewport dimensions (for @media queries) Only use for testing - normally set by window size
viewport_height: OptionF32§prefers_reduced_motion: OptionBoolOverride the reduced motion preference
prefers_high_contrast: OptionBoolOverride the high contrast preference
Implementations§
Source§impl CssMockEnvironment
impl CssMockEnvironment
Sourcepub fn dark_theme() -> Self
pub fn dark_theme() -> Self
Create a mock for dark theme
Sourcepub fn light_theme() -> Self
pub fn light_theme() -> Self
Create a mock for light theme
Sourcepub fn apply_to(&self, ctx: &mut DynamicSelectorContext)
pub fn apply_to(&self, ctx: &mut DynamicSelectorContext)
Apply this mock to a DynamicSelectorContext
Trait Implementations§
Source§impl Clone for CssMockEnvironment
impl Clone for CssMockEnvironment
Source§fn clone(&self) -> CssMockEnvironment
fn clone(&self) -> CssMockEnvironment
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more