Saltando un argumento opcional en Sass Mixin
Tengo esta mezcla para manejar un simple gradiente lineal CSS3:
@mixin linear-gradient($from, $to, $dir: bottom, $dir-webkit: top, $ie-filters: false) {
background-color: $to;
background-image: -webkit-linear-gradient($dir-webkit, $from, $to);
background-image: linear-gradient(to $dir, $from, $to);
@if $ie-filters == true and $old-ie {
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{ie-hex-str($from)}', endColorstr='#{ie-hex-str($to)}');
}
}
$dir
es la abreviatura de 'dirección'.
Si necesito hacer$ie-filters
'verdadero' y no necesito cambiar el$dir
/ $dir-webkit
los valores predeterminados todavía necesito volver a declararlos, lo que obviamente no es SECO y óptimo, así que debo hacer esto:
@include linear-gradient(#7a7a7a, #1a1a1a, bottom, top, true);
Cuando solo quiero hacer esto:
@include linear-gradient(#7a7a7a, #1a1a1a, true);
¿Cómo puedo omitir los argumentos de esta manera al llamar a un mixin?
PD: si te estás preguntando sobre el$dir-webkit
el argumento es para Webkit ya que todavía no maneja la nueva sintaxis de gradiente (ver:http://generatedcontent.org/post/37949105556/updateyourcss3 ->Nueva sintaxis de gradiente), la dirección debe ser opuesta a la sintaxis estándar.