glaze icon indicating copy to clipboard operation
glaze copied to clipboard

Responsive values given as array-like objects

Open kripod opened this issue 6 years ago • 0 comments

Motivation

Styled System has introduced array-based responsive styling, reducing the burden caused by manually written media queries.

Details

To avoid confusion between the array and object notation, undefined should be preferred over null for skipping a breakpoint:

sx({ width: [, , '25%'] }); // Good, sparse array
sx({ width: [undefined, undefined, '25%'] }); // Better, more explicit
sx({ width: { 2: '25%' } }); // Best, concise while being explicit

sx({ width: { 600: '25%' } }); // Okay, custom one-off breakpoint of >=600px

sx({ width: [null, null, '25%'] }); // Bad, null may suggest that the value gets reset
sx({ width: { 0: null, 2: '25%' } }); // Bad, null isn't necessary here

kripod avatar Mar 26 '20 09:03 kripod