mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
added lab post lines
This commit is contained in:
parent
a553a06ac5
commit
bf16c0ca22
6 changed files with 33 additions and 5 deletions
|
@ -10,6 +10,6 @@ export const normalizeBrightColor = (color?: string, saturationExp = 3, lightnes
|
|||
const saturation = hsla[1];
|
||||
const lightness = hsla[2];
|
||||
|
||||
const desaturated = desaturate(color, saturation ** saturationExp);
|
||||
return darken(desaturated, lightness ** lightnessExp);
|
||||
const desaturated = saturationExp > 1 ? desaturate(color, saturation ** saturationExp) : color;
|
||||
return lightnessExp > 1 ? darken(desaturated, lightness ** lightnessExp) : desaturated;
|
||||
};
|
||||
|
|
|
@ -3,7 +3,12 @@ import { adjustHue } from 'color2k';
|
|||
import { normalizeBrightColor } from '~/utils/color';
|
||||
import { stringToColour } from '~/utils/dom';
|
||||
|
||||
export const useColorGradientFromString = (val?: string, saturation = 3, lightness = 3) =>
|
||||
export const useColorGradientFromString = (
|
||||
val?: string,
|
||||
saturation = 3,
|
||||
lightness = 3,
|
||||
angle = 155
|
||||
) =>
|
||||
useMemo(() => {
|
||||
if (!val) {
|
||||
return '';
|
||||
|
@ -13,5 +18,5 @@ export const useColorGradientFromString = (val?: string, saturation = 3, lightne
|
|||
const second = normalizeBrightColor(adjustHue(color, 45), saturation, lightness);
|
||||
const third = normalizeBrightColor(adjustHue(color, 90), saturation, lightness);
|
||||
|
||||
return `linear-gradient(155deg, ${color}, ${second}, ${third})`;
|
||||
return `linear-gradient(${angle}deg, ${color}, ${second}, ${third})`;
|
||||
}, [val]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue