lundi 4 juillet 2016

SCSS mixin or function to differentiate between color or gradient

Using SCSS, I want to create a mixin, which will receive parameter and can determine whether it color or gradient and according to it create background property.

As possible parameters input:

  • any colors values (#hex, rgba, color...).
  • any colors SCSS functions (rgba(color, 0.1), darken(color, 15%) ...) as color.
  • gradient string ("top, rgba(30,87,153,1) 0%,rgba(125,185,232,1) 100%")

Pseudo-code:

if color or SCSS color function 
  then background: color;
if gradient 
  then background: -webkit-linear-gradient(gradient);
       background: linear-gradient(gradient);
       background: -moz-linear-gradient(gradient);

I don't want to use Compass or any other SASS library.

Aucun commentaire:

Enregistrer un commentaire