Socket
Book a DemoInstallSign in
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
npmnpm
Version published
Weekly downloads
3
50%
Maintainers
1
Weekly downloads
 
Created
Source

postcss-mediascope

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

This can be especially helpful for:

  • css rules that should only be triggered for particular media query (e.g. for responsive grids);
  • 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

postcss

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.