mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
10 lines
369 B
TypeScript
10 lines
369 B
TypeScript
import { useMemo } from 'react';
|
|
import { normalizeBrightColor } from '~/utils/color';
|
|
import { stringToColour } from '~/utils/dom';
|
|
|
|
export const useColorFromString = (val?: string, saturation = 3, lightness = 3) => {
|
|
return useMemo(
|
|
() => (val && normalizeBrightColor(stringToColour(val), saturation, lightness)) || '',
|
|
[lightness, saturation, val]
|
|
);
|
|
};
|