ATX ATX - 1 month ago 22
Sass (Sass) Question

SCSS, simplify/factorize ::after selector

Let's illustrate with an example.

I want the element

::after
sort
class to be red, and blue if sort order class is
desc
ending, I use the following scss.

.sort {
::after{
color: red;
}
&.desc::after {
color: blue;
}
}


Is there a way to simplify the two
::after
?

.sort::after {
color: red;
&.desc {
color: blue;
}
}


Is not ok as will be compiled to
.sort::after.desc
.

What I would like to obtain is
.sort.desc::after
.

Is there a way to simplify my example and remove the duplicated
::after
?

Answer

Unfortunately, this isn't possible and probably won't be. See the links to relevant GitHub issues in this answer.

Comments