36 lines
901 B
JavaScript
36 lines
901 B
JavaScript
export function djb2a(string) {
|
|
let hash = 5381;
|
|
for (let i = 0; i < string.length; i++)
|
|
hash = ((hash << 5) + hash) ^ string.charCodeAt(i);
|
|
return hash >>> 0;
|
|
}
|
|
|
|
export function useColor(value) {
|
|
return '#' + colors[djb2a(value || '') % colors.length];
|
|
}
|
|
|
|
const colors = [
|
|
'b5b941', // Yellow
|
|
'ae9681', // Peach
|
|
'd78767', // Salmon
|
|
'cc7000', // Orange bright
|
|
'e2553d', // Coral
|
|
'8B0000', // Red dark
|
|
'de4362', // Red crimson
|
|
'FF1493', // Ping intense
|
|
'be39a2', // Pink light
|
|
'b754cf', // Purple middle
|
|
'a87ba8', // Pink
|
|
'8a69cd', // Blue lavender
|
|
'ab20ab', // Purple dark
|
|
'00b5b8', // Turquoise
|
|
'1fa8a1', // Green ocean
|
|
'5681cf', // Blue steel
|
|
'3399fe', // Blue sky
|
|
'6d9c3e', // Green chartreuse
|
|
'51bb51', // Green lime
|
|
'518b8b', // Gray board
|
|
'7e7e7e', // Gray
|
|
'5d5d5d', // Gray dark
|
|
];
|