mercredi 14 février 2018

Sass For loop function

I'm really having trouble understanding how some of the Sass's @for function work. I've googled around for a bit and didn't find what I was looking for.

So here's an example:

@function box-shadow ($n) 
  $value: '#{random()}px #{random()}px 1px #FFF'
  @for $i from 0 through $n
    $value: '#{$value}, #{random()}px #{random()}px 1px #FFF'

  @return unquote($value)

So here's what I'm confused about:

the syntax of '#{$value}' inside the loop, is that the same logic as:

var x = 1;
x = x + 4;

Also, why can't the initial $value be empty string? it fails to compile if I remove the contents and have empty brackets.

Thanks




Aucun commentaire:

Enregistrer un commentaire