W3C home > Mailing lists > Public > www-style@w3.org > August 2007

Re: css constants

From: Andrew Fedoniouk <news@terrainformatica.com>
Date: Mon, 27 Aug 2007 17:53:42 -0700
Message-ID: <006201c7e90d$e1da5f60$f502000a@internal.toppro.net>
To: "fantasai" <fantasai.lists@inkedblade.net>, <www-style@w3.org>


----- Original Message ----- 
From: "fantasai" <fantasai.lists@inkedblade.net>
To: <www-style@w3.org>
Sent: Monday, August 27, 2007 11:58 AM
Subject: Re: css constants


>
> L. David Baron wrote:
>> On Monday 2007-08-27 12:18 -0500, Devi Web Development wrote:
>>> Please forgive me if this has been discussed extensively before, but a 
>>> lot
>>> of people (see below) have talked about it at various points and I 
>>> haven't
>>> seen it in any draft; why not have an @variable or @constant that would 
>>> set
>>> a constant that could be used as a value?
>>
>> There are many different ways constants could be used.  A proposal
>> that would support all of them would be difficult to specify and
>> difficult to implement.
>>
>> It might help move this idea forward if somebody compiled a list of
>> the major use cases for constants and their relative importance.
>> (Creating additional named colors is a common one given in examples,
>> but I suspect there are others.)  Knowing what the use cases are is
>> needed to design such a feature properly.
>>
>> A wiki page would be a good place to do this.  Do we (the CSS
>> working group) have a publicly editable wiki yet?
>
> Created
>   http://csswg.inkedblade.net/ideas/constants
> which should now be publicly editable.
>

BTW: Wiki at csswg.inkedblade.net does not allow to register  - does not 
send
passwords back.

We use following implementation (in h-smile core: htmlayout/sciter):

1. const @-rule - const declaration:

@const name: value(s);

Where:
   name is a symbolic name (nmtoken?);
   value(s) - single value or sequence of values.

Example:
@const  THEME-BORDER-WIDTH:  1px 1px 1px 1px;
@const  THEME-BACKGROUND-COLOR:  orange;
@const  THEME-DEFAULT-FONT:  12pt arial, helvetica, sans-serif;

2. const insertion point is marked by '@' symbol immediately followed by the 
name of
the constant:

#something {
   border-width: @THEME-BORDER-WIDTH;
   left-boder: @THEME-BORDER-WIDTH solid black;
   font: @THEME-DEFAULT-FONT;
}

3. Insertion of non-existent const is not an error.

--------------------------------

@const in our implementation are immutable things - they behave as macro
preprocessor definitions in C/C++.
List of defined @const(ants)  is read-only accessible  in script. That
allows to pass parameters defined in CSS to scripts.
In our case event handlers of DOM elements are assignable by CSS by
prototype:EventHandlerNameInScript CSS attribyte so such parametrization
makes additional sense.

--------------------------------

I also have a feature named style-set that allows to assign blocks of styles
to DOM subtrees in all-or-none fashion. Very useful for components in AJAX 
style
But this is different story. I can expalin when wiki will be available and 
if needed.

All this works  in real life about year so far and I cannot recall any 
problems with
syntax and overall logic.

Andrew Fedoniouk.
http://terrainformatica.com
Received on Tuesday, 28 August 2007 00:53:55 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:52 GMT