pub struct Sheet { /* private fields */ }Expand description
The rules for a set of styles, each declaration written once.
A rule outside any cascade layer beats a layered one, so a plain stylesheet the page also loads overrides these classes.
use hypersig_style::value::{Color, px};
use hypersig_style::{PseudoClass, Sheet, Style};
let mut sheet = Sheet::new();
sheet.add(&Style::new().padding(px(8)).color(Color::CRIMSON));
sheet.add(&Style::new().on(PseudoClass::Hover, Style::new().color(Color::RED)));
let css: Vec<String> = sheet.buckets().map(|b| b.css().to_owned()).collect();
assert_eq!(
css,
[
"@layer hypersig-tokens,hypersig-base,hypersig-atoms,hypersig-toggled;\
@layer hypersig-atoms.k-----00{.color_crimson{color:crimson}.padding_8px{padding:8px}}",
"@layer hypersig-tokens,hypersig-base,hypersig-atoms,hypersig-toggled;\
@layer hypersig-atoms.k----4019-00{.hover\\:color_red:hover{color:red}}",
]
);Implementations§
Source§impl Sheet
impl Sheet
Sourcepub fn add(&mut self, style: &Style)
pub fn add(&mut self, style: &Style)
Adds the rules for the classes Style::class_names lists.
Sourcepub fn add_toggled(&mut self, style: &Style)
pub fn add_toggled(&mut self, style: &Style)
Adds the rules for the classes Style::toggled_class_names lists.
Sourcepub fn buckets(&self) -> impl Iterator<Item = Bucket> + '_
pub fn buckets(&self) -> impl Iterator<Item = Bucket> + '_
The rules grouped into buckets, in the order they apply, then one
bucket per @keyframes rule.
Sourcepub fn to_css(&self) -> String
pub fn to_css(&self) -> String
The stylesheet Sheet::write_css writes.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sheet
impl RefUnwindSafe for Sheet
impl Send for Sheet
impl Sync for Sheet
impl Unpin for Sheet
impl UnsafeUnpin for Sheet
impl UnwindSafe for Sheet
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