()
| 86 | |
| 87 | let value = state.getDisplayColor(); |
| 88 | let generateBackground = () => { |
| 89 | let to: string; |
| 90 | if (orientation === 'vertical') { |
| 91 | to = 'top'; |
| 92 | } else if (direction === 'ltr') { |
| 93 | to = 'right'; |
| 94 | } else { |
| 95 | to = 'left'; |
| 96 | } |
| 97 | switch (channel) { |
| 98 | case 'hue': { |
| 99 | let stops = [0, 60, 120, 180, 240, 300, 360] |
| 100 | .map(hue => value.withChannelValue('hue', hue).toString('css')) |
| 101 | .join(', '); |
| 102 | return `linear-gradient(to ${to}, ${stops})`; |
| 103 | } |
| 104 | case 'lightness': { |
| 105 | // We have to add an extra color stop in the middle so that the hue shows up at all. |
| 106 | // Otherwise it will always just be black to white. |
| 107 | let min = state.getThumbMinValue(0); |
| 108 | let max = state.getThumbMaxValue(0); |
| 109 | let start = value.withChannelValue(channel, min).toString('css'); |
| 110 | let middle = value.withChannelValue(channel, (max - min) / 2).toString('css'); |
| 111 | let end = value.withChannelValue(channel, max).toString('css'); |
| 112 | return `linear-gradient(to ${to}, ${start}, ${middle}, ${end})`; |
| 113 | } |
| 114 | case 'saturation': |
| 115 | case 'brightness': |
| 116 | case 'red': |
| 117 | case 'green': |
| 118 | case 'blue': |
| 119 | case 'alpha': { |
| 120 | let start = value.withChannelValue(channel, state.getThumbMinValue(0)).toString('css'); |
| 121 | let end = value.withChannelValue(channel, state.getThumbMaxValue(0)).toString('css'); |
| 122 | return `linear-gradient(to ${to}, ${start}, ${end})`; |
| 123 | } |
| 124 | default: |
| 125 | throw new Error('Unknown color channel: ' + channel); |
| 126 | } |
| 127 | }; |
| 128 | |
| 129 | let forcedColorAdjustNoneStyle = {forcedColorAdjust: 'none'}; |
| 130 |
no test coverage detected