mardi 21 juillet 2020

SASS: Get property's value from the mixin

I am trying to make a mixin, which makes the button darker on hover and press, but how can I get background-colorand color automatically without typing values twice - in properties of the element and in arguments of the mixin?

What I have at the moment:

$darken-on-press: 40%
@mixin button-behaviour($background-color, $text-color)
    &:hover
        background: darken($background-color, $darken-on-hover)
        color: darken($text-color, $darken-on-hover)
    &:active
        background: darken($background-color, $darken-on-press)
        color: darken($text-color, $darken-on-press)

Maybe is there a way to make it simpler? Thanks for your answer! <3




Aucun commentaire:

Enregistrer un commentaire