change multiplier to just adding percentages

This commit is contained in:
Attila Greguss
2024-10-10 11:16:40 +01:00
parent 8954247842
commit b4f6e2fd7a
2 changed files with 40 additions and 40 deletions

View File

@ -4,9 +4,9 @@ const makePrimaryColor =
l =>
({ opacityValue }) => {
// we convert the passed in lightness value to a multiplier relative to 50% (full color)
let finalLightness = 1 + ((l - 50) / 100);
let finalLightness = (l - 50);
return (
`hsl(var(--primary-hue) var(--primary-saturation) calc(var(--primary-lightness) * ${finalLightness})` +
`hsl(var(--primary-hue) var(--primary-saturation) calc(var(--primary-lightness) ${finalLightness > 0 ? "+" : "-"} ${Math.abs(finalLightness)}%)` +
(opacityValue ? ` / ${opacityValue})` : ')')
)
}