Gathering detailed insights and metrics for postcss-js
Gathering detailed insights and metrics for postcss-js
Gathering detailed insights and metrics for postcss-js
Gathering detailed insights and metrics for postcss-js
PostCSS for React Inline Styles, Free Style and other CSS-in-JS
npm install postcss-js
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
658 Stars
155 Commits
24 Forks
17 Watching
1 Branches
24 Contributors
Updated on 15 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-4.3%
1,824,855
Compared to previous day
Last week
2.4%
10,424,121
Compared to previous week
Last month
7.2%
43,367,737
Compared to previous month
Last year
47.1%
427,247,578
Compared to previous year
1
1
PostCSS for CSS-in-JS and styles in JS objects.
For example, to use Stylelint or RTLCSS plugins in your workflow.
1const postcssJs = require('postcss-js') 2const autoprefixer = require('autoprefixer') 3 4const prefixer = postcssJs.sync([ autoprefixer ]) 5 6const style = prefixer({ 7 userSelect: 'none' 8}) 9 10style //=> { 11 // WebkitUserSelect: 'none', 12 // MozUserSelect: 'none', 13 // msUserSelect: 'none', 14 // userSelect: 'none' 15 // }
1const postcss = require('postcss') 2const postcssJs = require('postcss-js') 3 4const style = { 5 top: 10, 6 '&:hover': { 7 top: 5 8 } 9}; 10 11postcss().process(style, { parser: postcssJs }).then( (result) => { 12 result.css //=> top: 10px; 13 // &:hover { top: 5px; } 14})
1const postcss = require('postcss') 2const postcssJs = require('postcss-js') 3 4const css = '--text-color: #DD3A0A; @media screen { z-index: 1; color: var(--text-color) }' 5const root = postcss.parse(css) 6 7postcssJs.objectify(root) //=> { 8 // '--text-color': '#DD3A0A', 9 // '@media screen': { 10 // zIndex: '1', 11 // color: 'var(--text-color)' 12 // } 13 // }
sync(plugins): function
Create PostCSS processor with simple API, but with only sync PostCSS plugins support.
Processor is just a function, which takes one style object and return other.
async(plugins): function
Same as sync
, but also support async plugins.
Returned processor will return Promise.
parse(obj): Root
Parse CSS-in-JS style object to PostCSS Root
instance.
It converts numbers to pixels and parses [Free Style] like selectors and at-rules:
1{ 2 '@media screen': { 3 '&:hover': { 4 top: 10 5 } 6 } 7}
This methods use Custom Syntax name convention, so you can use it like this:
1postcss().process(obj, { parser: postcssJs })
objectify(root): object
Convert PostCSS Root
instance to CSS-in-JS style object.
Webpack may need some extra config for some PostCSS plugins.
Module parse failed
Autoprefixer and some other plugins need a json-loader to import data.
So, please install this loader and add to webpack config:
1loaders: [ 2 { 3 test: /\.json$/, 4 loader: "json-loader" 5 } 6]
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
GitHub workflow tokens follow principle of least privilege
Details
Reason
license file detected
Details
Reason
2 existing vulnerabilities detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 2/28 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More