Re: [mediaqueries] User-defined Media Queries?

Le 02/06/2013 20:16, Kenneth Rohde Christiansen a écrit :
> Hi,
>
> Can you explain to me what you mean with "parse-time declarative
> macros"? like for instance give an example.

Declarative: when you state what happens but not how it happens, as 
opposed to imperative. In Selectors, :hover is declarative while 
adding/removing a class with mouse events is imperative.

Macro: a kind of variables, but I wanted another term because this is 
not CSS Variables a.k.a. Custom Properties. This is two parts: one that 
associates a name with a value, and one that uses the name, which is 
replaced by the value.

Parse-time: the replacement is done when the stylesheet is parsed, as 
opposed to eg. every time the result of the MQ needs to change.


Here is an example with made-up syntax:

     @macros { wide: (min-width: 700px) }
     @import "foo.css" $wide
     @media $wide { /* ... */ }


This kind of macro could potentially be used anywhere (MQs, Selectors, 
property names …) unlike var() that can only be used in property values.


> In WebKit/Blink the engine
> knows which media features change as a result of viewport changes and it
> only reevaluates those when the viewport changes (size, scale/zoom,
> etc). If the engine knows then invented conditionals change, we could do
> similar.

Yes, MQs being declarative allows the engine to do that and apply the 
change without going through JavaScript code.

-- 
Simon Sapin

Received on Sunday, 2 June 2013 12:42:09 UTC