I'm trying to make a mixin that generates some styles with variables, and I would like to concatenate two variables and I can't make it work. Here is an example:
centerSprite($icon)
margin-top -(($ico_+$icon+_height) / 2)
margin-left -(($ico_+$icon+_width) / 2)
I have a variable with the height and the width of an icon and I would like to to put the name in the arguments of the mixin to get that variable and make the operation...
Thanks in advance!
A good man on Github explained to me the lookup
built-in function in Stylus and this is what I was looking for:
$ico_test_width ?= 20px
$ico_test_height ?= 15px
centerSprite($icon)
margin-top : -(lookup('$ico_' + $icon + '_height') / 2)
margin-left: -(lookup('$ico_' + $icon + '_width') / 2)
body
centerSprite('test')