News for hackers. Stuff that matters.
Re:AbsurdJS – JavaScript based CSS preprocessor by lux on Friday October 11, 2013 @08:36PM (#6536712)
This is a really powerful idea and makes a lot of sense.

It's as flexible and readable as any CSS preprocessor I've seen, possibly more so because it's in a syntax I won't forget because I program in it all day.

And it's trivial to integrate into any JavaScript setup because it's just JavaScript. Brilliant!

Re:AbsurdJS – JavaScript based CSS preprocessor by jcampbell1 on Friday October 11, 2013 @09:21PM (#6536851)
I completely agree.

When I get a chance, I am going to attempt thing that are impossible with SASS and LESS. There are things that are impossible such as using multiply and screen to create a button of an arbitrary gradient and color that looks good.

This is the first preprocessor that is capable of doing something other than just saving keystrokes.

Re:AbsurdJS – JavaScript based CSS preprocessor by cristianpascu on Saturday October 12, 2013 @02:34AM (#6537559)
CoffeeScript will save us many keystrokes here, too. :)
Re:AbsurdJS – JavaScript based CSS preprocessor by SkyMarshal on Saturday October 12, 2013 @02:02AM (#6537484)
Absolutely, and it takes CSS (preprocessors at least) closer to the LISP ideal of code is data and data is code.

Now that I've seen it, in hindsight I'm struck with several thoughts: 1) in hindsight it seems so obvious, 2) why didn't I think of this, and 3) LESS/SASS/Stylus/etc are obsolete.

Re:AbsurdJS – JavaScript based CSS preprocessor by krrishd on Friday October 11, 2013 @06:53PM (#6536343)
In the fact that it detects repeated properties and makes the code DRY, that feature could be absorbed into LESS or SASS, and become useful.
Re:AbsurdJS – JavaScript based CSS preprocessor by jonnyscholes on Saturday October 12, 2013 @12:58AM (#6537382)
You can sort of do this with @extend in sass - but I agree its nicer here, it seems to just sort of... do it.
Re:AbsurdJS – JavaScript based CSS preprocessor by krasimirtsonev on Saturday October 12, 2013 @07:59AM (#6538412)
Yep, @extends in SASS are exactly you need, but unfortunately they don't support params and interpolation in their names doesn't work as expected.
Re:AbsurdJS – JavaScript based CSS preprocessor by jonnyscholes on Monday October 14, 2013 @09:11PM (#6550797)
Yeah totally agree. Can also lead to very unreadable sass files to if your not very careful. Whilst teaching new devs where I work we ask them not to use @extend until we suggest it one a few reviews have been done.
Re:AbsurdJS – JavaScript based CSS preprocessor by crazygringo on Friday October 11, 2013 @06:43PM (#6536304)
OK... is this just a complete joke "because you can", hence the name...

...or is there some use case for CSS-in-your-JS that I can't quite manage to imagine? I'm straining my brain to think of one...

Edit: more info at http://davidwalsh.name/write-css-javascript

I guess it's trying to be a more flexible version of LESS/SASS by leveraging the full power of JavaScript. I've never felt that LESS was really lacking in power... I'm curious what others think. But interesting idea.

Re:AbsurdJS – JavaScript based CSS preprocessor by jeremiep on Friday October 11, 2013 @08:54PM (#6536772)
One use case would be to create server-side 'widgets' just like Yesod does.

The basic idea is that they combine the document, style and scripting in a single reusable component. Pages are then built by composing these widgets together and can finally be used as templates when responding to requests.

Re:AbsurdJS – JavaScript based CSS preprocessor by elros on Friday October 11, 2013 @08:49PM (#6536759)
From looking at the example code, two things come to my mind: The first is that it would probably look even better in CoffeeScript.

Also, https://en.wikipedia.org/wiki/JavaScript_Style_Sheets anybody? ;-)

Re:AbsurdJS – JavaScript based CSS preprocessor by latchkey on Friday October 11, 2013 @09:59PM (#6536938)
The CS syntax is mostly just the same, you can just remove most of the {} to define the objects.
Re:AbsurdJS – JavaScript based CSS preprocessor by paulannesley on Friday October 11, 2013 @07:36PM (#6536495)
I think it makes a lot of sense to build the features of Less/Sass etc on top of a well-known parser/interpreter (JS), rather than inventing a new one from scratch.

I already feel like I understand how AbsurdJS works better than I understand Less/Sass, for that reason.

Re:AbsurdJS – JavaScript based CSS preprocessor by padolsey on Saturday October 12, 2013 @05:05AM (#6537962)
Isn't one crucial problem with this that ES object-literal syntax does not guarantee order? And order is pretty important in CSS, no?
Re:AbsurdJS – JavaScript based CSS preprocessor by tomjakubowski on Saturday October 12, 2013 @06:55AM (#6538285)
Off the top of my head, order in CSS is only important when a property is defined multiple times for a given selector, either within the same block or in separate ones. Like these examples:

    .foo {
      font-size: 12px;
      font-size: 14px; // later property wins
    }

    .bar {
      font-size: 12px;
    }

    .bar, .baz {
      font-size: 14px; // later property wins
    }
And I don't see a way to generate either of those cases only using object literals in this library.
Re:AbsurdJS – JavaScript based CSS preprocessor by garethadams on Saturday October 12, 2013 @07:49AM (#6538392)
You're forgetting that shorthand properties give multiple ways to set some values. This wouldn't work reversed:

    {
      border: 1px solid red;
      border-bottom-width: 10px;
    }
- http://jsfiddle.net/afXGN/
Re:AbsurdJS – JavaScript based CSS preprocessor by krasimirtsonev on Saturday October 12, 2013 @08:19AM (#6538459)
Actually you care about the ordering if you have same properties applied for same selector. However, AbsurdJS hides this and automatically calculate the latest defined value. And that's what it goes in the compiled file. I need to spend some time using the library to be sure that such problem is actually solved. So, shortly: I can't 100% guarantee that you will not have problems with that.
Re:AbsurdJS – JavaScript based CSS preprocessor by jongleberry on Saturday October 12, 2013 @02:09AM (#6537502)
an alternative is rework: https://github.com/visionmedia/rework. both absurd and rework use https://github.com/visionmedia/css-parse for parsing CSS. the difference is that rework already has a bunch of great plugins like https://github.com/ai/autoprefixer. i'm not sure why this guy doesn't leverage any of the existing ones.

the only difference is using JSON and JS input vs. a CSS string, but he could have easily written that in less than 100 lines vs an entirely separate framework.

Re:AbsurdJS – JavaScript based CSS preprocessor by todd3834 on Friday October 11, 2013 @07:48PM (#6536541)
If you read Krasimir Tsonev's article about this, it is much cooler than you might think: http://davidwalsh.name/write-css-javascript

EDIT: Krasimir Tsonev's article not David Walsh

Re:AbsurdJS – JavaScript based CSS preprocessor by Pirate-of-SV on Friday October 11, 2013 @07:03PM (#6536384)
Fun project.

I guess I wouldn't bee too upset with CSS being replaced by json in the future. It makes sense in a way of using fewer languages.

On the other hand Javascript should probably be replaced by something better too.

Re:AbsurdJS – JavaScript based CSS preprocessor by nilved on Friday October 11, 2013 @06:58PM (#6536364)
I like the idea. People should note that this doesn't mean mixing your CSS into your JavaScript necessarily - you can precompile CSS just like you would with S*SS.
Re:AbsurdJS – JavaScript based CSS preprocessor by mrfancypants on Saturday October 12, 2013 @01:30AM (#6537423)
It doesn't seem to handle vendor-specific prefixes (-webkit, -moz, etc). I suppose you could write your own mixins (plugins) to handle that, but still, a shame.
Re:AbsurdJS – JavaScript based CSS preprocessor by krasimirtsonev on Saturday October 12, 2013 @03:14AM (#6537644)
Hello guys. Thanks for the comments. The next things which I'm going to do is to start packing components. One of the big problems which I have for a long time, is the fact that I have to deliver html, css and javascript. Usually they are placed in different places and I have to take care to put them in the browser. With AbsurdJS I could send the javascript logic and the css together.
Re:AbsurdJS – JavaScript based CSS preprocessor by chadscira on Friday October 11, 2013 @07:16PM (#6536442)
How do you handle defining multiple @font-face's?
Re:AbsurdJS – JavaScript based CSS preprocessor by lux on Friday October 11, 2013 @08:40PM (#6536731)
Not sure if it supports it, but couldn't an array be used? For example:

    "@font-face": [
        { /* font one },
        { /* font two }
    ]
Re:AbsurdJS – JavaScript based CSS preprocessor by krasimirtsonev on Saturday October 12, 2013 @03:16AM (#6537651)
It is actually possible if you turn of combineSelectors. Or you may create two different instances of AbsurdJS and at the end merge their output.
Re:AbsurdJS – JavaScript based CSS preprocessor by PLejeck on Saturday October 12, 2013 @01:02AM (#6537389)
This seems like it would be good for filling a similar role to LLVM, providing a framework to take an object and turn it into CSS. I'm not so sure it makes sense as a language to directly use: JSON is nice as a data serialization format, but it's not very fun to author complex things in it.
Re:AbsurdJS – JavaScript based CSS preprocessor by underwater on Saturday October 12, 2013 @01:08AM (#6537396)
JavaScript. JSON is more rigid and verbose, for example it requires that properties be quoted.
Re:AbsurdJS – JavaScript based CSS preprocessor by elwell on Saturday October 12, 2013 @04:00PM (#6540049)
Looks possibly awesome with CoffeeScript
Re:AbsurdJS – JavaScript based CSS preprocessor by caiob on Friday October 11, 2013 @06:25PM (#6536240)
Literally an absurd.
Re:AbsurdJS – JavaScript based CSS preprocessor by thenerdfiles on Saturday October 12, 2013 @12:51AM (#6537367)
JSON presentation layer for test-driven CSS for teh win.