gss / engine

GSS engine
http://gss.github.io
MIT License
2.87k stars 105 forks source link

Sass-esq variables for standard css dump #123

Open garhbod opened 9 years ago

garhbod commented 9 years ago

The following code would need altering to suit as I haven't found how your variables/constraints are managed but if you were to set a variable like you would in Sass then have it placed in the CSS dump it would negate the need for any other CSS and only need GSS.

Javascript pulled from gss.js and edited

  StyleSheet.prototype.dumpCSS = function() {
    var css, rule, ruleCSS, _i, _len, _ref;
    css = "";
    _ref = this.rules;
    for (_i = 0, _len = _ref.length; _i < _len; _i++) {
      rule = _ref[_i];
      ruleCSS = rule.dumpCSS();
      if (ruleCSS) {
        css += ruleCSS;
      }
    }
    // for (constraint in constraints) { //loops through the constraints or variables
        _key = 'primary-color'; //constraint.key
        _replace = new RegExp (/\[/.source+_key+/\]/.source, "g");
        _value = '#f0f'; //constraint.value
        css = css.replace(_replace, _value);
    // }
    return css;
  };

Example it would replace in its current state

[primary-color] == '#f0f';

#container {
   color: [primary-color];
}
paulyoung commented 9 years ago

Thanks for the suggestion. I think the implementation would be different in the branches that are currently being developed.

There's been some discussion about if / when / how we should do this.

makoConstruct commented 9 years ago

I really would appreciate Sass style macros/parametric classes.

On Tue, Nov 25, 2014 at 6:56 AM, Paul Young notifications@github.com wrote:

Thanks for the suggestion. I think the implementation would be different in the branches that are currently being developed.

There's been some discussion about if / when / how we should do this.

— Reply to this email directly or view it on GitHub https://github.com/gss/engine/issues/123#issuecomment-64234637.