pub struct CssClass { /* private fields */ }Expand description
Represents a CSS class with a name, its style declarations, and optional pseudo rules.
Created by the class! macro and used in html! via the class: attribute.
When the renderer encounters a CssClass, it injects the styles into the
DOM’s <style> element on first use and applies the class name to the element.
Implementations§
Source§impl CssClass
Implementation of CssClass construction and style injection.
impl CssClass
Implementation of CssClass construction and style injection.
Sourcepub fn new_with_rules(
name: String,
style: String,
pseudo_rules: Vec<PseudoRule>,
media_rules: Vec<MediaRule>,
) -> Self
pub fn new_with_rules( name: String, style: String, pseudo_rules: Vec<PseudoRule>, media_rules: Vec<MediaRule>, ) -> Self
Creates a new CSS class with the given name, style declarations, and pseudo rules.
Automatically injects the base styles, pseudo-class/pseudo-element rules, and media query rules into the DOM upon creation.
§Arguments
String- The class name.String- The CSS style declarations.Vec<PseudoRule>- The pseudo-class and pseudo-element rules.Vec<MediaRule>- The media query rules.
§Returns
Self- A new CSS class with injected styles and pseudo rules.
Sourcepub fn parse_pseudo_rules(input: &str) -> Vec<PseudoRule>
pub fn parse_pseudo_rules(input: &str) -> Vec<PseudoRule>
Parses pseudo-class/pseudo-element rules from a compact serialization string.
The serialization format is: :selector { key: value; key: value; }:another { ... }
This is used by the class! macro for fully static class definitions
where pseudo rules can be computed at compile time.
§Arguments
&str- The serialized pseudo rules string.
§Returns
Vec<PseudoRule>- The parsed pseudo rules.
Sourcepub fn parse_media_rules(input: &str) -> Vec<MediaRule>
pub fn parse_media_rules(input: &str) -> Vec<MediaRule>
Parses media query rules from a compact serialization string.
The serialization format is: @media query { key: value; key: value; }@media query2 { ... }
This is used by the class! macro for fully static class definitions
where media rules can be computed at compile time.
§Arguments
&str- The serialized media rules string.
§Returns
Vec<MediaRule>- The parsed media rules.
Sourcepub fn inject_style(&self)
pub fn inject_style(&self)
Injects this class’s styles into the DOM if not already present.
Creates a <style> element with id euv-css-injected on first call,
then appends the class rule, pseudo-class rules, and media rules.
Subsequent calls for the same class name are no-ops. On first creation,
also injects global CSS keyframes required by built-in animations.
§Panics
Panics if window() or document() is unavailable on the current platform.
Source§impl CssClass
impl CssClass
pub fn get_name(&self) -> &String
pub fn set_name(&mut self, val: String) -> &mut Self
pub fn get_mut_name(&mut self) -> &mut String
pub fn get_style(&self) -> &String
pub fn set_style(&mut self, val: String) -> &mut Self
pub fn get_mut_style(&mut self) -> &mut String
pub fn get_pseudo_rules(&self) -> &Vec<PseudoRule>
pub fn set_pseudo_rules(&mut self, val: Vec<PseudoRule>) -> &mut Self
pub fn get_mut_pseudo_rules(&mut self) -> &mut Vec<PseudoRule>
pub fn get_media_rules(&self) -> &Vec<MediaRule>
pub fn set_media_rules(&mut self, val: Vec<MediaRule>) -> &mut Self
pub fn get_mut_media_rules(&mut self) -> &mut Vec<MediaRule>
Trait Implementations§
Source§impl Display for CssClass
Displays the CSS class name.
impl Display for CssClass
Displays the CSS class name.
This enables format!("{}", css_class) to produce the class name string,
which is required for reactive if conditions in class: attributes.
Source§impl IntoReactiveString for &'static CssClass
Converts a reference to a CssClass into its class name for reactive string storage.
impl IntoReactiveString for &'static CssClass
Converts a reference to a CssClass into its class name for reactive string storage.
Source§fn into_reactive_string(self) -> String
fn into_reactive_string(self) -> String
Source§impl IntoReactiveString for CssClass
Converts a CssClass into its class name for reactive string storage.
impl IntoReactiveString for CssClass
Converts a CssClass into its class name for reactive string storage.
Source§fn into_reactive_string(self) -> String
fn into_reactive_string(self) -> String
Source§impl IntoReactiveValue for &'static CssClass
Converts a reference to a CSS class into an attribute value by cloning.
impl IntoReactiveValue for &'static CssClass
Converts a reference to a CSS class into an attribute value by cloning.
Source§fn into_reactive_value(self) -> AttributeValue
fn into_reactive_value(self) -> AttributeValue
Converts this CSS class reference into an AttributeValue::Css by cloning.
§Returns
AttributeValue- A CSS class attribute value.
Source§impl IntoReactiveValue for CssClass
Converts a CSS class reference into an attribute value.
impl IntoReactiveValue for CssClass
Converts a CSS class reference into an attribute value.
Source§fn into_reactive_value(self) -> AttributeValue
fn into_reactive_value(self) -> AttributeValue
Converts this CSS class into an AttributeValue::Css.
§Returns
AttributeValue- A CSS class attribute value.