Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

   @case {
      supports(display: grid) and media(min-width: 33em) {
       
      }

      otherthing(arg: whatever) {

      }

      otherwise {

      }
   }
You're welcome.


Are @switch, @case and @default available? Because that'd be even more in line with general programming language knowledge.


Note that you don't need any @ sigil inside this @case because it contains condition { CSS } pairs; where something like "default" or "otherwise" can be recognized as a special condition word without a sigil. Selectors do not appear there; "otherwise" isn't syntactically a selector for some <otherwise> tag.

I got it down to one @ sygil to write a long conditional ladder with any number of conditions and a default.

It could be called @cond, in the Lisp style; not a lot of people know that though.

The first condition that is true fires; the rest are then ignored, so the order of the cases matters. Many languages call that sort of thing using "case" terminology.

Probably a diagnostic in the browser console is worthwhile if the always true "otherwise" condition is followed by anything.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: