Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not resolve the variable within mixin #80

Open
bazzle opened this issue May 9, 2019 · 2 comments
Open

Could not resolve the variable within mixin #80

bazzle opened this issue May 9, 2019 · 2 comments

Comments

@bazzle
Copy link

bazzle commented May 9, 2019

I created a mixin with variables and @if like this;

@mixin grid($howmanycols: 2, $gap: 1.5rem){
  display:grid;
  grid-auto-rows:auto;
  grid-gap:$gap;
  @if $howmanycols == 2{
    grid-template-columns:1fr 1fr;
  } @else if $howmanycols == 3{
    grid-template-columns:1fr 1fr 1fr;
  } @else if $howmanycols == 4{
    grid-template-columns:1fr 1fr 1fr 1fr;
  }
}

.thing{
  @include grid(2, 1.5rem);
}

https://www.sassmeister.com/gist/0a2d33972534af2cddd8323cc19e543b

Getting this error;
Fatal error: postcss-advanced-variables: /Users/bazzle/Documents/become a freelancer/site-design/css/input/main.css:12:15: Could not resolve the variable "$howmanycols" within "if $howmanycols == 3"

@gael-boyenval
Copy link

hello @bazzle it seems @else if is not supported.
but you can work around by doing multiple if :

@mixin grid($howmanycols: 2, $gap: 1.5rem){
  display:grid;
  grid-auto-rows:auto;
  grid-gap:$gap;
  
  @if $howmanycols == 2 {
    grid-template-columns:1fr 1fr;
  } 

  @if $howmanycols == 3{
    grid-template-columns:1fr 1fr 1fr;
  } 
  
  @if $howmanycols == 4 {
    grid-template-columns:1fr 1fr 1fr 1fr;
  }
}

.thing{
  @include grid(2, 1.5rem);
}

@gael-boyenval
Copy link

gael-boyenval commented May 5, 2020

🤣 didn't see how hold is this issue ! I think you've found your solution by now !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants