Optional vendor support with global $variables #1

Open
barraponto opened this Issue Aug 9, 2012 · 8 comments

Projects

None yet

2 participants

@barraponto

That's how Compass does it, and it's pretty useful when you're dealing with mobile apps (webkit-only) or FirefoxOS apps (moz-only). See http://compass-style.org/reference/compass/support/

@danillonunes
Owner

This looks like a must-have in future, but for now there's no reason at all to use Property without vendor support.

@danillonunes
Owner

Oh, now I see, you want to disable vendor support for one engine but no all at once. This seems pretty cool, actually. I still don't know how it can be done - less is... less powerful than sass :( - but I'll think of it. Anyway, samples are welcome.

@barraponto

Did you see how Compass implements it? Doesn't Less support global variables?

@danillonunes
Owner

The first problem is that "variable" in Less isn't really a variable, is a constant, it can be defined only once.

So I can't do something like set @awesome-support: true by default and ask the users to set it to false if they wants to disable it. Also I can't ask them to set all the variables they want to true because it's a pita.

So all that can be done is expect a variable like @disable-awesome-support: true to be set only when the user wants to disable the feature.

The second problem is that, afaik, variables defined in a parent file aren't accessible inside the children files. So I can't do something like

in my-custom-css.css.less

@disable-awesome-support: true;
@import 'property/property.css.less
selector {
  .awesomeness();
}

in property/property.css.less

.awesomeness () {
  some-property: awesome;
}
.awesomeness () when (@disable-awesomeness-support) {
  some-property: sans-awesome;
}

The result will always be awesome (which is awesome, but the user is expecting a lack of awesomeness in this case).

@barraponto

So I guess you won't be able to port bourbon to LESS. https://github.com/thoughtbot/bourbon
:|

@danillonunes
Owner

So I figure out I can use variables from a parent file, but I'm still a bit stuck on how I can use different mixins according to a variable existence.

This gist is where I'm doing my tests: https://gist.github.com/3442700

lessc custom.css.less is outputting:

selector {
  some-property: awesome;
  some-property: sans-awesome;
}

the expected result is

selector {
  some-property: sans-awesome;
}
@danillonunes danillonunes was assigned Aug 24, 2012
@danillonunes
Owner

Oh, and thanks for the Bourbon link, it looks like exactly what I aim with Property.

@barraponto

Yeah, Bourbon is an almost ruby-less library for SASS. I thought it aimed to be absolutely independent of Ruby, so it would fulfill a demand that Compass can't. But it started to use SASS functions defined in Ruby so... go figure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment