Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@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
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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.