import Color from "color";
import { ColorScale } from "./types";

export function generateColorScale(baseColor: string): ColorScale {
    const color = Color(baseColor);
    const steps = [-0.4, -0.32, -0.24, -0.16, -0.08, 0, 0.08, 0.16, 0.24, 0.32, 0.4];
    const keys = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];

    const scale = Object.fromEntries(
        keys.map((key, index) => [
            key,
            color.lighten(-steps[index]).rgb().string()
        ])
    ) as ColorScale;

    return {
        ...scale,
        DEFAULT: scale[500]
    };
}
export function withAlpha(color: string, alpha: number): string {

    return Color(color).alpha(alpha).toString();
}
