paraseba / cssgen

Generate CSS from clojure code with an embedded DSL
http://wiki.github.com/paraseba/cssgen/
120 stars 10 forks source link

@ getting a little redundant with nesting #8

Open patbrown opened 12 years ago

patbrown commented 12 years ago

Not a terminal issue, but a touch on the annoying side. I've been porting a few libraries to cssgen, because I prefer to write clojure code over Ruby. I'm running into a redundancy issue with parsing @

For instance ["@keyframes flash"
["0%, 50%, 100%" :opacity :1]
["25%, 75%" :opacity :0]]

Becomes @keyframes flash {

} @keyframes flash 0%, @keyframes flash 50%, @keyframes flash 100% {
opacity: 1;
}
@keyframes flash 25%, @keyframes flash 75% {
opacity: 0;
}

I understand the way nesting is designed in CSSGen and for most instances it is perfect, but in the event of designing responsive sites or utilizing CSS3 features it creates a lot of unnecessary bloat.

If I can figure out an elegant solution, I'll send you a pull. Right now my work-around is too jank.

paraseba commented 12 years ago

Thanks for reporting this, it's very interesting. Do you have any idea for a better syntax that covers this case? Please, if you make any changes, start with the 0.3.0 branch.

I'll try to look into this during the next days.

Thanks again

patbrown commented 12 years ago

I'm working on the 0.3.0. I'm pleased with my setup. Currently, I have defined my own functions "css-container" and "css-container-close" They basically print the selector in a string and spit with an open bracket, close closes.

I've got a convenience function for declaring spit on a comment line at the top of the page labeling the subject of the file. I then use append on every consequential spit by default. The spits in the page all default to a folder "raw" in the cwd and the file-name is the namespace of the clj file creating them. I then reference the namespaces with another spit to concat my files into one. Not a slick as I'd like, but getting there, minification is possible with some simple regex, but I haven't felt the need yet.

I've also come up with a way to make animations, color-schemes, and a few other css3 goodies extremely functional from within css-gen. It needs to be slimmed down big time, it'll be a week or so, before I feel comfortable releasing. Let me know what you think about incorporating an animation, color tools, etc set of libraries. Otherwise, they work fine as plugins.