@mixin genericSidesStyles ($sides, $style, $cssProperty) {
@if($sides == '') {
$cssProperty: $style;
}
@else {
@each $side in $sides {
@if ($side == 'top' or $side == 'bottom' or $side == 'left' or $side == 'right' ) {
$cssProperty-#{$side}: $style;
}
}
}
}
This is a scss mixin for giving styles to css properties with sides like margin, padding, border etc.
I am calling my mixin as below
@include genericSidesStyles('top', 20px, 'margin');
here top is for margin-top, 20px is the distance and margin is the cssProperty but I am getting the following error
expected ':' after $cssProperty- in assignment statement
Help me to know where I am wrong in this
@if ($side == 'top' or $side == 'bottom' or $side == 'left' or $side == 'right' )
condition. Remove the@each
loop (not sure why is it even required) & it should work fine. Also change your statement to#{$cssProperty}-#{$side}: $style
– Nikhil Nanjappa$cssProperty
from@each
statement - All you need to do is change the statement$cssProperty-#{$side}: $style;
to#{$cssProperty}-#{$side}: $style;
– Nikhil Nanjappa