@kcuf/mere-color
Version:
Mere color utils for generating, manipulation, a11y purposes.
24 lines • 687 B
JavaScript
import _toArray from "@babel/runtime/helpers/toArray";
/**
* Modern format
*
* - hsl(255 10 20)
* - hsl(100% 10% 20)
* - hsl(100% 10% 20% / 0.2)
* - hsl(100% 10% 20% / 20%)
* - hsla(255 0 0 / 0.2)
* - hsla(100% 0 0 / 0.2)
* - hsla(255 0 0 / 20%)
* - hsla(100% 0 0 / 20%)
*/
var REG_HSL_MATCHER_MODERN = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
export default function matchHsl(input) {
var arr = REG_HSL_MATCHER_MODERN.exec(input.trim());
if (!arr) {
return null;
}
var _arr = _toArray(arr),
rest = _arr.slice(1);
return rest;
}
//# sourceMappingURL=match-hsl.js.map