You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

jss-plugin-sort-css-media-queries

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jss-plugin-sort-css-media-queries

JSS plugin for sort CSS media queries

1.0.1-beta.0
latest
Source
npmnpm
Version published
Weekly downloads
929
253.23%
Maintainers
1
Weekly downloads
 
Created
Source

jss-plugin-sort-css-media-queries

Test Build

JSS plugin for sort CSS media queries

Install

npm i jss-plugin-sort-css-media-queries

Plugin options

desktopFirst

type: boolean
default: false

By default, plugin is using mobileFirst methodology for sorting CSS Media Queries.
By this option you can change behavior to the desktopFirst methodology.

combineMediaQueries

type: boolean
default: false

You can combine similar CSS Media Queries rules into the one block.

import jss from 'jss';
jss.use(sortCssMediaQueries());

const sheet = jss.createStyleSheet({
    button: {
        width: 100,
        '@media (min-width: 600px)': {
            width: 150
        }
    },
    span: {
        color: 'blue',
        '@media (min-width: 600px)': {
            width: 'yellow'
        }
    }
});

Result without combineMediaQueries

button {
    width: 100px;
}

span {
    color: blue;
}

@media (min-width: 600px) {
    button {
        width: 150px;
    }
}

@media (min-width: 600px) {
    span {
        color: yellow;
    }
}

Result with combineMediaQueries: true

button {
    width: 100px;
}

span {
    color: blue;
}

@media (min-width: 600px) {
    button {
        width: 150px;
    }

    span {
        color: yellow;
    }
}

How it works

Unfortunately, I have not found a more correct method of influencing the sorting of the list of rules than how to modify the RuleList::toString() method.
That is a wrong way from the architecture OOP principles, but it is the most non-breaking way for the whole JSS workflow.
After calling .toString() method JSS work is done and in this point I can make own job with sorting, combining and returning CSS output.

Contributing

Please fill free to create issues or send PR

Licence

BSD-3-Clause License

Keywords

mobile-first

FAQs

Package last updated on 14 Feb 2021

Did you know?

Socket

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.

Install

Related posts