postcss-js-mixins
Advanced tools
Comparing version 2.2.1 to 2.3.0
@@ -29,4 +29,3 @@ const tinycolor = require('tinycolor2'); | ||
/** | ||
* Convert hex values to RGBa. Can accept both three and | ||
* size letter hex. | ||
* Convert color values to RGBa | ||
* | ||
@@ -37,22 +36,10 @@ * @param {string} color | ||
*/ | ||
function hexToRgba(color, opacity = false) { | ||
color = color.replace('#', ''); | ||
function toRgba(color, opacity = false) { | ||
color = tinycolor(color); | ||
if (opacity !== false) { | ||
opacity = calcOpacity(opacity); | ||
} | ||
if (color.length === 3) { | ||
color = color[0] + color[0] + color[1] + color[1] + color[2] + color[2]; | ||
} | ||
let r = parseInt(color.substring(0,2), 16), | ||
g = parseInt(color.substring(2,4), 16), | ||
b = parseInt(color.substring(4,6), 16); | ||
if (opacity) { | ||
return `rgba(${r}, ${g}, ${b}, ${opacity})`; | ||
color.setAlpha(calcOpacity(opacity)); | ||
} | ||
return `rgb(${r}, ${g}, ${b})`; | ||
return color.toRgbString(); | ||
} | ||
@@ -238,3 +225,2 @@ | ||
calcOpacity: calcOpacity, | ||
hexToRgba: hexToRgba, | ||
isColor: isColor, | ||
@@ -253,4 +239,5 @@ isEmpty: isEmpty, | ||
toPercentage: toPercentage, | ||
toRgba: toRgba, | ||
type: type, | ||
unit: unit | ||
}; |
{ | ||
"name": "postcss-js-mixins", | ||
"version": "2.2.1", | ||
"version": "2.3.0", | ||
"description": "PostCSS plugin for custom mixin syntax", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16825
451