Horizontal composite (CSS version)

2 views
Skip to first unread message

Leslie P. Polzer

unread,
Apr 1, 2008, 6:54:15 AM4/1/08
to weblocks

Dead simple, but probably someone will need it.

(defwidget hcomposite (composite)
())

(defmethod render-widget-body ((hcomp hcomposite) &rest args)
(with-html
(dolist (w (composite-widgets hcomp))
(htm (:div :style "float:left"
(render-widget w))))
(htm (:div :style "clear:left"))))

Evan Monroig

unread,
Apr 1, 2008, 8:00:27 AM4/1/08
to webl...@googlegroups.com

Hi, I am not sure wether this is the right place to put CSS styling,
but it is a good idea to put little code snippets like this to share
:).

I also have a simple composite for the same use case but using inline
elements and HR separators every n elements. I needed this because
with floating, if the widgets inside have varying height you can see
some interesting staircase-like widget patterns.

Evan

Vyacheslav Akhmechet

unread,
Apr 3, 2008, 1:09:53 PM4/3/08
to webl...@googlegroups.com
On Tue, Apr 1, 2008 at 6:54 AM, Leslie P. Polzer <leslie...@gmx.net> wrote:
> (defwidget hcomposite (composite)
> ())
>
> (defmethod render-widget-body ((hcomp hcomposite) &rest args)
> (with-html
> (dolist (w (composite-widgets hcomp))
> (htm (:div :style "float:left"
> (render-widget w))))
> (htm (:div :style "clear:left"))))
Creating a widget just for styling?! Blasphemy!!!

ianeslick

unread,
Apr 3, 2008, 5:33:42 PM4/3/08
to weblocks
Is there a strategy to manage style and layout information from lisp,
or only via some separately defined css? It's a good to separate the
information structure and the design, but it also seems to me that you
want to specify some of the design in a more structured way than pure
CSS.

Could you have a mixin or inheritance strategy that allows you to set
the class and id elements of a widget implicitly and makes it easy for
a given system to customize the css layout by subclassing the layout
class? I find I often want to specify layout programatically and then
link it to a given widget and potentially, selectively, override it
for certain contexts.

There has to be a better way than manually maintaining the connection
between structure and design via id's and classes. It feels like
doing assembly language, there should be a good lispy abstraction for
this!

Ian

On Apr 3, 1:09 pm, "Vyacheslav Akhmechet" <coffee...@gmail.com> wrote:
> On Tue, Apr 1, 2008 at 6:54 AM, Leslie P. Polzer <leslie.pol...@gmx.net> wrote:>  (defwidget hcomposite (composite)

Vyacheslav Akhmechet

unread,
Apr 3, 2008, 8:19:55 PM4/3/08
to webl...@googlegroups.com
On 4/3/08, ianeslick <iane...@gmail.com> wrote:
> Is there a strategy to manage style and layout information from lisp,
> or only via some separately defined css?
Well, the widget hierarchy already encodes some information. Widget
class name corresponds to CSS classes and the NAME slot corresponds to
a CSS id. So, if I have a widget hierarchy like this: widget -> base
-> derived, and I instantiate derived with a name "foo" it will be
rendered like this:

<div class="widget base derived" id="foo">
...
</div>

This is done automagically by weblocks and can, of course, be
customized by specializing relevant generic functions.

Initially I intended to do a high level DSL for layout specification
that compiles to CSS, but unfortunately CSS has too many quirks for
this to be useful. There's really no way that I can think of to
convert layouts to working CSS programmatically given all the quirks
and browser incompatibilities without spending years on the compiler.

Reply all
Reply to author
Forward
0 new messages