You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
.problemcolor: rgb(255255255 / 20%)
color: hsl(0deg0%100% / 20%)
color: hwb(0deg100%0%/20%)
// Use older syntax.solution-1color: rgba(255, 255, 255, .2)
color: hsla(0, 0%, 100%, .2)
// Escape / for colors that don't have older syntax or convert them to rgba().solution-2color: hwb(0deg100%0%\/20%)
// Use unquote(), s() or "%s" % val.solution-3color: s("hwb(0deg 100% 0% / 20%)")
color: "hwb(0deg 100% 0% / 20%)"%0// Use @css{}.solution-4
color:@css{hwb(0deg100%0%/20%)}
You can quickly convert them to older syntax in the stylus editor using the color picker. Click on the switch formats icon (↔) and then again while holding shift.
calc(stylusVars)
You can’t use stylus variables inside calc(). This is intended behavior.
.problembackground: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=)
// Use quotation marks for Data URLs (I recommend to always use them).solution-1background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=")
// Escape semicolon.solution-2background: url(data:image/png\;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=)
.problemgrid-template:
"a a a" 40px
"b c c" 40px
"b c c" 40px / 1fr 1fr 1fr;
// Make it in one line.solution-1grid-template: "a a a"40px"b c c"40px"b c c"40px/1fr1fr1fr// Escape new line.solution-2grid-template: \
"a a a" 40px \
"b c c" 40px \
"b c c" 40px / 1fr 1fr 1fr
// Use @css{}@css {
.solution-3{
grid-template:
"a a a" 40px
"b c c" 40px
"b c c" 40px / 1fr 1fr 1fr;
}
}
// Problemadd(a, b)
{
a + b
}
foo
{
bar1bar2
{
color: #fff
}
}
// Solution (I recommend to always use this indentation style)add(a, b) {
a + b
}
foo {
bar1 bar2 {
color: #fff
}
}
// Solution 2add(a, b)
a + bfoobar1bar2color: #fff
foo==foo// true - Undefined identifiers yield themselves as the valuefoo=="foo"// true - Idents are string-like10px==10%// true - Numbers are equal even if they have different units"bar"=="bar"// truered=="red"// falsered==#f00// truetrue==1// true""+10px ==""+10%// false
foo=f1f2"f3"bar=b1b2, "b3""%s"% foo // f1"%s"% bar // b1 b2"%s %s %s"% foo // f1 f2 "f3""%s %s"% bar // b1 b2 "b3"// To make it act like s(), you need to add another value (it can be null, () or whatever you want)"%s"% (foo ()) // f1 f2 "f3"s("%s", foo) // f1 f2 "f3""%s"% (bar ()) // b1 b2, "b3"s("%s", bar) // b1 b2, "b3""%s %s"% (foo bar) // f1 f2 "f3" b1 b2, "b3"s("%s %s", foo, bar) // f1 f2 "f3" b1 b2, "b3"// s() or unquote()s(""+foo) // f1 f2 f3s(""+bar) // b1 b2 b3s(""+foo+" "+bar) // f1 f2 f3 b1 b2 b3
// Double slash comments don't output/* Multi-line comments output when the 'compress' option is not enabled (It's not enabled in the stylus browser extension) *//*! Multi-line buffered comments output regardless of compression */
body {
color:#fff;
/*color: #000;*/color:/*#0f0*/;
}
Less Preprocessor
If you chose Stylus Preprocessor just because it has the same name as the extension and you only use if statements and variables, then maybe try Less Preprocessor instead. It’s also very powerful and not that buggy.
/* ==UserStyle==@name example.com Less@version 1.0.0@namespace example Less@license WTFPL@preprocessor less@var select fonts "Select" ["Roboto", "Helvetica", "'Comic Sans MS'"]@var color txt "Text" #fff@var color link "Link" #7790ff@var color bg "Background" #000@var checkbox bgImg "Image" 1 @var text bgImgL "Image Link" "'https://coolbackgrounds.io/images/unsplash/samuel-zeller-medium-b832fe04.jpg'"@var number divW "Width" [600, 200, null, 1, 'px']@var range divBr "Border radius" [16, 5, 30, 1, 'px']==/UserStyle== */@-moz-document domain("example.com") {
body {
background-color: @bg;
&when (@bgImg=1) {
background-image: url(@bgImgL);
}
color: @txt;
font-family: @fonts;
}
div {
background-color: lighten(@bg, 5%);
width: @divW;
border-radius: @divBr;
}
a:link, a:visited {
color: @link;
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
You can report stylus preprocessor bugs here: https://github.com/stylus/stylus/issues
Stylus preprocessor Docs: https://stylus-lang.com/docs/
UserCSS Docs: https://github.com/openstyles/stylus/wiki/Writing-UserCSS#stylus
Pretty much all of the bugs below you can fix by using:
@css{}
- https://stylus-lang.com/docs/literal.html#css-literalunquote()
- https://stylus-lang.com/docs/bifs.html#unquote-str-idents()
- https://stylus-lang.com/docs/bifs.html#s-fmt"%s" % val
- https://stylus-lang.com/docs/operators.html#sprintf\
- https://stylus-lang.com/docs/escape.html#char-escapingBugs
rgb(255 255 255 / 20%)
- Colors Module Level 4 Syntaxstylus/stylus#2489
You can quickly convert them to older syntax in the stylus editor using the color picker. Click on the switch formats icon (↔) and then again while holding shift.
calc(stylusVars)
You can’t use stylus variables inside calc(). This is intended behavior.
stylus/stylus#1766 | #1584
url()
- Data URLsstylus/stylus#2597 | stylus/stylus#2347 | stylus/stylus#2117
stylus/stylus#2243
grid-template
stylus/stylus#2306
Because stylus allows to omit colons and semicolons, you can’t split values into separate lines
stylus/stylus#2293
@supports selector()
stylus/stylus#2738
@media
- Media Queries Level 4 Syntaxstylus/stylus#2317 | stylus/stylus#2215 | stylus/stylus#2831
@container
stylus/stylus#2746
min()
max()
css functionsStylus preprocessors min() max() functions override build-in css min() max() functions
stylus/stylus#2584
#decor
- ID selectors similar to hex colors and operatorsIDs that start with: a, b, c, d, e, f (similar to hex color) and end with: or, and, is, isnt, unless, not, null (operators) cause error
stylus/stylus#2140
:is(a, b)
:where(a, b)
:has(a, b)
:not(a, b)
with nestingstylus/stylus#2774
stylus/stylus#2750 | stylus/stylus#2710 | stylus/stylus#2694
[style="color: rgb(0, 0, 0)"]
stylus/stylus#2378 | stylus/stylus#2658
.foo\:bar
stylus/stylus#2805
color-mix()
#1694
{
- opening bracket in a new lineThis indentation style is not fully supported. You can see supported style syntax here.
#1730 | stylus/stylus#2847
Additional Stylus Preprocessor Info
Type of
https://stylus-lang.com/docs/bifs.html#typeof-node
Equality
https://stylus-lang.com/docs/operators.html#equality-relational | https://stylus-lang.com/docs/functions.html#conditionals
Colors
Colors are converted to hex or rgba on output
Sprintf
"%s" % val
vss("%s", val)
Comments
https://stylus-lang.com/docs/comments.html
Input
Output
Less Preprocessor
If you chose Stylus Preprocessor just because it has the same name as the extension and you only use
if
statements and variables, then maybe try Less Preprocessor instead. It’s also very powerful and not that buggy.An example of the same style in every
@preprocessor
(stylus, less, uso, default)Beta Was this translation helpful? Give feedback.
All reactions