Search code examples
sasscompass-sass

A hexvalue isn't converted to rgba by the rgba function in compass


i have written the following two mixins:

@mixin textcolor($hexvaltxt, $opacitytxt: 1.0){
    color: $hexvaltxt;
    color: rgba($hexvaltxt, $opacitytxt);
}
@mixin boxcolor($hexvalbox, $opacitybox: 1.0){
    background-color: $hexvalbox;
    background-color: rgba($hexvalbox, $opacitybox);
}

basically i enter a hexvalue and in return i get a fallback color as hexvalue as well as a rgba value. basically based on what i have read the rgba function of compass should convert the hexvalue and the opacity into a rgba value. but when i call my mixin:

.maintitle {
    @include textcolor($sectionhead);
}

$sectionhead has #3f3e3e as value. then i get the following output:

.maintitle {
  color: #3f3e3e;
  color: #3f3e3e; }

instead of showing one hex and one rgba value i get only the same hex value twice. :/ isnt the conversion provided anymore or am i doing something completely wrong? as a side note i am running the latest compass (0.12.2) and sass (3.2.1). best regards ralf


Solution

  • 1.0 is completely opaque, so I am guessing Sass just leaves it as is since that would be optimal for backwards compatibility. If I change the second argument to .8, I get this output:

    .maintitle {
      color: #3f3e3e;
      color: rgba(63, 62, 62, 0.8);
    }