Hey folks,
I’m trying to use a mixin to create a linear gradient for background,
I check sass doc and search online but there must be something I’m not seeing as it seem like i’m doing what I’m suppose to but I’m surely doing something wrong.
I have created styles/components/ _mixins.scss
@mixin linear-gradient($from, $to) {
background: $to;
background: -moz-linear-gradient(top, $from 0%, $to 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, $from), color-stop(100%, $to));
background: -webkit-linear-gradient(top, $from 0%, $to 100%);
background: -o-linear-gradient(top, $from 0%, $to 100%);
background: linear-gradient(to bottom, $from 0%, $to 100%);
filter: progid:dximagetransform.microsoft.gradient(GradientType=0, startColorstr=#{$from}, endColorstr=#{$to});
}
called it in _page.scss
#home {
padding: 100px;
@include linear-gradient(map-get($theme-colors, primary), map-get($theme-colors, secondary));
}
and imported it in main.scss
@import “components/mixins”;
I’m getting this error “no mixin named linear gradient”.
I don’t understand why it’s not finding the mixin.
Any clue?
Edit : found the solution!
apparently there is an order for @import in main.scss
I had added @import “components/mixins”; as last line which wasn’t working but when
I add it not as last line but after the last file in the same folder (here components) like so
@import “common/global”;
@import “components/buttons”;
@import “components/comments”;
@import “components/forms”;
@import “components/wp-classes”;
@import “components/mixins”;
@import “layouts/header”;
@import “layouts/sidebar”;
@import “layouts/footer”;
@import “layouts/pages”;
@import “layouts/posts”;
@import “layouts/tinymce”;
it’s working.
I leave this post in case another noob got the same problem.