cssthis-parse
Is a way to write component-oriented styles, transform your style into a template string for creating functions.
This is done by defragmenting the css using postcss
Cssthis, now also accepts :host, as alias for :this.
Entry
Departure
$
Why :this ?
:this is not a reserved word of the css language, it is not like :host, :root or :scope, these have a neutral definition for the css, and The goal of :this is not to clash with the evolution of language.
Instance
;; let plugins = ; ` :this{ width : 200px; height : 200px; }`
:this
:this allows you to point to the root class of the context, by using the variable prop
, for :this the root class will be defined by prop.id
.
Example 1
If :this is used as a function, it will create a list of selectors based on the given arguments
/*----input----*/)/*----output----*/
Example 2
the following example shows how :this can receive more than one argument regardless of its type
/*----input----*/)/*----output----*/,,
Example 3
You can also make :this act only if it is accompanied by the given class as an argument
/*----input----*/)/*----output----*/
example 4
You can also make :this act only when accompanied by one or more attributes
/*----input----*/)/*----output----*/[
Example 5
searches by attribute and class also work without the need to use parentheses
/*----input----*//*----output----*/[
Example 6
One of the advantages of using parentheses is that the selection by attribute is iterated until they are all completed
/*----input----*/)/*----output----*/
: this and the context
default :this points only to the root of the context, but it must be understood that the whole context is governed by :this, so that you generate styles outside of :this continue belonging to the context.
Example 1
The following example shows the effect that :this has on the button selector
/*----input----*//*----output----*/
Example 2
in the following example it is taught that it has the same effect within the alrule @media, :this will always put its context first.
/*----input----*/{}/*----output----*/{}
Example 3
when working with keyframes again :this prefixes its context, adding the variable to each animation name only within the context.
/*----input----*/@ 100%}/*----output----*/-@- 100%}
:global
using :global you can avoid using the context on the selector, it is useful to generate global classes
/*----input----*//*----output----*/
Using global button has been defined as a global rule, escaping the context of :this
this in properties
You can also use this to use properties within the argument prop
/*----input----*//*----output----*/;}