-
Notifications
You must be signed in to change notification settings - Fork 250
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
The state of the gradients in nib #94
Comments
sounds reasonable. Personally I only use linear grads but I definitely don't want to render some functionality useless for those who do want it. We're missing support for degrees and I think the original position is optional, which I never noticed when I implemented it, or maybe it wasn't optional at the time |
Ok, then I'll try to find time and get to the gradients, there are a lot of things to do with them. |
it's unfortunate that browsers put us in this situation, I really wish experimental stuff was implemented as if it was official, we would still have some of this maybe with varying implementations but it would be a lot better I would think |
It would be great to have fully functional gradient support =) Re 1. and 3. Its nice to be able to write a single linear-gradient and have all the support you have configured automatically generated instead of having to repeat yourself three times. Nearly all CSS3 gradients can also be implemented with canvas or SVG. Sure that support involves some code and added complexity. But I don't understand how that has any impact on making the specific issues you listed simpler to fix ? Most of those issues appear to be related to the use of current-property which is a problem regardless of the fall-back support ? Feel free to re-write gradients and drop the SVG/canvas support for now. I'd be happy to re-add SVG and canvas support for linear/radial gradients based on the fixed mixins when this is merged unless there is some issue I can't see that makes that uber complicated. Maybe I'll need to see the diff to understand =) I definitely think a long-term view of removing legacy/fall-back support altogether, or moving to it another repo, would be a step back for nib and put us far behind compass/SASS which currently does SVG and PIE. Re 2. +1 |
Yeah, I won't have anything against the canvas etc. support for linear gradients as long as it won't break all other gradients :) So it would be ok if there'd be an image fallback when it can be done and just CSS3 stuff otherwise. |
Sure its would be great just to have pure CSS3 support working well first so your plan sounds good. Then after everything is fixed and merged just for pure CSS3 can have a look at the feasibility of re-implementing more comprehensive canvas or SVG support based on the re-written mixins =) I believe it will be possible without too much troubles and will be better to do it with a more solid base as the current state of gradients is quite broken. Cheers =) |
Some progress: kizu/nib@kizu:vendor-properties-values...kizu:new-gradients (based on my pull-request #95 — it have the code that also helps in this issue a lot). It already fixes some issues (multiple gradients, angles), however there are still work to do:
Maybe there is something else I forgot, I'll find out this when I'll get to the tests. |
Current state: moved the logic for the gradients from the So, this fixes almost all of the problems, so you could set the gradients to the variables, use them in any context that can have the backgrounds etc. What must be done still:
|
Looking forward to this! |
When it will be done? |
I'm a bit overwhelmed with my current work, I hope I'll complete this in a week or so. |
good |
Working on it, however, I stopped at the conversion between new and old gradient syntaxes, I think I'll redo most of the hacks needed to the gradient on the plain js via the plugin, so I could use the proper tools for that. The Stylus' pseudo-language don't allow me to do most of the things I want. |
awesome, Kizu. who's a master? Kizu is a master! |
Hi I've recently released a stylus framework that takes a lot of inspiration from nib and a fair bit of code, as well. Initially I planned to use nib for CSS3 mixins, but decided to try my hand at writing my own. I tried to focus on the mixins being as simple and transparent as possible. the linear and radial gradients accept the new css3 syntax. example linear "to" keyword. radial "at" keyword. There are still some issues as far as implementation. For instance support for radial sizes in pixels seems to be absent from firefox? or maybe I'm just doing it all wrong. I'm not an expert in the language stylus so my code could likely be refactored by someone who knows better. but it basically demonstrates the approach I'd like to see with mixins for CSS3. Maybe there's something relevant for you guys in it? I'd love some feedback. |
will it be possible to use multiple gradients in one background-image directive? what i mean is when i use the following code ATM, @import 'nib'
body
background-image \
linear-gradient(rgba(red, .1), rgba(blue, .1)), \
radial-gradient(black, white) i get body {
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, rgba(255,0,0,0.1)), color-stop(1, rgba(0,0,255,0.1))), radial-gradient(#000, #fff);
background-image: -webkit-linear-gradient(top, rgba(255,0,0,0.1) 0%, rgba(0,0,255,0.1) 100%), radial-gradient(#000, #fff);
background-image: -moz-linear-gradient(top, rgba(255,0,0,0.1) 0%, rgba(0,0,255,0.1) 100%), radial-gradient(#000, #fff);
background-image: -o-linear-gradient(top, rgba(255,0,0,0.1) 0%, rgba(0,0,255,0.1) 100%), radial-gradient(#000, #fff);
background-image: -ms-linear-gradient(top, rgba(255,0,0,0.1) 0%, rgba(0,0,255,0.1) 100%), radial-gradient(#000, #fff);
background-image: linear-gradient(top, rgba(255,0,0,0.1) 0%, rgba(0,0,255,0.1) 100%), radial-gradient(#000, #fff);
} i.e. only the first background is vendorized. PS: can we get parens to work like in python? so that we can simply do that instead of escaping newlines background-image (
linear-gradient(rgba(red, .1), rgba(blue, .1)),
radial-gradient(black, white)
) |
… external js function instead of buggy Stylus hacks, fixes stylus#94
@flying-sheep using multiple images is already possible in my branch, and it's almost complete, so I'll send a PR on this week or on the next one. |
Any word on the status of this? Big fan of the initiative : ) |
The only thing left is to make the ie canvas fallback to work where possible, I jut can't find some spare hours for it. But I hope I'll do it on this or next week. |
Awesome. I'm generally not a fan of the whole canvas implementation anyway just because it's easy enough to use css3 pie when you need it. Has anyone else tinkered with this? It works extremely well in IE (in production on a few large projects for my employer) and is very easy to implement. PS You are awesome for doing this. I'd love to help out too, and hopefully I will. I just feel like nib is undocumented and really losing steam, so I've been porting pieces of it over to a stylus css library I've been working on for a while. |
Yeah, adding some pie could be a thing. And I'm too not a fan of all those canvas polyfills, but I just dont' want to break anything for someone who uses it. However, I still that all the canvas functionality should be moved to another repo, 'cause it's not that everyone would use anyway. |
Just wanted to say that I'm really looking forward to that update as well! Hope you'll find the time soon. |
Thanks for your efforts on the gradient front Kizu! (specifically radial-gradient -yes, people actually use them) |
For anyone that's remotely interested, I've been putting a lot of work into this stylus library - I ported over the core gradient syntax (without the canvas piece) and it's stable and available as a stylus plugin like nib: https://github.com/jenius/roots-css I'm very actively working on this project and will continue to do so. |
Any progress on this? |
@domenic roots-css was released a few weeks ago and is stable. it's being used in roots, and documentation for the gradients piece can be found here. All linear gradients are supported (no canvas implementation, uses pie for IE fallback), haven't yet implemented radial because of lack of demand and support. |
I am not interested in another plugin; I am interested in nib. |
Nib is not being actively worked on. This issue was opened 8 months ago. |
Yeah, right now we use my branch in production, but there are still few issues with it that pervent the merging to the nib's upstream (mostly backwards compatibility ones). I still don't have time to fix them. The main problem is that the new way to render gradients is by using plugin in js that need to be somehow included. While there is no way to include plugins right from So, to fix it we should use the old gradients if the nib is simply included and use the new gradients if we can use the functions from the plugin. The Stylus' syntax don't allow it to write the needed mixins in it, so it's possible only via the plugin. |
Maybe this is true. Perhaps because you seem to be trying something pretty complicated in the OP. I just want my damn gradients to work in IE10 and new versions of Firefox, so my goal is to change the last line from "top" to "to bottom" etc. Looking at all the complicated things already done in gradients.styl, this seems likely possible. I guess I'll spend some time today trying to do this, and maybe that will get merged in, even if this ambitious project cannot be completed due to lack of time and technical issues. |
I would really love to see this issue closed with al the hard work you've done @kizu! |
👍 |
Is there at least slightest chance that these changes will be implemented in the original Nib? |
according to https://developer.mozilla.org/en-US/docs/Web/CSS/linear-gradient
and according to http://www.quirksmode.org/webkit.html & http://www.chromium.org/developers/webkit-version-table & https://en.wikipedia.org/wiki/Google_Chrome#Release_history - With data from statcounter, I calculate that the total usage for chrome 1-10 is That means that removing the legacy webkit gradient would only affect about PS: if anyone else can verify this against a larger dataset than just chrome, that'd be great. I doubt that adding in stats from Safari and the mobile browsers that use webkit would change much, but it's always better to have more data. |
+1 @slang800 |
This has been rebased on top of #192 and will be mergable once the 1 test that is still failing is fixed. |
Whoa. Huge! Nice work @kizu I'll check this out soon. |
Problem
There is a problem with gradients in nib now: there is a canvas polyfill for simple linear gradients and support for old webkit syntax.
While this is cool, it's cool until you want to do something more than just simple linear gradient.
Today you can do a lot of other things, like repeating gradients, radial ones, multiple images (look for example at the Lea Verou's pattern collection), and you can't use all those things with nib, 'cause, as I understand, you'll need to support the canvas and old webkit syntax as well, so you can't do just anything you want to gradients' mixin.
The nib's issues affected by this:
border-image
,-webkit-mask
etc.The solution
linear-gradient()
one wouldn't generate them by default. Or move them to different repo at all.I can try to fork nib and do all those things, but I want to know if it's needed there.
@visionmedia, what do you think?
The text was updated successfully, but these errors were encountered: