MCPcopy Create free account
hub / github.com/adobe/react-spectrum / parse

Method parse

packages/react-stately/src/color/Color.ts:662–668  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

660 }
661
662 static parse(value: string): HSLColor | void {
663 let m: RegExpMatchArray | null;
664 if ((m = value.match(HSL_REGEX))) {
665 const [h, s, l, a] = (m[1] ?? m[2]).split(',').map(n => Number(n.trim().replace('%', '')));
666 return new HSLColor(normalizeHue(h), clamp(s, 0, 100), clamp(l, 0, 100), clamp(a ?? 1, 0, 1));
667 }
668 }
669
670 toString(format: ColorFormat | 'css' = 'css') {
671 switch (format) {

Callers

nothing calls this directly

Calls 2

clampFunction · 0.90
normalizeHueFunction · 0.85

Tested by

no test coverage detected