This PR is the first step in our plan for an improved way to define a stylesheet structure.
Changes in this PR add the ability to define nested pseudo-elements in a single stylesheet and focus on new syntax for defining classes, pseudo-elements, and pseudo-states. The new syntax allows to define deep nested pseudo-elements in the same stylesheet and currently enforce limits that exist in stylable (will be loosed in the future):
classes with extend + global mapping that doesn't effect the type
@st .x :is(.y) => :global(.y)
pseudo-element with mapping (no extend)
@st ::x => .y
More information on this effort can be found in the proposal.
Changes
Refactor parts handling
Up until now pseudo-elements were registered directly by css-class/ st-custom-selector features.
This PR add a higher level feature st-structure to handle the previous auto parts mode (now called legacy-flat mode) and the new structure mode.
st-structure checks the mode on analyze start and register parts according to mode
legacy-flat: set parts on .root class (from analyzed pseudo-elements and classes)
structure: analyze @st ::part definitions and register to the parent class or pseudo-element(nested pseudo-element is a new feature)
New @st definition
syntax:@st .class
register top level @st .class to class-symbol[-st]
[x] error on non class param (remove in v3)
[x] error on definition not at top level
[x] collect => selector mapping (allow only global mapping for now)
This PR is the first step in our plan for an improved way to define a stylesheet structure.
Changes in this PR add the ability to define nested
pseudo-elements
in a single stylesheet and focus on new syntax for definingclasses
,pseudo-elements
, andpseudo-states
. The new syntax allows to define deep nestedpseudo-elements
in the same stylesheet and currently enforce limits that exist in stylable (will be loosed in the future):@st .x :is(.y) => :global(.y)
@st ::x => .y
More information on this effort can be found in the proposal.
Changes
Refactor parts handling
Up until now
pseudo-elements
were registered directly bycss-class
/st-custom-selector
features. This PR add a higher level featurest-structure
to handle the previous auto parts mode (now called legacy-flat mode) and the new structure mode.st-structure
checks the mode on analyze start and register parts according to mode.root
class (from analyzedpseudo-elements
andclasses
)@st ::part
definitions and register to the parentclass
orpseudo-element
(nested pseudo-element is a new feature)New
@st
definitionsyntax:
@st .class
@st .class
toclass-symbol[-st]
=>
selector mapping (allow only global mapping for now)@st .class :is(<class-selector>)
class-symbol[-st-extends]
- allow a single class extension@st
is usedst-part
ignores legacy parts (registered from@custom-selector
and standalone css-class)@st
statement-st-extends/-st-states/-st-global
(on class defined with@st .c<class>
Nested pseudo-state
syntax:
@st :state;
class-symbol[-st-states]
@st :state
).class:state::part
\.class::part:state
Nested pseudo-element
syntax:
@st ::part => mapped-selector
PartSymbol
&
) in mapping (similar to.root.x
in@custom-selector
)@st-override
in v2):is()
or&is()
@st .class
or@st ::pseudo-element
).class::partA::partB
Technical debts
@st .x
class as root? maybe provide a way to opt-in/out?@st ::part => [mapped-selector]
css-class->st-symbol
redeclare api to handle top level class in structure mode (error on declare)@st
definition@st
completion@st .
/@st .<known-undefined-class>
@st .class :is(.base)
@st .class => :global(<selector>)
@st ::part => <selector>;
@st :<state-def>;