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

Method parse

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

Source from the content-addressed store, hash-verified

505 }
506
507 static parse(value: string): HSBColor | void {
508 let m: RegExpMatchArray | null;
509 if ((m = value.match(HSB_REGEX))) {
510 const [h, s, b, a] = (m[1] ?? m[2]).split(',').map(n => Number(n.trim().replace('%', '')));
511 return new HSBColor(normalizeHue(h), clamp(s, 0, 100), clamp(b, 0, 100), clamp(a ?? 1, 0, 1));
512 }
513 }
514
515 toString(format: ColorFormat | 'css' = 'css') {
516 switch (format) {

Callers

nothing calls this directly

Calls 2

clampFunction · 0.90
normalizeHueFunction · 0.85

Tested by

no test coverage detected