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

[Feature Request] Flag for the compiler to compile SASS variables into CSS variables #2505

Closed
ncovercash opened this issue Apr 17, 2018 · 1 comment

Comments

@ncovercash
Copy link

Hello,

Admittedly, I am not terribly familiar with SASS, I was wondering if it would be possible to add a flag to the compiler to, instead of substituting variables in, do the following:

$blue: #3bbfce;
$margin: 16px;

.content_navigation {
  color: $blue;
}

.border {
  padding: $margin / 2;
  margin: $margin / 2;
  border-color: $blue;
}

to

:root {
  --blue: #3bbfce;
  --margin: 16px;
}

.content_navigation {
  color: var(--blue);
}

.border {
  padding: var(--margin) / 2;
  margin: var(--margin) / 2;
  border-color: var(--blue);
}

Additional details, such as what to do with functions like darken, would need to be worked out, however I think this feature would be highly useful. This is especially important in CDN environments, such as Materialize, where the user must download the source, recompile it themselves, then host it themselves if they want to do something like change a color.

@nex3
Copy link
Contributor

nex3 commented Apr 19, 2018

The semantics of Sass variables are very different than those of CSS custom properties. For one thing, Sass variables are interpreted procedurally, so that a change later in the stylesheet won't affect earlier uses of the variable. They also support functions, operations, mixins, and control structures in a way that's impossible to emulate with custom properties. You're better of choosing between the two for use-cases where each one makes sense.

@nex3 nex3 closed this as completed Apr 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants