question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Defining default values for mixins defined in JS file

See original GitHub issue

Sorry; 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 $backgroundColorwhich makes some sense as this is an argument rather than an actual variable.

How should I be writing this?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
aicommented, Mar 15, 2016

@benfrain JS mixins accepts a rule in first argument (I forget it too 😃 ). Here is a fixed version:

MakeSpinner: function (rule, $backgroundColor, $highlightColor)  {
        return {
            "content": "''",
            "border": '2px solid ' + $backgroundColor,
            "border-left-color": $highlightColor,
            "border-radius": "999px",
            "opacity": "0"
        };
    }
0reactions
aicommented, Mar 15, 2016

@benfrain definitely! 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found