Content Blocks in Mixins in SASS

To pass a block of styles inside a mixin, we use the @content directive, in place of which the styles we need will be placed.

Let's look at an example:

styles.scss@mixin active {
  * div {
    @content;
  }
}

@include active {
  #block {
    color: red;
  }
}

Compilation result:

styles.css* div #block {
  color: red; 
}

It is important to know that if we specify the @content directive more than once or inside a loop, then the style block will be called the same number of times.

styles.scss@mixin active {
  div {
    @content;
  }
navbar {
    @content;
  }
}
@include active {
  #block {
    color: red;
  }
  button {
    color:green;
  }
}

After compilation we will see:

styles.cssdiv #block {
  color: red; 
}
div button {
  color: green; 
}

navbar #block {
  color: red; 
}
navbar button {
  color: green; 
}
Задание 1

Tell me what the result of compiling the following code will be:

styles.scss@mixin super-link {
  a {
    @content;
  }
}
@include super-link {
  color: blue;
  text-decoration: underline;
}
Задание 2

Tell me what the result of compiling the following code will be:

styles.scss@mixin super-link {
  a {
    @content;
  }
  a .primary-link{
    @content;
    font-weight: bold;
  }
}
@include super-link {
  color: blue;
  text-decoration: underline;
}
Задание 3

Let's say you have the following mixin:

styles.scss@mixin colors {
  ...
}

Using the @content directive, set all links related to #primary to blue font color and wavy underline.