Package Exports
- sort-css-media-queries
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sort-css-media-queries) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
sort-css-media-queries
🇺🇸 English | 🇷🇺 Русский язык
The custom
sortmethod (mobile-first / desktop-first) forcss-mqpackerorpleeease(which uses css-mqpacker) or, perhaps, something else ))
Installing
npm install --save sort-css-media-queries
# or using yarn cli
yarn add sort-css-media-queriesUsage
See the original docs at first https://www.npmjs.com/package/css-mqpacker#sort;
const sortCSSmq = require('sort-css-media-queries');
// your cool code
// ...
postcss([
mqpacker({
sort: sortCSSmq
})
]).process(css);
mobile-first
The plugin will sort your media-queries according to the mobile-first methodology. The sequence of media requests:
min-widthandmin-heightfrom smallest to largest,max-widthandmax-heightfrom largest to smallest,min-device-widthandmin-device-heightfrom smallest to largest,max-device-widthandmax-device-heightfrom largest to smallest- media queries without dimension values, for example
print, tv, ....
Example
Media-queries list:
// min-width/-height -> from smallest to largest
'screen and (min-width: 320px) and (max-width: 767px)',
'screen and (min-height: 480px)',
'screen and (min-height: 480px) and (min-width: 320px)',
'screen and (min-width: 640px)',
'screen and (min-width: 1024px)',
'screen and (min-width: 1280px)',
// device
'screen and (min-device-width: 320px) and (max-device-width: 767px)',
// max-width/-height <- from largest to smallest
'screen and (max-width: 1023px)',
'screen and (max-height: 767px) and (min-height: 320px)',
'screen and (max-width: 767px) and (min-width: 320px)',
'screen and (max-width: 639px)',
// no units
'screen and (orientation: landscape)',
'screen and (orientation: portrait)',
'print',
'tv'Sort result:
'screen and (min-width: 320px) and (max-width: 767px)',
'screen and (min-height: 480px)',
'screen and (min-height: 480px) and (min-width: 320px)',
'screen and (min-width: 640px)',
'screen and (min-width: 1024px)',
'screen and (min-width: 1280px)',
'screen and (min-device-width: 320px) and (max-device-width: 767px)',
'screen and (max-width: 1023px)',
'screen and (max-height: 767px) and (min-height: 320px)',
'screen and (max-width: 767px) and (min-width: 320px)',
'screen and (max-width: 639px)',
'print',
'screen and (orientation: landscape)',
'screen and (orientation: portrait)',
'tv'desktop-first
const sortCSSmq = require('sort-css-media-queries');
// your cool code
// ...
postcss([
mqpacker({
sort: sortCSSmq.desktopFirst
})
]).process(css);
The plugin will sort your desktop-queries according to the mobile-first methodology. The sequence of media requests:
max-widthandmax-heightfrom largest to smallest,max-device-widthandmax-device-heightfrom largest to smallestmin-widthandmin-heightfrom smallest to largest,min-device-widthandmin-device-heightfrom smallest to largest,- media queries without dimension values,
print, tv, ....
Tests
npm run sort- test of sorting resultnpm run happiness- test code stylenpm test:npm run sort+npm run happiness