1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-28 22:26:41 +07:00

add eslint-plugin-prettier

This commit is contained in:
Fedor Katurov 2025-01-24 17:51:59 +07:00
parent 0e4d2bf44d
commit ba0604ab9d
69 changed files with 419 additions and 249 deletions

View file

@ -1,9 +1,19 @@
import { adjustHue, darken, desaturate, parseToHsla, transparentize } from 'color2k';
import {
adjustHue,
darken,
desaturate,
parseToHsla,
transparentize,
} from 'color2k';
import { DEFAULT_DOMINANT_COLOR } from '~/constants/node';
import { stringToColour } from '~/utils/dom';
export const normalizeBrightColor = (color?: string, saturationExp = 3, lightnessExp = 3) => {
export const normalizeBrightColor = (
color?: string,
saturationExp = 3,
lightnessExp = 3,
) => {
if (!color) {
return '';
}
@ -12,12 +22,23 @@ export const normalizeBrightColor = (color?: string, saturationExp = 3, lightnes
const saturation = hsla[1];
const lightness = hsla[2];
const desaturated = saturationExp > 1 ? desaturate(color, saturation ** saturationExp) : color;
return lightnessExp > 1 ? darken(desaturated, lightness ** lightnessExp) : desaturated;
const desaturated =
saturationExp > 1 ? desaturate(color, saturation ** saturationExp) : color;
return lightnessExp > 1
? darken(desaturated, lightness ** lightnessExp)
: desaturated;
};
export const generateColorTriplet = (val: string, saturation: number, lightness: number) => {
const color = normalizeBrightColor(stringToColour(val), saturation, lightness);
export const generateColorTriplet = (
val: string,
saturation: number,
lightness: number,
) => {
const color = normalizeBrightColor(
stringToColour(val),
saturation,
lightness,
);
return [
color,
@ -31,9 +52,13 @@ export const generateGradientFromColor = (
saturation = 3,
lightness = 3,
angle = 155,
opacity = 1
opacity = 1,
) => {
const [first, second, third] = generateColorTriplet(val, saturation, lightness).map(it => {
const [first, second, third] = generateColorTriplet(
val,
saturation,
lightness,
).map((it) => {
if (opacity > 1 || opacity < 0) {
return it;
}