I have a mixin for a gradient that currently takes two colors:
@mixin gradient($color-start, $color-end) {
background-image: linear-gradient(90deg, $color-start 0%, $color-end 100%);
}
which I use everywhere like so
.my-gradient {
@include gradient(blue, yellow)
}
but now I'd like to modify the mixin (or convert it to a function) that can take two or three parameters for the gradient.
something like (pseudo code):
@mixin gradient($color-start, $color-end, $color-center) {
...if $color-center param exists...
background-image: linear-gradient(90deg, $color-start 0%, $color-center 50%, $color-end 100%);
...if $color-center param does not exist...
background-image: linear-gradient(90deg, $color-start 0%, $color-end 100%);
}
I'm not sure of the best way to handle this condition.