feat: 1.13.2

This commit is contained in:
TrèsAbhi committed 2023-10-05 11:04:46 -05:00
1 parent cb9d283f62
commit 92e35bd0ac
5 files changed
+13 -27

No files matched your search

@@ -1,5 +1,4 @@
import { Percentile } from '../../../../../constants/percentiles';
import hslToHex from '../../../../../core/node/hslToHex';
import { PERCENTILE_COLORS } from '../../../../PercentileIndicator';
export enum GlowSide {
@@ -14,8 +13,8 @@ export interface GlowProps {
export function Glow({ percentile, side }: GlowProps) {
const color = PERCENTILE_COLORS[percentile];
const color1 = hslToHex(color);
const color2 = `${color1}00`;
const color1 = color;
const color2 = `${color}00`;
const background = `linear-gradient(${
side === GlowSide.Top ? 0 : 180
-22
View File
@@ -1,22 +0,0 @@
const numberRegex = /\d+(\.\d+)?/g;
/**
* Thanks to icl7126!
* https://stackoverflow.com/a/44134328/12294756
*/
export default function hslToHex(hsl: string) {
let [h, s, l] = Array.from(hsl.matchAll(numberRegex)).map((m) =>
parseFloat(m[0]),
);
l /= 100;
const a = (s * Math.min(l, 1 - l)) / 100;
const f = (n: number) => {
const k = (n + h / 30) % 12;
const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
return Math.round(255 * color)
.toString(16)
.padStart(2, '0'); // convert to Hex and prefix "0" if needed
};
return `#${f(0)}${f(8)}${f(4)}`;
}