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

@dialpad/postcss-responsive-variations

Package Overview
Dependencies
Maintainers
20
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dialpad/postcss-responsive-variations

PostCSS plugin for creating responsive variations from a list of classes

  • 1.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
20
Created
Source

postcss-responsive-variations

PostCSS plugin for creating responsive variations from a list of classes.

/* Input example */
.foo {
    .background-color: red;
}
/* Output example */
.foo {
  .background-color: red;
}

@media (max-width: 480px){
  .sm\:foo {
    .background-color: red;
  }
}

@media (max-width: 640px){
  .md\:foo {
  .background-color: red;
  }
}

@media (max-width: 980px){
  .lg\:foo {
  .background-color: red;
  }
}

@media (max-width: 1264px){
  .xl\:foo {
  .background-color: red;
  }
}

Usage

Step 1: Install plugin:

npm install --save-dev postcss @dialpad/postcss-responsive-variations

Step 2: 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 do not use PostCSS, add it according to official docs and set this plugin in settings.

Step 3: Add the plugin to plugins list:

module.exports = {
  plugins: [
+   require('postcss-responsive-variations'),
    require('autoprefixer')
  ]
}

Step 4: Create the responsive breakpoints and the classes you need and pass it to the plugin argument.

+const breakpoints = [
+  { prefix: 'sm\\:', mediaQuery: '(max-width: 480px)' },
+  { prefix: 'md\\:', mediaQuery: '(max-width: 640px)' },
+  { prefix: 'lg\\:', mediaQuery: '(max-width: 980px)' },
+  { prefix: 'xl\\:', mediaQuery: '(max-width: 1264px)' },
+];

+const classes = [
+ '.foo',
+ /\.bar-*/
+];

module.exports = {
  plugins: [
+   require('postcss-responsive-variations')({breakpoints, classes}),
    require('autoprefixer')
  ]
}

Keywords

FAQs

Package last updated on 28 Mar 2023

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