All Projects → lutien → Postcss Extract Value

lutien / Postcss Extract Value

Licence: mit
PostCSS plugin to extract values from css properties and put them into variables.

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Postcss Extract Value

Universal React Base
[OUTDATED] Super basic example to get you started with Universal (😦) React/Redux (+ API requests). Lightweight and straightforward.
Stars: ✭ 6 (-84.62%)
Mutual labels:  postcss
Postcss Interpolate
PostCSS plugin for values interpolation between breakpoints.
Stars: ✭ 9 (-76.92%)
Mutual labels:  postcss
Postcss Register Custom Props
PostCSS plugin that transforms custom property registration in CSS to JS
Stars: ✭ 20 (-48.72%)
Mutual labels:  postcss
Postcss Start To End
PostCSS plugin that lets you control your layout (LTR or RTL) through logical rather than physical rules
Stars: ✭ 18 (-53.85%)
Mutual labels:  postcss
Postcss Position
PostCSS plugin that adds shorthand declarations for position attributes
Stars: ✭ 26 (-33.33%)
Mutual labels:  postcss
Grunt Csswring
DEPRECATED. Minify CSS files using PostCSS-based CSSWring
Stars: ✭ 12 (-69.23%)
Mutual labels:  postcss
Purgecss
Remove unused CSS
Stars: ✭ 6,566 (+16735.9%)
Mutual labels:  postcss
Jekyll Boilerplate
Helpful files to get started working on a new Jekyll website
Stars: ✭ 30 (-23.08%)
Mutual labels:  postcss
Concise.css
A CSS framework that's lightweight and easy-to-use. Give up the bloat. Stop tripping over your classes. Be Concise.
Stars: ✭ 941 (+2312.82%)
Mutual labels:  postcss
Postcss Unprefix
PostCSS CSS unprefix
Stars: ✭ 15 (-61.54%)
Mutual labels:  postcss
Postcss Variables Loader
Share variables between CSS and JS with Webpack + HMR
Stars: ✭ 18 (-53.85%)
Mutual labels:  postcss
Gatsby Starter Alchemy
A Gatsby starter with PostCSS powers ✨🔮
Stars: ✭ 23 (-41.03%)
Mutual labels:  postcss
Postcss Banner
PostCSS plugin to add text banner and footer to resulting file
Stars: ✭ 13 (-66.67%)
Mutual labels:  postcss
Mdl Skeleton
Material Design skeleton with ssr-engine
Stars: ✭ 17 (-56.41%)
Mutual labels:  postcss
Postcss Icon
PostCSS plugin that adds `css icons` from icon sets
Stars: ✭ 20 (-48.72%)
Mutual labels:  postcss
Gulp Postcss
Pipe CSS through PostCSS processors with a single parse
Stars: ✭ 749 (+1820.51%)
Mutual labels:  postcss
React Postcss
Simple style tag for React
Stars: ✭ 9 (-76.92%)
Mutual labels:  postcss
Node Px2rem
Pixel to rem postprocessor
Stars: ✭ 31 (-20.51%)
Mutual labels:  postcss
Sapper Template Firebase
Starter Rollup template for Sapper apps with Firebase functions based on https://github.com/nhristov/sapper-template-rollup.
Stars: ✭ 29 (-25.64%)
Mutual labels:  postcss
Astral
⊙ CSS franken-work ⊙
Stars: ✭ 14 (-64.1%)
Mutual labels:  postcss

PostCSS Extract Value Build Status Coverage Status

PostCSS plugin to extract values from css properties and put them into variables.

.foo {
     width: 100px;
     color: #000;
     margin: 10px;
}
.bar {
     color: #000;
     margin: 15px;
}
:root {
    --width-1: 100px;
    --color-1: #000;
    --margin-1: 10px;
    --margin-2: 15px;
}
.foo {
    width: var(--width-1);
    color: var(--color-1);
    margin: var(--margin-1);
}
.bar {
    color: var(--color-1);
    margin: var(--margin-2);
}

Usage

import postcssExtractValue from 'postcss-extract-value';

postcss([
    postcssExtractValue(/* options */),
    // more plugins...
])

Options

filterByProps

Type: array
Required: false
Default: []

You can add names of css properties and only from this properties will be extracted values.

onlyColor

Type: boolean
Required: false
Default: false

If you set true, only colors (hex, rgb, hsl, color keywords) will be extracted from values.

scope

Type: string
Required: false
Default: :root

You can set custom selector, which will contain variables.

variableSyntax

Type: string
Required: false
Default: ``

By default it will be used css variables syntax, other available variants less and sass.

templateVariableName

Type: string
Required: false
Default: ``

You can set template for variables using special words. See more information below.

Usage templateVariableName

With options filterByProps or without any options by default:

[propertyName]

Name of css property (width, border, etc.).

postcss([
    postcssExtractValue({
        templateVariableName: 'theme[propertyName]'
    }),
])
.foo {
     width: 100px;
}
:root {
    --theme-width-1: 100px;
}
.foo {
    width: var(--theme-width-1);
}

With options onlyColor:

[colorKeyword]

Color keyword of the nearest color.

[tint]

Deviation in the dark or light side from the nearest color. (light\dark)

postcss([
    postcssExtractValue({
         templateVariableName: 'theme[tint][colorKeyword]',
    }),
])
.foo {
    border: 2px solid #cc0000;
    color: #ff0000;
    background-color: rgb(255, 26, 26);
}
:root {
   --theme-dark-red-1: #cc0000;
   --theme-red-1: #ff0000;
   --theme-light-red-1: rgb(255, 26, 26);
}
.foo {
   border: 2px solid var(--theme-dark-red-1);
   color: var(--theme-red-1);
   background-color: var(--theme-light-red-1);
}

Others

[selectorName]

Name of css selector (className, id, etc.)

postcss([
    postcssExtractValue({
        templateVariableName: 'theme[selectorName]'
    }),
])
.foo {
     width: 100px;
}
:root {
    --theme-foo-1: 100px;
}
.foo {
    width: var(--theme-foo-1);
}

See PostCSS docs for examples for your environment.

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].