At the time i use 2 Mixins for my Border Radius:
// When the Input is 1 Variable
@mixin border-radius($pixel) {
border-radius: $pixel;
}
// When the Inputs are 4 Variables
@mixin border-radius-s($tl, $tr, $br, $bl) {
border-top-left-radius: $tl;
border-top-right-radius: $tr;
border-bottom-right-radius: $br;
border-bottom-left-radius: $bl;
}
I'm trying to find a way to combine those mixins in to one! Probably with an if else
for the input. I've tried around but couldn't find any good working solution.
Anyone that could help me on that ?
Sass MixinsThe @mixin directive lets you create CSS code that is to be reused throughout the website. The @include directive is created to let you use (include) the mixin.
The @content, aka content directive, is “simple” in that it provides a way to reduce repetitive code, allowing for reuse and easier changes throughout the codebase.
Keyword arguments: The arguments are used to include in mixins. These types of arguments, if named, can be passed in any order and their default values can be skipped.
You can set the mixin to accept a list of values, as shown in the docs.
@mixin border-radius($pixel...) {
border-radius: $pixel;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With