views:

35

answers:

2

I was contemplating writing a UI toolkit where setting the position and size of an element/widget was intuitive and powerful. Here are some examples of how it would be used (not currently implemented):

ui("Panel").size(". 40").pos("0 0").attach(element);
ui("Textarea").size(". %-10").pos("0 40").attach(element);
ui("Panel").size(". 10").pos("0 bottom+5");

Where . means auto, % means 100% and the possibility to add pixels to percentages.

Does anything like said exist (even as a jQuery plugin or something)? Somethings just aren't possible with pure CSS.

+1  A: 

If you want to create it in Javascript you will have to make the script read the ui code then convert to css. This would cause too much overhead and wouldn't really be worth the hassle. It would be nice to have a quicker more intuitive way to create styles but unfortunately without paying in efficiency it wont work too well.

GEShafer
I thought about that but I'm sure for my application I could think of a way to cache it somehow. Besides, it wouldn't be much overhead to parse simple positions and sizes, just ones mixing percentages with pixels.
Louis
Maybe for one ui element; but I am assuming it would be possible to have several ui components at once. Then upon page loading it will need to be converted to something the page can read so each element will have to be changed into css via the script. It just seems like the best way to make this functional would be for personal use not on an actual web app. (i.e. use your own code to quickly create styled ui elements and then use your application to parse this at a pretty quick speed and copy and paste the output css)
GEShafer
A: 

I would be very wary before lunching into this. This would give any devloper joining your project a major headache of needing to learn your new layout mechanisims.

I have yet to see what CSS can not do, so you may want to look into what it can do further before going ahead look at the various examples from http://www.csszengarden.com/ . I'm not saying CSS is easy but it is standard.

If you need more power look at CSS3 the majority of which can be achived using jQuery.

Sorry to say but I think you are heading down the wrong road by building your own. Use standard, tested, well knowen and documented way. Don't reinvent the wheel unless you are in the wheel making business.

David Waters
Completely agree. That's why my question was "does this exist?" :P. I've been looking into other UI frameworks but they don't work very well in a container or flowing to the containers constraints.
Louis