-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] variables do not recognize in calc #1584
Comments
This is a stylus preprocessor bug val = 10em
.example1 {
--val: val
height: calc(100vh - var(--val))
}
.example2 {
height: 'calc(100vh - %s)' % val
}
.example3 {
height: unquote('calc(100vh - '+ val +')')
} |
thanks |
I just wrote my own calc() {
x = ''
for v, k in arguments {
x += (k > 0) ? ' %s' % v : '%s' % v
}
return 'calc(%s)' % unquote(x)
}
x = 16px
y = 16rem
z = var(--n)
:root {
// bad
--case1: calc(x - y)
--case2: calc(x * y)
// good
--case3: calc(x \- y \- z)
--case4: calc(x \* y \+ 8px)
} :root {
/* bad */
--case1: calc(0px);
--case2: calc(256px);
/* good */
--case3: calc(16px - 16rem - var(--n));
--case4: calc(16px * 16rem + 8px);
} |
Or even simpler👍 calc(a) {s('calc(%s)',a)}
x = 16px
y = 16rem
z = var(--n)
:root {
--case3: calc(x \- y \- z)
--case4: calc(x \* y \+ 8px)
} |
Awesome! I find it interesting how output is exactly the same. It might be better to keep arguments instead of passing additional argument |
Bug Report
Bug Description
Variables not recognized as numbers in calc()
Screenshots
CSS Code
System Information
Additional Context
The text was updated successfully, but these errors were encountered: