mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
fixed color calculation hook
This commit is contained in:
parent
df75624a2f
commit
a09c129d04
1 changed files with 11 additions and 12 deletions
|
@ -4,16 +4,15 @@ import { useColorFromString } from '~/utils/hooks/useColorFromString';
|
|||
import { normalizeBrightColor } from '~/utils/color';
|
||||
|
||||
export const useColorGradientFromString = (val?: string, saturation = 3, lightness = 3) => {
|
||||
const color = useColorFromString(val, saturation, lightness);
|
||||
return useMemo(
|
||||
() =>
|
||||
val
|
||||
? `linear-gradient(155deg, ${color}, ${normalizeBrightColor(
|
||||
adjustHue(color, 80),
|
||||
saturation,
|
||||
lightness
|
||||
)})`
|
||||
: '',
|
||||
[color]
|
||||
);
|
||||
return useMemo(() => {
|
||||
if (!val) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const color = useColorFromString(val, saturation, lightness);
|
||||
const second = normalizeBrightColor(adjustHue(color, 45), saturation, lightness);
|
||||
const third = normalizeBrightColor(adjustHue(color, 90), saturation, lightness);
|
||||
|
||||
return `linear-gradient(155deg, ${color}, ${second}, ${third})`;
|
||||
}, [val]);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue