Can be done with pure CSS and less code
ProLoser opened this issue · 11 comments
Here's a demo:
http://jsfiddle.net/ProLoser/bM4C9/
Doesn't require Javascript and should have excellent browser support. I tend to prefer declaring the colors in CSS instead of JS anyway.
Of course it can be done in pure CSS. It's a matter of personal preference. Some people prefer to write 3 lines of JS, instead of 30 in CSS.
OR you could refactor your version so that click events are properly emitted and your javascript gets reduced to just tweaking the css and generating the html instead of event binding.
Thanks for your feedback, I find it very useful, especially from someone experienced like you. I'll consider it when making further changes to the component.
@damianof no because it's not something people should be including into their project as a 3rd party lib, just learn css. At best I would throw it on a tips and tricks collection
Maybe a repo of CSS snippets....
Here's a demo:
http://jsfiddle.net/ProLoser/bM4C9/
Doesn't require Javascript and should have excellent browser support. I tend to prefer declaring the colors in CSS instead of JS anyway.
Hey @ProLoser , do you have a copy of this CSS you might share? unfortunately this jsfiddle seems to have been lost in the river of time. Thank you!
@bobbyg603 Google "css switch"
thanks @ProLoser i ended up finding one, here's the one i went with for anyone looking at this thread in the future https://codepen.io/TazTheManiac/pen/rGrpMg