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

Re: Proposal: @-rule for containing exclusive @media rules

From: Sebastian Zartner <sebastianzartner@gmail.com>
Date: Mon, 22 Oct 2012 10:29:46 +0200
Message-ID: <CAERejNauPRUJVAg03aqwEyur9=8jKnrh4PZ7vX2FtYJregjqaw@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: Fran├žois REMY <fremycompany_pub@yahoo.fr>, www-style list <www-style@w3.org>
On Mon, Oct 22, 2012 at 8:35 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote:

> On 10/22/12 2:22 AM, Fran├žois REMY wrote:
>
>> An idea to solve the case in more generality:
>>
>>     @switch media {
>>         (min-width: 1000px) {
>>             ...
>>         }
>>         (min-width: 480px) {
>>             ...
>>         }
>>         all {
>>
>
> I can probably live with this, though requiring the explicit "all" is a
> bit counterintuitive; it took me a sec to figure out why that works.
>
I don't find the explicit "all" counterintuitive. To stay with your
examples: In C it would be default:, in Python else. It groups the rules in
the else branch.


> The fact that this doesn't simply reuse existing @media rules make the
> implementation a bit more annoying, but not too terrible, I guess.  It also
> makes the CSSOM for this a bit more painful to spec, too...  Again not too
> big a deal, assuming we actually _do_ it.

It complies more to the implementations of switch blocks in other languages
and avoids redundance, plus could probably enhanced to work together with
CSS variables in a future enhancement.


> >      @switch import {
> >       "desktop.css" (min-width: 1000px);
> >       "phone.css" (min-width: 480px);
> >       "small-phone.css" all;
> >   }
>
> Again, a bit more implementation and spec work than simply allowing
> @import inside @media, but doable.
>
A disadvantage of that syntax for authors is that they can't keep to their
known rules definition. Another one is that you can't mix different switch
expressions, e.g. not @media together with @import, if that's a use case at
all.

Sebastian
Received on Monday, 22 October 2012 08:30:13 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:21:01 GMT