Answer the question
In order to leave comments, you need to log in
Is it possible to implement something similar in Stylus?
Hello, I started to master Stylus and I had a question. Is it possible somehow to automatically collect all the selectors where there is an sp mixin, for example, into a variable?
$home = 20px 20px 0 0px;
$menu = 12px 12px -222px 0px;
$logo = 120px 120px -122px 0px;
sp($icon)
width $icon[0]
height $icon[1]
background-position $icon[2] $icon[3]
.home
sp($home)
.menu
sp($menu)
.logo
sp($logo)
.home,
.menu,
.logo {
background: ...;
}
.home {
width: 20px;
height: 20px;
background-position: 0px 0px;
}
.menu {
width: 12px;
height: 12px;
background-position: -222px 0px;
}
.logo {
width: 120px;
height: 120px;
background-position: -122px 0px;
}
Answer the question
In order to leave comments, you need to log in
You can use +cache
$home = 20px 20px 0 0px;
$menu = 12px 12px -222px 0px;
$logo = 120px 120px -122px 0px;
sp($icon)
width $icon[0]
height $icon[1]
background-position $icon[2] $icon[3]
+cache('bg')
background-image: url('')
.home
sp($home)
.menu
sp($menu)
.logo
sp($logo)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question