mhulse / rex

On, Wildfire, on!
http://mhulse.github.io/rex/demo/
Apache License 2.0
4 stars 0 forks source link

Need "relative" mixin #110

Closed mhulse closed 11 years ago

mhulse commented 11 years ago

So I can pass unlimited nums to it. Returns back relative units in same order. Add $unit, $divisor and $multiplier.

mhulse commented 11 years ago

I've spent my weekend building this:

cd556d7410d168e6c8818d5aeca401098b9f2ff4

Now that I've got something working, I think I might nix this idea altogether.

Why? For multiple reasons:

  1. I'm not satisfied with logic of function.
  2. SASS/SCSS has some limitations that make the code harder to keep things simple (when I compare to other languages); for example, nth() will throw an error if index doesn't exist ... In other langs, you can specify a default return value in the list function so you can test/get/default all in one line. Currently, SCSS makes one jump through hoops with @if/@else statements in order to protect against list out of range errors.
  3. My experience level, while it's getting better, is still pretty noob ... I can't but help to think I'm missing a feature. If can't live without this feature, then I'm going to assume I'll write better SCSS when I revisit at a later date (not only that, but it looks like SASS 3.3 will have a ton of new/useful features to help improve current logic of code).
  4. SASS 3.3 will have better code to help improve current logic. :smile:
  5. What to do in these types of situations: padding: #{baseline(22, .875) / 2}em;? It would be pain in arse to account for multiplier and divisor plus the function call thingy. Ugh and ugly.
  6. Other?

For now, I guess it's good for me to have a commit to point to, just in case I want to re-visit, but I think I'm going to remove "expand" from my code and stick with things like:

.foo {
    margin: #{relative(12)}rem 0;
    padding: #{baseline(22, .875) / 2}em;
}

I suppose it's less readable, but at least it's more flexible.

mhulse commented 11 years ago

Discussion on nth() here:

Sass > nth() ... Specify a default return value?