Defining default values for mixins defined in JS file
See original GitHub issueSorry; this is likely due to my lack of understanding. I have a mixin defined in a JS file — it takes a couple of arguments so I am attempting to define it like this:
MakeSpinner: function ($backgroundColor, $highlightColor) {
return {
"content": "''",
"border": "'2px solid ' + $backgroundColor",
"border-left-color": $highlightColor,
"border-radius": "999px",
"opacity": "0"
};
}
However, I get the error Undefined variable $backgroundColor
which makes some sense as this is an argument rather than an actual variable.
How should I be writing this?
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Default values for mixins | Sass in the Real World: book 1 of 4
Set default values for mixins. When using mixins that require arguments, it is a best practice to always specify a default value for...
Read more >mixin and @include - Sass
Default values use the same syntax as variable declarations: the variable name, followed by a colon and a SassScript expression.
Read more >Simplifying SASS Mixins with Default Values | by Seth Poulin
We can do this by specifying a value for the default we want to override. @include border(5px); the mixin will compile to CSS...
Read more >Typescript mixins with default property values (derived from ...
As mentioned in my previous answer the issue is that the value of the property is set in the constructor of the mixin...
Read more >Defining mixins | LoopBack Documentation
To apply a mixin to a model, add “mixins” to the model definition JSON file. The value of mixins is an object keyed...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@benfrain JS mixins accepts a
rule
in first argument (I forget it too 😃 ). Here is a fixed version:@benfrain definitely! 😃