EDIT:
I was just overthinking it. Now I've added more variables to the mixin like this to make all the colour correct:
@mixin CustomBtn($border-color, $transparent: transparent, $text-color, $bg-hover-color, $text-hover-color)
I've got a WordPress page where I use SCSS mixins to simplify the use of different colours on buttons. Most of the buttons have the same border colour and a text colour with a transparent background on them all so I created this mixin to deal with that:
@mixin CustomBtn($primary-color, $text-hover-color, $transparent: transparent) {
border: 2px solid $primary-color;
border-radius: 2px;
background-color: $transparent;
background-image: none;
color: $pri-color;
font-weight: 600;
padding: 1rem 2rem 1rem 1.5rem;
&:hover {
background-color: $primary-color;
color: $text-hover-color;
}
}
And here is the css where I output it:
.btn_custom {
&-black a {
@include CustomBtn($black, $white);
}
&-white a {
@include CustomBtn($white, $black);
}
&-blue a {
@include CustomBtn($light-blue, $white, $light-blue);
}
&-negative a {
@include CustomBtn($brown, $white);
}
}
This is all great but now the client wants to have a button that uses a coloured background, ex. a button with blue background-colour and white text. I want to do this mixin in the best way possible and not repeat my code, but I can't seem to figure out how to make this mixin work with a coloured background in the way I want it to (maybe I'm doing it wrong tho...)
Should I maybe use a conditional statement for the $transparent
variable?