W3C home > Mailing lists > Public > www-style@w3.org > October 2010

Re: [css3-writing-modes], option #4, use of CSS constants

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Tue, 26 Oct 2010 09:59:28 -0700
Message-ID: <AANLkTi=9KuJVpmiojN3M3RmngNwSsUNQ1WCGd-Ew1BZZ@mail.gmail.com>
To: Andrew Fedoniouk <news@terrainformatica.com>
Cc: www-style@w3.org
On Mon, Oct 25, 2010 at 9:35 PM, Andrew Fedoniouk
<andrew.fedoniouk@live.com> wrote:
> CSS constants is a generic way of adding "virtual properties and values".
>
> So if we would have CSS constants then anyone will able to declare the
> following:
>
> @media writing-direction(ttb)
> {
>  @const margin-start: margin-top;
>  @const margin-end: margin-bottom;
> }
> @media writing-direction(ltr)
> {
>  @const margin-start: margin-left;
>  @const margin-end: margin-right;
> }
> @media writing-direction(rtl)
> {
>  @const margin-start: margin-right;
>  @const margin-end: margin-left;
> }
>
> div {
>  @margin-start: 20px; /* declaration of 'logical' properties */
>  @margin-end: 10px;
> }
>
> constants in CSS have its own value and are useful in many other cases too.
>
> Pros:
>
> 1) Given option does not require creation of any new attributes.
> @margin-start and @margin-end are just "conditional aliases" of
> margin-left and margin-right.
> 2) We don't need to worry in the spec about particular names -
> authors may choose anything they like.
>
> 3) This will support any other forms of "property virtualization",
> even those we don't know yet.
>
> 3) @const's are very useful by themselves.
>
> Contras:
>
> 1) @const'ants need to be added to CSS.

Hrm.  That's a lot more intriguing than I had thought it would be.

This would work within the mixin framework I want, too:

@media writing-direction(ttb) { /* or whatever */
  @mixin margin-start (length) {
    margin-top: var(length);
  }
  @mixin margin-end (length) {
    margin-bottom: var(length);
  }
}
...etc...
div {
  @mixin margin-start(20px);
  @mixin margin-end(10px);
}

It's slightly more verbose, but I don't know if the specific idea of
property-name aliases is worthwhile outside of very limited contexts
like this, while mixins are useful much more generally.

~TJ
Received on Tuesday, 26 October 2010 17:00:27 GMT

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