All Projects → pascalduez → Postcss Apply

pascalduez / Postcss Apply

Licence: unlicense
PostCSS plugin enabling custom properties sets references

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Postcss Apply

Postcss Quantity Queries
PostCSS plugin enabling quantity-queries
Stars: ✭ 113 (-23.13%)
Mutual labels:  postcss
Midas
Syntax highlighter based on PostCSS.
Stars: ✭ 123 (-16.33%)
Mutual labels:  postcss
Preprocessor
A future-facing CSS preprocessor (used by SUIT CSS)
Stars: ✭ 132 (-10.2%)
Mutual labels:  postcss
Webpack4 Cli
🌈 Webpack4 + Vue/React + TS (SPA or MPA) 面向实际工作流(开发 & 编译 & 打包 & 部署 & 上线)的脚手架,并提供docker镜像供快速构建。
Stars: ✭ 115 (-21.77%)
Mutual labels:  postcss
Container Query
A PostCSS plugin and Javascript runtime combination, which allows you to write container queries in your CSS the same way you would write media queries.
Stars: ✭ 119 (-19.05%)
Mutual labels:  postcss
Fast
Develop, build, deploy, redeploy, and teardown frontend projects fast.
Stars: ✭ 126 (-14.29%)
Mutual labels:  postcss
Sapper Firebase Typescript Graphql Tailwindcss Actions Template
A template that includes Sapper for Svelte, Firebase functions and hosting, TypeScript and TypeGraphQL, Tailwind CSS, ESLint, and automatic building and deployment with GitHub Actions
Stars: ✭ 111 (-24.49%)
Mutual labels:  postcss
Postcss Rtl
PostCSS plugin for RTL-adaptivity
Stars: ✭ 143 (-2.72%)
Mutual labels:  postcss
Postcss Aspect Ratio Mini
A PostCSS plugin to fix an element's dimensions to an aspect ratio
Stars: ✭ 123 (-16.33%)
Mutual labels:  postcss
Postcss Px To Viewport
A plugin for PostCSS that generates viewport units (vw, vh, vmin, vmax) from pixel units. The best choice to create a scalable interface on different displays by one design size.
Stars: ✭ 1,997 (+1258.5%)
Mutual labels:  postcss
Rollup Plugin Styles
🎨 Universal Rollup plugin for styles: PostCSS, Sass, Less, Stylus and more.
Stars: ✭ 116 (-21.09%)
Mutual labels:  postcss
Static Site Boilerplate
A better workflow for building modern static websites.
Stars: ✭ 1,633 (+1010.88%)
Mutual labels:  postcss
React Redux Graphql Apollo Bootstrap Webpack Starter
react js + redux + graphQL + Apollo + react router + hot reload + devTools + bootstrap + webpack starter
Stars: ✭ 127 (-13.61%)
Mutual labels:  postcss
Fuzzymail
📨 Email template generator. Making emails fun again.
Stars: ✭ 114 (-22.45%)
Mutual labels:  postcss
Postcss Viewport Height Correction
PostCSS plugin to solve the popular problem when 100vh doesn’t fit the mobile browser screen.
Stars: ✭ 137 (-6.8%)
Mutual labels:  postcss
Postcss Instagram
📷 PostCSS plugin for using Instagram filters in CSS
Stars: ✭ 111 (-24.49%)
Mutual labels:  postcss
Frasco
Quick starter for Jekyll including full setup for Sass, PostCSS, Autoprefixer, stylelint, Webpack, ESLint, imagemin, Browsersync, etc.
Stars: ✭ 123 (-16.33%)
Mutual labels:  postcss
Postcss Ant
Size-getting function masquerading as a grid system.
Stars: ✭ 145 (-1.36%)
Mutual labels:  postcss
Book
《现代化前端工程师权威指南》https://guoyongfeng.github.io/book/
Stars: ✭ 141 (-4.08%)
Mutual labels:  postcss
Barebones
A barebones boilerplate for getting started on a bespoke front end.
Stars: ✭ 127 (-13.61%)
Mutual labels:  postcss

postcss-apply

CSS Standard Status npm version Build Status Coverage Status

PostCSS plugin enabling custom property sets references

Refer to postcss-custom-properties for DOMless limitations.

Web Platform status

Spec (editor's draft): https://tabatkins.github.io/specs/css-apply-rule
Browser support: https://www.chromestatus.com/feature/5753701012602880

⚠️ The @apply rule and custom property sets most likely won't get any more support from browser vendors as the spec is yet considered deprecated and alternative solutions are being discussed.
Refer to following links for more infos:

Installation

npm install postcss-apply --save-dev

Usage

const fs = require('fs');
const postcss = require('postcss');
const apply = require('postcss-apply');

const input = fs.readFileSync('input.css', 'utf8');

postcss()
  .use(apply)
  .process(input)
  .then((result) => {
    fs.writeFileSync('output.css', result.css);
  });

Examples

In CSS declared sets

/* input */

:root {
  --toolbar-theme: {
    background-color: rebeccapurple;
    color: white;
    border: 1px solid green;
  };
}

.Toolbar {
  @apply --toolbar-theme;
}
/* output */

.Toolbar {
  background-color: rebeccapurple;
  color: white;
  border: 1px solid green;
}

In JS declared sets

const themes = {
  /* Set names won't be transformed, just `--` will be prepended. */
  'toolbar-theme': {
    /* Declaration properties can either be camel or kebab case. */
    backgroundColor: 'rebeccapurple',
    color: 'white',
    border: '1px solid green',
  },
};

[...]
postcss().use(apply({ sets: themes }))
[...]
/* input */

.Toolbar {
  @apply --toolbar-theme;
}
/* output */

.Toolbar {
  background-color: rebeccapurple;
  color: white;
  border: 1px solid green;
}

options

preserve

type: Boolean
default: false
Allows for keeping resolved declarations and @apply rules alongside.

sets

type: { [customPropertyName: string]: Object | string }
default: {}
Allows you to pass an object or string of custom property sets for :root. These definitions will be prepended, in such overridden by the one declared in CSS if they share the same name. The keys are automatically prefixed with the CSS -- to make it easier to share sets in your codebase.

Credits

Licence

postcss-apply is unlicensed.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].