Stylus is an awesome CSS pre-processor, which provides much more concise syntax and more powerful feature than its competitors, such as LESS or SCSS.
But now, with more and more features added into Stylus
, it seems its syntax become over-weighted. Pitfall come up.
I wish to declare an array of values for box-shadow
property. And I can reference them with index:
|
|
And expect it generates
|
|
But I found there is not such thing called Array
in Stylus
!!!!
There is only Hash
, and Hash doesn’t accept number as key!
So finally, I come up something like this:
|
|
In this piece of code, there are a bunch of pitfalls:
- Hash doesn’t accept number as key. So
1: 0 2px 10px 0 rgba(0, 0, 0, 0.16)
cause compile error. '1' != 1
, sodrop-shadows[1]
returnsnull
- There is no type conversion function in
Stylus
, use the same trick asJavaScript
.''+n
convertn
intostring
.
Just found Stylus
provides something called List
, which is pretty much similar to what array in other languages, except the syntax.
|
|
So no brackets or parentesis needed.