Hans Ørberg Lingua Latina per se Illustrata (Orberg) by Hans Ørberg & Peer Lauritsen
Category:Latin-language education
Category:Latin textbooks
Category:Latin dictionaries
Category:Latin dictionaries by language
Category:English dictionariesQ:
Sass mixin for unset / not set properties
Is there a way to write a Sass mixin for properties that are not defined in a parent's.scss file?
For example, I want to write a mixin for a property that is not defined in the parent's.scss file. The following would be an example of the usage I want to achieve:
$yellow-primary-color: #fbe5db;
#parent {
.color-picker-field {
background: $yellow-primary-color;
}
}
Then I want to be able to call.color-picker-field and have it return #fbe5db.
The error is:
Error: Invalid CSS after "background": expected expression (e.g. 1px, bold), was "#fbe5db"
If I remove the background property, it will get rid of the error, but it will not work properly.
#parent {
.color-picker-field {
background: 1px 1px 1px 1px;
}
}
Is there a clean, effective way to handle this situation?
A:
The way you want to do this is using the @content function as in the following example.
Here we use the "missing" parent's color property and make use of the @content function to include the content of that property.
@mixin color-picker($color) {
background: $color;
}
#parent {
.color-picker-field {
@content;
}
}
A:
You can create a mixin which includes the color as a default, then use that as a fallback when it is not defined on your selector.
$yellow-primary-color: #fbe5db;
#parent {
.color-p be359ba680
Related links:
Comments