Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
postcss-color-rgba-fallback
Advanced tools
The postcss-color-rgba-fallback package is a PostCSS plugin that provides fallback colors for browsers that do not support RGBA colors. It automatically generates hexadecimal color fallbacks for RGBA colors in your CSS, ensuring better compatibility across different browsers.
RGBA to Hex Fallback
This feature automatically converts RGBA colors to their hexadecimal equivalents and adds them as fallbacks. This ensures that browsers that do not support RGBA can still render the color.
/* Input CSS */
body {
background: rgba(255, 0, 0, 0.5);
}
/* Output CSS */
body {
background: #ff0000;
background: rgba(255, 0, 0, 0.5);
}
The postcss-color-rgb package is a PostCSS plugin that converts RGB colors to hexadecimal. Unlike postcss-color-rgba-fallback, it does not handle alpha transparency but focuses on converting RGB values to hex.
The postcss-color-hex-alpha package is a PostCSS plugin that converts 8-digit hexadecimal colors (which include alpha transparency) to RGBA. It is somewhat the reverse of postcss-color-rgba-fallback, focusing on converting hex with alpha to RGBA.
The postcss-color-function package is a PostCSS plugin that transforms W3C CSS color function notation (like color-mod) into more compatible CSS. It offers broader functionality for color manipulation compared to postcss-color-rgba-fallback.
PostCSS plugin to transform rgba() to hexadecimal.
$ npm install postcss-color-rgba-fallback
// dependencies
var fs = require("fs")
var postcss = require("postcss")
var colorRgbaFallback = require("postcss-color-rgba-fallback")
// css to be processed
var css = fs.readFileSync("input.css", "utf8")
// process css
var output = postcss()
.use(colorRgbaFallback())
.process(css)
.css
Using this input.css
:
body {
background: rgba(153, 221, 153, 0.8);
border: solid 1px rgba(100,102,103,.3);
}
you will get:
body {
background: #99DD99;
background: rgba(153, 221, 153, 0.8);
border: solid 1px #646667;
border: solid 1px rgba(100,102,103,.3);
}
postcss-color-rgba-fallback accepts options
properties
default: [ "background-color", "background", "color", "border", "border-color", "outline", "outline-color ]
Allows you to specify your whitelist of properties. This option enables adding a fallback for one or a properties list
oldie
default: false
Set to true to enable the option and to get fallback for ie8
backgroundColor
default: null
Allows you to specify a background color to use as a base alpha matte.
Instead of cutting off the alpha channel it will blend the foreground and background.
Expects an array of rgb values:
"backgroundColor": [255, 1, 1]
Checkout tests for more examples.
Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature.
$ git clone https://github.com/postcss/postcss-color-rgba-fallback.git
$ git checkout -b patch-1
$ npm install
$ npm test
FAQs
PostCSS plugin to transform rgba() to hexadecimal
The npm package postcss-color-rgba-fallback receives a total of 159,278 weekly downloads. As such, postcss-color-rgba-fallback popularity was classified as popular.
We found that postcss-color-rgba-fallback demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.