Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
@csstools/postcss-nested-calc
Advanced tools
@csstools/postcss-nested-calc is a PostCSS plugin that allows you to use nested calc() expressions in your CSS. This can simplify complex calculations and make your CSS more maintainable.
Nested calc() expressions
This feature allows you to nest calc() expressions within each other. The plugin will resolve these nested calculations into a single calc() expression.
/* Input CSS */
.example {
width: calc(100% - calc(50px + 10px));
}
/* Output CSS */
.example {
width: calc(100% - 60px);
}
Simplifying complex calculations
This feature simplifies complex calculations by resolving nested calc() expressions, making your CSS easier to read and maintain.
/* Input CSS */
.example {
height: calc(100vh - calc(2 * 20px + 10px));
}
/* Output CSS */
.example {
height: calc(100vh - 50px);
}
postcss-calc is another PostCSS plugin that reduces calc() references whenever it's possible. It can handle simple calculations but does not support nested calc() expressions as @csstools/postcss-nested-calc does.
postcss-advanced-variables is a PostCSS plugin that allows you to use Sass-like variables, conditionals, and loops in your CSS. While it offers more advanced features, it does not specifically focus on nested calc() expressions like @csstools/postcss-nested-calc.
npm install @csstools/postcss-nested-calc --save-dev
PostCSS Nested Calc lets you use nested calc()
expressions following the CSS Values and Units 4 specification.
.example {
order: calc(1 + calc(2 * 2));
}
/* becomes */
.example {
order: calc(1 + (2 * 2));
order: calc(1 + calc(2 * 2));
}
Add PostCSS Nested Calc to your project:
npm install postcss @csstools/postcss-nested-calc --save-dev
Use it as a PostCSS plugin:
const postcss = require('postcss');
const postcssNestedCalc = require('@csstools/postcss-nested-calc');
postcss([
postcssNestedCalc(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
The preserve
option determines whether the original notation
is preserved. By default the original values are preserved.
postcssNestedCalc({ preserve: false })
.example {
order: calc(1 + calc(2 * 2));
}
/* becomes */
.example {
order: calc(1 + (2 * 2));
}
FAQs
Use nested calc() expressions in CSS
The npm package @csstools/postcss-nested-calc receives a total of 3,088,137 weekly downloads. As such, @csstools/postcss-nested-calc popularity was classified as popular.
We found that @csstools/postcss-nested-calc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.