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

Method parse

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

clampFunction · 0.90
normalizeHueFunction · 0.85

Tested by

no test coverage detected