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

Method toString

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

Source from the content-addressed store, hash-verified

668 }
669
670 toString(format: ColorFormat | 'css' = 'css') {
671 switch (format) {
672 case 'hex':
673 return this.toRGB().toString('hex');
674 case 'hexa':
675 return this.toRGB().toString('hexa');
676 case 'hsl':
677 return `hsl(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%)`;
678 case 'css':
679 case 'hsla':
680 return `hsla(${this.hue}, ${toFixedNumber(this.saturation, 2)}%, ${toFixedNumber(this.lightness, 2)}%, ${this.alpha})`;
681 default:
682 return this.toFormat(format).toString(format);
683 }
684 }
685 toFormat(format: ColorFormat): IColor {
686 switch (format) {
687 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