Closed Jarzka closed 3 years ago
Good question. I have wondered similar things in the past.
I'm mainly asking this because I'm planning creating an algorithm which will automatically scope a Garden selector to specific class, i.e. make the original selector valid only inside some element. This is possible to do by simply wrapping the style map in the selector within a vector.
For example:
from: [:.item {:font-weight "normal"}]
to: [:.item [:.my-custom-scope {:font-weight "normal"}]]
.
I'm just curious to know if I can safely do this. It should be ok if maps are only treated as CSS properties and there should not be multiple maps in the same vector.
I think having multiple style maps in a single Garden vector is allowed, but usually you want to put them in a different context, like:
[:.outer {:font-weight "normal"}
[:.inner {:font-weight "bold"}])
It does appear that the compiler (at least in the version we're using, "1.3.10"
) allows multiple declerations in a single rule:
render-css
supports many sequential types:
Accounting for this in your programmatic manipulations of garden data seems like a good idea.
Note: I'm mostly just a user of this library, still learning more about the internals myself, so take my advice w/ a grain of salt.
Is this the designed behavior?
Yes.
Are multiple style maps supported like this or what does it mean to have multiple style maps as part of the vector?
It means merge them all into one set of declarations from left to right. This is to both address problems with ordering in large Clojure maps and ordering of declarations in CSS.
Also, does Garden assume that maps are always CSS properties, never part of the selector?
Yes.
Thanks for the answers.
Hi
As I understand the Garden selector syntax, it has the selector part (first N elements which can be strings, keywords or vectors) and the style map should be the last element in every vector.
However, if I have something like this:
it outputs this CSS:
Is this the designed behavior? Are multiple style maps supported like this or what does it mean to have multiple style maps as part of the vector? Also, does Garden assume that maps are always CSS properties, never part of the selector?