Expand description
The at-rules besides @media, @supports and @layer: @keyframes,
@counter-style and @property parsed into what they say, and the
preludes of @container, @scope and @import, which the cascade
evaluates. Each is written back as CSSOM writes it.
use parsec_css::rules::{CounterStyle, PropertyRule};
use parsec_css::Rule;
let css = "@property --gap { syntax: '<length>'; inherits: false; initial-value: 4px }
@counter-style thumbs { system: cyclic; symbols: '👍'; suffix: ' ' }";
let sheet = parsec_css::parse_stylesheet_deep(css);
let Rule::At(p) = &sheet.rules[0] else { unreachable!() };
let p = PropertyRule::parse(p).unwrap();
assert_eq!((p.syntax.as_str(), p.inherits, p.initial_value.as_deref()), ("<length>", false, Some("4px")));
let Rule::At(c) = &sheet.rules[1] else { unreachable!() };
let c = CounterStyle::parse(c).unwrap();
assert_eq!(c.get("system"), Some("cyclic"));Structs§
- Axes
- What a container query asks of its container: its width, its height, or both.
- Container
Query - One
@containerquery, CSS Conditional 5 §6: an optional container name and a condition on the container’s size or its custom properties’ values. - Counter
Style @counter-style, CSS Counter Styles 3 §3: a name and its valid descriptors, each written back in its canonical form, in the order CSSOM writes them. What a counter is for a number isn’t worked out.- Import
@import, CSS Cascade 5 §2: the URL as written, the layer it puts the sheet in, and the conditions on it.- Keyframe
- One keyframe: where it is in the animation, and its declarations,
!importantones left out as §3.3 says. - Keyframes
@keyframes, CSS Animations 1 §3: a name and its keyframes, in order.- Property
Rule @property, CSS Properties and Values API 1 §3: a custom property registered with a syntax, whether it inherits, and an initial value. A descriptor that’s missing or invalid takes its default,*andtrue, as CSSOM has it; the rule registers the property only if its syntax is*or it has an initial value (PropertyRule::registers).- Scope
Bounds @scope’s prelude, CSS Cascade 6 §3.5: the selectors for the scoping roots and limits, as written;Nonefor a root is the parent of the<style>the rule is in, or the rule’s parent style rule.- Syntax
- A registered property’s syntax:
Nonefor the universal*, or the grammar it stands for.
Enums§
- Keyframe
Offset - A keyframe selector:
fromis 0%,to100%, and Scroll Animations 1 adds a range name before a percentage,entry 50%. - Style
Query style()’s query, §6.2: a custom property’s value, that it has one, or a range of values compared, and those joined withnot,andandor.