use crate::baseline::{default_first_paint_theme, theme_scoped_vars_css, ROOT_THEME_SCOPE_ID};
use crate::options::Density;
use crate::Theme;
pub fn is_baseline_theme(theme: &Theme) -> bool {
if theme.mode != crate::ThemeMode::Light {
return false;
}
let options = &theme.options;
if options.brand.is_some() || options.density != Density::Default {
return false;
}
if (options.elevation.multiplier - 1.0).abs() > f32::EPSILON {
return false;
}
let baseline = default_first_paint_theme();
theme_scoped_vars_css(ROOT_THEME_SCOPE_ID, theme)
== theme_scoped_vars_css(ROOT_THEME_SCOPE_ID, &baseline)
}
#[cfg(feature = "hydrate")]
pub fn baseline_active_in_document() -> bool {
use leptos::prelude::document;
document()
.query_selector(&format!(
r#"[data-orbital-theme-baseline="{ROOT_THEME_SCOPE_ID}"]"#
))
.ok()
.flatten()
.is_some()
}
#[cfg(not(feature = "hydrate"))]
pub fn baseline_active_in_document() -> bool {
false
}
pub fn should_skip_root_baseline_injection(scope_id: &str, theme: &Theme) -> bool {
scope_id == ROOT_THEME_SCOPE_ID && is_baseline_theme(theme)
}