Skip to content

Instantly share code, notes, and snippets.

@maradondt
Last active November 22, 2022 08:46
Show Gist options
  • Save maradondt/06770fd0f1caf04926cfb8552d787c0c to your computer and use it in GitHub Desktop.
Save maradondt/06770fd0f1caf04926cfb8552d787c0c to your computer and use it in GitHub Desktop.
generate gray colors
export interface Color {
50: string;
100: string;
200: string;
300: string;
400: string;
500: string;
600: string;
700: string;
800: string;
900: string;
}
export const generateGrayColors = (): Color => {
return Array(10)
.fill((i: number) => (i === 0 ? 0.05 : '0.' + i))
.map((f, i) => f(i))
.reduce((acc, label) => {
return { ...acc, [label * 1000]: `hsl(0deg, 0%, ${(1 - Number(label)) * 100}%)` };
}, {} as Record<string, string>);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment