Directive @at-root in SASS
The @at-root directive is designed to extract rules from the parent selector to the root of the file.
Let's look at the following example with first-level nesting selectors:
.parent {
background-color: #fdd;
@at-root .child {
border: 1px solid;
}
}
As a result of compilation we got the following code:
.parent {
background-color: #fdd;
}
.child {
border: 1px solid;
}
Now let's look at how the @at-root directive works with multiple selectors:
.main-parent {
background-color: #fdd;
@at-root {
.first-child {
border: 1px solid;
}
.second-child {
font-weight: bold;
}
}
.step-child {
color: #232523;
}
}
After compilation, the code looks like this:
.main-parent {
background-color: #fdd;
}
.first-child {
border: 1px solid;
}
.second-child {
font-weight: bold;
}
.main-parent .step-child {
color: #232523;
}
Tell me what the result of compiling the following code will be:
.primary-button {
background-color: #3272c7;
@at-root {
.block-button {
color: #ff0000;
}
.content-button {
color: #ccb42a;
}
}
.warning-button {
border: 2px solid #232523;
}
}