Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
sort-css-media-queries
Advanced tools
Readme
The custom
sort
method (mobile-first / desktop-first) forcss-mqpacker
orpleeease
(which uses css-mqpacker) or, perhaps, something else ))
Statements | Branches | Functions | Lines |
---|---|---|---|
🇬🇧 English | 🇺🇦 Українська
mqpacker
https://github.com/hail2u/node-css-mqpacker is deprecated.
One of the alternative plugins may be - postcss-sort-media-queries
This package now is a part of the jss-plugin-sort-css-media-queries
npm install --save sort-css-media-queries
# or using yarn cli
yarn add sort-css-media-queries
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);
The plugin will sort your media-queries according to the mobile-first methodology. The sequence of media requests:
min-width
and min-height
from smallest to largest,max-width
and max-height
from largest to smallest,min-device-width
and min-device-height
from smallest to largest,max-device-width
and max-device-height
from largest to smallestprint, tv, ...
,print
print and (orientation: landscape)
print and (orientation: portrait)
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'
const sortCSSmq = require('sort-css-media-queries');
// your cool code
// ...
postcss([
mqpacker({
sort: sortCSSmq.desktopFirst
})
]).process(css);
The plugin will sort your media-queries according to the desktop-first methodology. The sequence of media requests:
max-width
and max-height
from largest to smallest,max-device-width
and max-device-height
from largest to smallestmin-width
and min-height
from smallest to largest,min-device-width
and min-device-height
from smallest to largest,tv, ...
,print
print and (orientation: landscape)
print and (orientation: portrait)
You can import a separate sorting helper from a package and create your own sorting method with config as needed:
const createSort = require("sort-css-media-queries/lib/create-sort");
const sortCSSmq = createSort({ ...configuration });
Or alternatively create a sort-css-mq.config.json
file in the root of your project.
Or add property sortCssMQ: {}
in your package.json
.
By this configuration you can control sorting behaviour.
unitlessMqAlwaysFirst
boolean | undefined
undefined
FAQs
The custom `sort` method (mobile-first / desktop-first) of CSS media queries for `postcss-sort-media-queries`, `css-mqpacker` or `pleeease` (which uses css-mqpacker) or, perhaps, something else ))
The npm package sort-css-media-queries receives a total of 258,927 weekly downloads. As such, sort-css-media-queries popularity was classified as popular.
We found that sort-css-media-queries demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.