MCPcopy Index your code
hub / github.com/adobe/react-spectrum / toString

Method toString

packages/react-stately/src/color/Color.ts:666–680  ·  view source on GitHub ↗
(format: ColorFormat | 'css' = 'css')

Source from the content-addressed store, hash-verified

664 }
665
666 toString(format: ColorFormat | 'css' = 'css') {
667 switch (format) {
668 case 'hex':
669 return this.toRGB().toString('hex');
670 case 'hexa':
671 return this.toRGB().toString('hexa');
672 case 'hsl':
673 return `hsl(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%)`;
674 case 'css':
675 case 'hsla':
676 return `hsla(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%, ${this.alpha})`;
677 default:
678 return this.toFormat(format).toString(format);
679 }
680 }
681 toFormat(format: ColorFormat): IColor {
682 switch (format) {
683 case 'hsl':

Callers

nothing calls this directly

Calls 4

toRGBMethod · 0.95
toFormatMethod · 0.95
toFixedNumberFunction · 0.90
toStringMethod · 0.65

Tested by

no test coverage detected