Re: [css-variables] CSS Variables are a NEW kind of variable

This is actually an extension I proposed for CSS Variables Level 2.

    html { my-preferred-color: lime; }
    .pBackground { background: $my-peferred-color; }
    .feather { box-shadow: 0px 0px 5px $background-color; }

    .feater.pBackground == { background: lime; box-shadow: 0px 0px 5px lime; }

However, it would - like for CSS Variables – use the SPECIFIED value for the property and not the COMPUTED one (using the latter is impossible because it would create implicit dependencies that would be a nightmare for both implementors and authors), except that ‘initial’ and ‘inherit’ would be resolved (this is similar to what happens when you use ‘inherit’ in your stylesheet). This limits the scope where this can be useful. 



Going from there, this is very handy to consider variables and properties toegether if you consider new “replacement” functions like var-inherit(): 

    li.important {
        border-left: 3px solid inherit(color);
        color: red;
    }

or

    .switchToBlack { 
        my-old-color: inherit(my-color); 
        my-color: black;
    }

or

    * {
        my-align-child-content: auto; /* not-inherited variable */
        align-content: inherit(my-align-child-content);
    }

    #someElement {
        my-align-child-content: center;
    }

However, those proposals are left for L2 because this requires to extend the specification and we want variables as soon as possible.

François

From: Chris Eppstein 
Sent: Wednesday, June 13, 2012 10:38 PM
To: Tab Atkins Jr. 
Cc: Divya Manian ; www-style@w3.org 
Subject: Re: [css-variables] CSS Variables are a NEW kind of variable
If they are normal properties, why can I not access the value of other properties? 

Chris


On Wed, Jun 13, 2012 at 1:31 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:

  On Wed, Jun 13, 2012 at 1:25 PM, Divya Manian <manian@adobe.com> wrote:
  > Sorry to flog this dead horse again.
  >
  > But there has been no satisfactory answer to why variables are still being
  > defined as a 'property' instead of having a new definition.


  Because the things that define variables *are* properties.  There's no
  difference, in any way, from a normal property.  Trying to distinguish
  them syntactically would just be overly verbose and would hide the
  fact that they're just normal properties.

  ~TJ

Received on Wednesday, 13 June 2012 21:13:37 UTC