npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

postcss-screen

v0.1.0

Published

Sugar syntax for screen sizes

Downloads

5

Readme

PostCSS Screen Plugin

This plugin has the purpose to be sugar syntax for width media queries.

/** This is the sugar syntax */
@small-screen {
    div {
        width: 400px; 
    }
}

/** This is what it would look like after parsing */
@media (max-width: 980px) {
    div {
        width: 400px; 
    }
}

Installation

To install it, you can paste the following text to your terminal.

npm install postcss postcss-screen

About

This plugin has 8 standard screen sizes for the HTML to react with CSS, where each one will replace a custom at rule with a supported media query.

| Size | Width | |----------|--------| | jumbo | 2200px | | wide | 2000px | | large | 1700px | | moderate | 1450px | | medium | 1200px | | small | 980px | | mini | 670px | | nano | 450px |

Options

The plugin can be customized to have custom response sizes or custom parameters for the query.

// To pass your options it can be done in the following way
postcss: {
    plugins: [
        ...,
        require('postcss-screen')({ 
            query: 'max-width',
            sizes: { small: 1000 },
        }),
    ]
}

// Other frameworks may use a map object
postcss: {
    plugins: {
        ...,
        "postcss-screen": {
            sizes: { small: 1000 },
            query: 'max-width',
            params: 'only screen and',
        }
    }
}

Sizes

There will be some cases when a custom size is desired. For such cases, this can be passed to the options in the sizes object as a key pair value (Check the example above).

/** This is the sugar syntax */
@small-screen {
    div {
        width: 400px; 
    }
}

/** This is what it would look with a custom small size of 1000 */
@media (min-width: 1000px) {
    div {
        width: 400px; 
    }
}

Queries

In some cases the desired behavior is to apply with the min-width instead of the max-width query. If that is the case, this value can be passed in the query property from the options.

/** This is the sugar syntax */
@small-screen {
    div {
        width: 400px; 
    }
}

/** This is what it would look with the custom query */
@media (min-width: 980px) {
    div {
        width: 400px; 
    }
}

Params

In case is wanted to attach specific media at rule paramateres, this can be done with the params property from the options.

/** This is the sugar syntax */
@small-screen {
    div {
        width: 400px; 
    }
}

/**
 * This is what it would look with custom parameters
 * like `only screen and` for legacy browsers
 * @see https://www.geeksforgeeks.org/what-is-the-difference-between-screen-and-only-screen-in-media-queries/
*/
@media only screen and (min-width: 980px) {
    div {
        width: 400px; 
    }
}

For Requests If you wish to contribute to this plugin you can visit me in the public repository on github at https://github.com/Nona9614/postcss-screen and discuss about it. I will be happy to improve this project to its best!