[Adding laszlo-dev, as I think this is a general issue]

The way we handle the conversion of CSS to attributes is to write a 
"presentation type", that parses the string that will be passed in from CSS 
into the appropriate internal representation for Javascript.  For an example, 
you can look at lps/components/mixins/boxmodel.lzx and the <type> 
`boxsidedimensions`, which takes the various CSS patterns for specifying an 
defaulting top/right/bottom/left dimensions and parses them into an array that 
is set into the actual attribute.

I definitely think that we should support standard CSS.  Probably this means 
writing an `url` <type>.  It can probably leverage off the url-parsing code in 
lz.Browser (although that is far from perfect, IMO).

BTW, in general, you never need quotes in your CSS.  Our CSS compiler pretty 
much just passes everything through as a string and leaves it to the runtime to 
decide how to parse those strings (using <types>).  This is different from real 
CSS, where the name of the property dictates what the type of the value is.  
Because we allow arbitrary associations of CSS properties with LZX attributes, 
we have to defer the type conversion until we bind the property value to the 
attribute so we can infer from the attribute's type how to convert that string 
to a value.

Finally, resources are an additional layer of complexity because they are 
handled specially in the compiler, mostly for legacy reasons.  So there may be 
some compiler work required to get it out of the way when you want to use CSS 
to bind a resource.

On 2011-01-31, at 09:49, [email protected] wrote:

> Hi,
> 
> Using css to display an image in html looks like this:
> 
>    #bird {background-image: url(./bird.png); background-repeat:no-repeat;}
> 
> 
> 
> The button component requires something different:
> 
>        #bird {
>            icon-position: 'left';
>            icon-resource: 'http:bird.png';
>        }
> 
> 
> See the attachment for the example code.
> 
> Do you think the button component should support url() to specify an image?
> 
> BTW, using just bird.png won't work because OL assumes this is an embedded 
> resource.
> 
> Thanks!
> 
> Phil
> <b2.zip>


Reply via email to