Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-mediascope

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-mediascope

Declare variables for each mediaquery

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

postcss-mediascope

PostCSS plugin to declare postcss-advanced-variables for each media query.

This can be especially helpful for:

  1. css rules that should only be triggered for particular media query (e.g. for responsive grids);
  2. css declaration that should have different value for particular media query (e.g. adjusting font-size based on the screen size).

Usage

postcss([
    postcssMediascope([
        {
            query: 'only screen and (max-width: 500px)',
            variables: {
                color: 'red',
                media: 'phone'
            }
        },
        {
            query: 'only screen and (min-width: 501px) and (max-width: 900px)',
            variables: {
                color: 'blue',
                media: 'tablet'
            }
        }
    ]),
    postcssAdvancedVariables()
])

Running the following css code through postcssMediascope :

@mediascope {
    .$(media)-test {
        color: $color;
    }
}

produces intermediate result:

@media only screen and (max-width: 500px) {
    $color: red;
    $media: phone;
    .$(media)-test {
        color: $color;
    }
}
@media only screen and (min-width: 501px) and (max-width: 900px) {
    $color: blue;
    $media: tablet;
    .$(media)-test {
        color: $color;
    }
}

that then is processed through postcss-advanced-variables, so it becomes:

@media only screen and (max-width: 500px) {
    .phone-test {
        color: red;
    }
}
@media only screen and (min-width: 501px) and (max-width: 900px) {
    .tablet-test {
        color: blue;
    }
}

Keywords

FAQs

Package last updated on 08 Sep 2015

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc