Installations
npm install @vusion/postcss-calc
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
10.16.3
NPM Version
6.13.2
Score
74.4
Supply Chain
98.2
Quality
80.6
Maintenance
50
Vulnerability
100
License
Releases
Contributors
Languages
JavaScript (83.13%)
Yacc (16.87%)
Developer
postcss
Download Statistics
Total Downloads
12,347
Last Day
1
Last Week
6
Last Month
89
Last Year
2,843
GitHub Statistics
215 Stars
206 Commits
34 Forks
16 Watching
6 Branches
31 Contributors
Bundle Size
161.57 kB
Minified
42.60 kB
Minified + Gzipped
Package Meta Information
Latest Version
7.0.3
Package Id
@vusion/postcss-calc@7.0.3
Unpacked Size
147.03 kB
Size
37.82 kB
File Count
10
NPM Version
6.13.2
Node Version
10.16.3
Total Downloads
Cumulative downloads
Total Downloads
12,347
Last day
-90.9%
1
Compared to previous day
Last week
-72.7%
6
Compared to previous week
Last month
-17.6%
89
Compared to previous month
Last year
-53.9%
2,843
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
PostCSS Calc ![PostCSS](https://postcss.github.io/postcss/logo.svg)
PostCSS Calc lets you reduce calc()
references whenever it's possible. This
can be particularly useful with the PostCSS Custom Properties plugin.
When multiple units are mixed together in the same expression, the calc()
statement is left as is, to fallback to the W3C calc() implementation.
Installation
1npm install postcss-calc
Usage
1// dependencies 2var fs = require("fs") 3var postcss = require("postcss") 4var calc = require("postcss-calc") 5 6// css to be processed 7var css = fs.readFileSync("input.css", "utf8") 8 9// process css 10var output = postcss() 11 .use(calc()) 12 .process(css) 13 .css
Example (with PostCSS Custom Properties enabled as well):
1// dependencies 2var fs = require("fs") 3var postcss = require("postcss") 4var customProperties = require("postcss-custom-properties") 5var calc = require("postcss-calc") 6 7// css to be processed 8var css = fs.readFileSync("input.css", "utf8") 9 10// process css 11var output = postcss() 12 .use(customProperties()) 13 .use(calc()) 14 .process(css) 15 .css
Using this input.css
:
1:root { 2 --main-font-size: 16px; 3} 4 5body { 6 font-size: var(--main-font-size); 7} 8 9h1 { 10 font-size: calc(var(--main-font-size) * 2); 11 height: calc(100px - 2em); 12 margin-bottom: calc( 13 var(--main-font-size) 14 * 1.5 15 ) 16}
you will get:
1body { 2 font-size: 16px 3} 4 5h1 { 6 font-size: 32px; 7 height: calc(100px - 2em); 8 margin-bottom: 24px 9}
Checkout tests for more examples.
Options
precision
(default: 5
)
Allow you to define the precision for decimal numbers.
1var out = postcss() 2 .use(calc({precision: 10})) 3 .process(css) 4 .css
preserve
(default: false
)
Allow you to preserve calc() usage in output so browsers will handle decimal precision themselves.
1var out = postcss() 2 .use(calc({preserve: true})) 3 .process(css) 4 .css
warnWhenCannotResolve
(default: false
)
Adds warnings when calc() are not reduced to a single value.
1var out = postcss() 2 .use(calc({warnWhenCannotResolve: true})) 3 .process(css) 4 .css
mediaQueries
(default: false
)
Allows calc() usage as part of media query declarations.
1var out = postcss() 2 .use(calc({mediaQueries: true})) 3 .process(css) 4 .css
selectors
(default: false
)
Allows calc() usage as part of selectors.
1var out = postcss() 2 .use(calc({selectors: true})) 3 .process(css) 4 .css
Example:
1div[data-size="calc(3*3)"] { 2 width: 100px; 3}
Contributing
Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature.
1git clone git@github.com:postcss/postcss-calc.git 2git checkout -b patch-1 3npm install 4npm test
Changelog
License
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
GitHub workflow tokens follow principle of least privilege
Details
- Info: found token with 'none' permissions: .github/workflows/test.yml:1
- Info: no jobLevel write permissions found
Reason
13 commit(s) and 5 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
3 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Reason
Found 3/25 approved changesets -- score normalized to 1
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/postcss/postcss-calc/test.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/postcss/postcss-calc/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/postcss/postcss-calc/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:33: update your workflow using https://app.stepsecurity.io/secureworkflow/postcss/postcss-calc/test.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:34: update your workflow using https://app.stepsecurity.io/secureworkflow/postcss/postcss-calc/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:38: update your workflow using https://app.stepsecurity.io/secureworkflow/postcss/postcss-calc/test.yml/master?enable=pin
- Info: 0 out of 4 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 27 are checked with a SAST tool
Score
5.1
/10
Last Scanned on 2025-01-27
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