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

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 UTC