stylus / nib

Stylus mixins, utilities, components, and gradient image generation
http://stylus.github.io/nib
MIT License
1.91k stars 249 forks source link

rgba/hsla backward compatibility #211

Closed AliMD closed 10 years ago

AliMD commented 11 years ago

I usually use hsla for my colors, and it not work in old browser. I request to add backward compatibility like this

.selector{
  color: #hex;
  color: rgba(...);
}
notslang commented 11 years ago

but rgba has support for transparency... hex does not... how would we add full backwards compatibility?

AliMD commented 10 years ago

Not need to full compatibly Just 2 color for old browser support ! its better no color Normally stylus convert hsl to hex and hsla to rgba, great but i want to fix this warning http://csslint.net/ for IE6,IE7,IE8 Fallback color (hex or RGB) should precede RGBA color.

notslang commented 10 years ago

I'm not entirely sure that nib should add a hex fallback when using rgba because, often, that transparency is important and might not look right without it. Also, there's no way for us to determine what the correct color should be... it would probably be color_of_the_element * opacity_of_the_color + background_color * (1 - opacity_of_the_color) ... or something like that... but we can't tell from just the css what the background color will be... also that would only work for the color of the element... using rgba in the background color would be even harder to determine.

Adding a fallback like this that isn't fully (or at least mostly) backwards-compatible would cause issues in places where custom fallbacks are really needed. Also, it would add a lot of bloat to the css since rgba can be used anywhere that hex can. And with 87.27% browser support for rgba, I don't think it's worth it... unless you know of a good solution.

AliMD commented 10 years ago

just add a function for color and background-color to write double color for every transparent color. or guide me to add it to my own. thank you.

AliMD commented 10 years ago

@visionmedia could you please check this issue.

notslang commented 10 years ago

TJ is very busy because he manages like 300 open source projects (which is why I'm managing nib for him)... so I wouldn't expect him to have time to reply here.

notslang commented 10 years ago

As for writing your own mixin, Stylus provides docs here: http://learnboost.github.io/stylus/docs/mixins.html ... Imma close this since adding partial backwards compatibility for something like this is likely to cause issues... If you can think of a better solution, feel free to reopen.

AliMD commented 10 years ago

@slang800 i don't know why you don't understand me !

nib try to fix all css issue in all browser i need to fix this issue too

i want to write this

p
  color hlsa(...)

and nib convert it to this

p {
  color #...;
  color rgba(...);
}

if you agree with me i can sent a pull request

AliMD commented 10 years ago

If you can think of a better solution, feel free to reopen.

i cant reopen this !

AliMD commented 10 years ago

I'm managing nib for him

I did not know this, i think you don't know why TJ make nib ! so sorry

notslang commented 10 years ago

I understand what you want to do, but I don't understand why.

Adding a fallback like this that isn't fully (or at least mostly) backwards-compatible would cause issues in places where custom fallbacks are really needed. Also, it would add a lot of bloat to the css since rgba can be used anywhere that hex can. And with 87.27% browser support for rgba, I don't think it's worth it... unless you know of a better solution.

As for why TJ made nib, it is to make prefixing and other redundant parts of CSS easier. But nib is not supposed to make assumptions about whether or not a different color (one without transparency) would be a suitable fallback for one that has transparency.

If you would like to implement this on your own, then go right ahead and fork nib... you can make whatever you want. However, I don't think a partial fallback like this belongs in nib.

AliMD commented 10 years ago

Ok This is only a feature request.

But i don't agree with you

I don't understand why

And i don't understand why not If you are using rgba for example for background-color you don't have any color in background in 12.73% of browsers. we don't want to have alpha fallback just fallback for backcolor.

Thank you anyway