Installations
npm install @gravitylabs/css-calc-transform
Developer Guide
Typescript
No
Module System
CommonJS
Score
74.7
Supply Chain
99.4
Quality
75.2
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
kristerkari
Download Statistics
Total Downloads
416
Last Day
2
Last Week
3
Last Month
12
Last Year
214
GitHub Statistics
13 Stars
266 Commits
1 Forks
3 Watching
8 Branches
1 Contributors
Bundle Size
6.31 kB
Minified
2.27 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.0
Package Id
@gravitylabs/css-calc-transform@1.0.0
Unpacked Size
272.72 kB
Size
85.97 kB
File Count
35
Total Downloads
Cumulative downloads
Total Downloads
416
Last day
100%
2
Compared to previous day
Last week
0%
3
Compared to previous week
Last month
140%
12
Compared to previous month
Last year
164.2%
214
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
CSS calc() to pixels transform
Tiny Javascript library to transform CSS properties with CSS calc() function values to pixels based on window and element dimensions.
Install
1yarn add --save css-calc-transform
or
1npm install --save css-calc-transform
Usage
Pixels
1import { transform } from "css-calc-transform"; 2 3transform({ 4 prop: "width", 5 value: "calc(10px + (100px / 3.5))" 6}); 7 8↓ ↓ ↓ ↓ ↓ ↓ 9 1038.57142857142857
Percentages
1import { transform } from "css-calc-transform"; 2 3const parentElementDimensions = { 4 width: 480, 5 height: 100 6}; 7 8transform({ 9 prop: "width", 10 value: "calc(100% - 10px)", 11 parent: parentElementDimensions 12}); 13 14↓ ↓ ↓ ↓ ↓ ↓ 15 16470
Viewport units
1import { transform } from "css-calc-transform"; 2 3const windowDimensions = { 4 width: 480, 5 height: 640 6}; 7 8transform({ 9 prop: "height", 10 value: "calc(50vh + 10px)", 11 win: windowDimensions 12}); 13 14↓ ↓ ↓ ↓ ↓ ↓ 15 16330
rem unit
1import { transform } from "css-calc-transform"; 2 3transform({ 4 prop: "fontSize", 5 value: "calc(2rem + 1px)", 6}); 7 8↓ ↓ ↓ ↓ ↓ ↓ 9 1033
em unit
When em units are used on font-size, the size is relative to the font-size of the parent.
When used on other properties, it’s relative to the font-size of the element itself.
https://www.digitalocean.com/community/tutorials/css-rem-vs-em-units
1import { transform } from "css-calc-transform"; 2 3transform({ 4 prop: "fontSize", 5 value: "calc(2em + 1px)", 6 parent: { 7 font: { 8 size: 16 9 } 10 } 11}); 12 13↓ ↓ ↓ ↓ ↓ ↓ 14 1533
1import { transform } from "css-calc-transform"; 2 3transform({ 4 prop: "height", 5 value: "calc(10px + 2em)", 6 font: { 7 size: 16 8 } 9}); 10 11↓ ↓ ↓ ↓ ↓ ↓ 12 1342
min(), max(), clamp()
1import { transform } from "css-calc-transform"; 2 3transform({ 4 prop: "height", 5 value: "calc(min(2px, 3px) + clamp(100px, 150px, 200px) + max(1px, 2px))", 6}); 7 8↓ ↓ ↓ ↓ ↓ ↓ 9 10154
More examples
For more examples, please have a look at the tests.
Dependencies
- None
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
SAST tool detected but not run on all commits
Details
- Info: SAST configuration detected: CodeQL
- Warn: 0 commits out of 30 are checked with a SAST tool
Reason
6 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql-analysis.yml:28
- Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql-analysis.yml:29
- Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1
- Warn: no topLevel permission defined: .github/workflows/test.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/kristerkari/css-calc-transform/codeql-analysis.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/kristerkari/css-calc-transform/codeql-analysis.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:59: update your workflow using https://app.stepsecurity.io/secureworkflow/kristerkari/css-calc-transform/codeql-analysis.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:72: update your workflow using https://app.stepsecurity.io/secureworkflow/kristerkari/css-calc-transform/codeql-analysis.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/kristerkari/css-calc-transform/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/kristerkari/css-calc-transform/test.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/kristerkari/css-calc-transform/test.yml/master?enable=pin
- Info: 0 out of 6 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
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'
Score
3.7
/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