Gathering detailed insights and metrics for postcss-sort-media-queries
Gathering detailed insights and metrics for postcss-sort-media-queries
Gathering detailed insights and metrics for postcss-sort-media-queries
Gathering detailed insights and metrics for postcss-sort-media-queries
PostCSS plugin for sorting and combining CSS media queries with mobile-first / desktop-first methodologies.
npm install postcss-sort-media-queries
95.7
Supply Chain
100
Quality
76.2
Maintenance
100
Vulnerability
100
License
Module System
Unable to determine the module system for this package.
Min. Node Version
Typescript Support
Node Version
NPM Version
147 Stars
229 Commits
8 Forks
3 Watching
4 Branches
4 Contributors
Updated on 28 Sept 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-8.3%
58,329
Compared to previous day
Last week
7.2%
327,492
Compared to previous week
Last month
7.7%
1,435,170
Compared to previous month
Last year
55.9%
14,727,548
Compared to previous year
1
1
🌏 English ▫ O'zbek
PostCSS plugin for sorting and combining CSS media queries with mobile first / desktop first methodologies.
From 5.0.0 plugin support Media Feature Types: “range”
And here is the online demo
before
1@media screen and (max-width: 640px) { 2 .head { color: #cfcfcf } 3} 4@media screen and (max-width: 768px) { 5 .footer { color: #cfcfcf } 6} 7@media screen and (max-width: 640px) { 8 .main { color: #cfcfcf } 9} 10@media screen and (min-width: 1280px) { 11 .mobile-first { color: #cfcfcf } 12} 13@media screen and (width > 640px) { 14 .mobile-first { color: #cfcfcf } 15} 16@media screen and (max-width: 640px) { 17 .footer { color: #cfcfcf } 18}
after
1@media screen and (width > 640px) { 2 .mobile-first { color: #cfcfcf } 3} 4@media screen and (min-width: 1280px) { 5 .mobile-first { color: #cfcfcf } 6} 7@media screen and (max-width: 768px) { 8 .footer { color: #cfcfcf } 9} 10@media screen and (max-width: 640px) { 11 /* combined */ 12 .head { color: #cfcfcf } 13 .main { color: #cfcfcf } 14 .footer { color: #cfcfcf } 15}
before
1@media screen and (width < 640px) { 2 .header { color: #cdcdcd } 3} 4@media screen and (min-width: 760px) { 5 .desktop-first { color: #cdcdcd } 6} 7@media screen and (width < 640px) { 8 .main { color: #cdcdcd } 9} 10@media screen and (min-width: 1280px) { 11 .desktop-first { color: #cdcdcd } 12} 13@media screen and (max-width: 760px) { 14 .footer { color: #cdcdcd } 15} 16@media screen and (max-width: 640px) { 17 .footer { color: #cdcdcd } 18}
after
1@media screen and (max-width: 760px) { 2 .footer { color: #cdcdcd } 3} 4@media screen and (width < 640px) { 5 /* combined */ 6 .header { color: #cdcdcd } 7 .main { color: #cdcdcd } 8 .footer { color: #cdcdcd } 9} 10@media screen and (min-width: 760px) { 11 .desktop-first { color: #cdcdcd } 12} 13@media screen and (min-width: 1280px) { 14 .desktop-first { color: #cdcdcd } 15}
First thing's, install the module:
npm install postcss postcss-sort-media-queries --save-dev
Check you project for existed PostCSS config: postcss.config.js
in the project root, "postcss"
section in package.json
or postcss
in bundle config.
If you already use PostCSS, add the plugin to plugins list:
1module.exports = { 2 plugins: [ 3+ require('postcss-sort-media-queries')({ 4+ sort: 'mobile-first', // default value 5+ }), 6 require('autoprefixer') 7 ] 8}
or with custom sort function
1module.exports = { 2 plugins: [ 3+ require('postcss-sort-media-queries')({ 4+ sort: function(a, b) { 5+ // custom sorting function 6+ } 7+ }), 8 require('autoprefixer') 9 ] 10}
If you do not use PostCSS, add it according to official docs and set this plugin in settings.
Sorting works based on dutchenkoOleg/sort-css-media-queries function.
This option support string or function values.
{string}
'mobile-first'
- (default) mobile first sorting{string}
'desktop-first'
- desktop first sorting{function}
your own sorting function'mobile-first'
1postcss([ 2 sortMediaQueries({ 3 sort: 'mobile-first' // default 4 }) 5]).process(css);
'desktop-first'
1postcss([ 2 sortMediaQueries({ 3 sort: 'desktop-first' 4 }) 5]).process(css);
1postcss([ 2 sortMediaQueries({ 3 function(a, b) { 4 return a.localeCompare(b); 5 } 6 }) 7]).process(css);
In this example, all your media queries will sort by A-Z order.
This sorting function is directly passed to Array#sort() method of an array of all your media queries.
By this configuration you can control sorting behaviour.
1postcss([ 2 sortMediaQueries({ 3 configuration: { 4 unitlessMqAlwaysFirst: true, // or false 5 } 6 }) 7]).process(css);
Or alternatively create a sort-css-mq.config.json
file in the root of your project. Or add property sortCssMQ: {}
in your package.json
.
Sort only top level media queries to prevent eject nested media queries from parent node
1postcss([ 2 sortMediaQueries({ 3 onlyTopLevel: true, 4 }) 5]).process(css);
See Releases history
postcss-momentum-scrolling
- plugin for adding momentum style scrolling behavior (-webkit-overflow-scrolling:touch
) for elements with overflow (scroll, auto) on iOSNo vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
9 existing vulnerabilities detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/19 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn Moresort-css-media-queries
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 ))
postcss-custom-media
Use Custom Media Queries in CSS
postcss-media-minmax
Using more intuitive `>=`, `<=`, `>`, `<` instead of media queries min/max prefix.
@csstools/postcss-media-queries-aspect-ratio-number-values
Use number values in aspect-ratio media queries.