W3C home > Mailing lists > Public > www-style@w3.org > May 2012

Re: [css-variables] Using $foo as the syntax for variables

From: Florian Rivoal <florianr@opera.com>
Date: Thu, 24 May 2012 09:29:51 +0200
To: "Ojan Vafai" <ojan@chromium.org>, "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: www-style@w3.org
Message-ID: <op.wesxr1wz4p7avi@localhost.localdomain>
On Wed, 23 May 2012 19:32:50 +0200, Tab Atkins Jr. <jackalmage@gmail.com>  
wrote:

> In the new syntax, it would look something like this:
> color: $bar //normal
> color: default-var($bar, red) // default value
> color: parent-var($bar) // bar from the parent
> color: parent-var($bar, red) // bar from the parent, with a default value

If we go with $ (which I still think we shouldn't), I think the above  
should
be written like this instead:

color: $bar //normal
color: default-var(bar, red) // default value
color: parent-var(bar) // bar from the parent
color: parent-var(bar, red) // bar from the parent, with a default value

Keeping the $ within the function, seems to imply that you want to expand
the variable first, and then apply the function, giving the following
behavior:

ul {
   $foo: red;
   $bar: green;
}
li {
   $foo: bar;
   $bar: blue;
   $background-color: parent-var($foo); /* you get green */
}

Also, having the following two be equivalent
  color: $bar;
  color: var(bar);
Makes it possible to have multiple levels of indirection. Which you can't
have with $, unless you want to allow this:
  color: $$bar;

  - Florian
Received on Thursday, 24 May 2012 07:30:30 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:54 GMT