Add stencils for styling #2412
NicholasBoll
started this conversation in
Ideas
Replies: 1 comment 3 replies
-
Link Iis 404. How doesn't compound resolution work, given
I would expect the background to be orange here (that doesn't work in your sandbox, but I think that is the intention). Is it always exact? e.g. would
produce a green background since it matches 2/3 and there is no full match? I assume not but wanted to double check. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There has been a lot of interest in the new styling options introduced in v10. See #2265
The
createStyles
andcreateModifiers
utility functions aren't obvious from the beginning. The concept of a Stencil is proposed. The concept is similar to the Vanilla Extract Recipes. A stencil would help developers think in terms of base styles and modifiers and the stencil would ensure each are created in the proper order to make sure style merging works as expected.The API would look similar to this:
Stencils also introduce the concept of a "compound modifier". A compound modifier is an intersection of two or more modifiers. A overriding style can be defined at the intersection of two or more modifiers. An example we have in Canvas Kit of a compound modifier is
size
andiconPosition
. Since icons have their own padding, less padding is needed before or after the icon and since padding is different depending on thesize
, the intersection ofsize
andiconPosition
determines padding overrides.A stencil return as valid
className
. More technically it return a space delimited list of CSS class names. The result of the example would have 4 class names:It will look something like
"css-a1 css-a2 css-a3 css-a4"
A PoC can be found as a Stencil codesandbox
Beta Was this translation helpful? Give feedback.
All reactions