UNPKG

@kcuf/mere-color

Version:

Mere color utils for generating, manipulation, a11y purposes.

24 lines 665 B
import _toArray from "@babel/runtime/helpers/toArray"; /** * Modern format * * - rgb(255 0 0) * - rgb(100% 20 128) * - rgb(100% 0 0 / 0.2) * - rgb(100% 0 0 / 20%) * - rgba(255 0 0 / 0.2) * - rgba(100% 0 0 / 0.2) * - rgba(255 0 0 / 20%) * - rgba(100% 0 0 / 20%) */ var REG_RGB_MATCHER_MODERN = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; export default function matchRgb(input) { var arr = REG_RGB_MATCHER_MODERN.exec(input.trim()); if (!arr) { return null; } var _arr = _toArray(arr), rest = _arr.slice(1); return rest; } //# sourceMappingURL=match-rgb.js.map