修正意识是错误的lodash函数使用。

This commit is contained in:
徐涛 2024-12-31 16:13:46 +08:00
parent 67beb88583
commit bfc0d3bab8

View File

@ -1,6 +1,6 @@
import { Icon } from '@iconify/react/dist/iconify.js';
import cx from 'clsx';
import { clamp, divide, floor, times, trim } from 'lodash-es';
import { clamp, divide, floor, multiply, trim } from 'lodash-es';
import { ChangeEvent, useEffect, useState } from 'react';
import { useColorFunction } from '../ColorFunctionContext';
import styles from './ColorComponentInput.module.css';
@ -50,8 +50,8 @@ export function ColorComponentInput({ color, onChange }: ColorComponentInputProp
try {
const [h, s, l] = colorFn?.represent_hsl(colorValue) ?? [0, 0, 0];
setH(floor(h, 1));
setS(floor(times(s, 100), 2));
setL(floor(times(l, 100), 2));
setS(floor(multiply(s, 100), 2));
setL(floor(multiply(l, 100), 2));
} catch (e) {
console.error('[Convert HSL]', e);
}
@ -143,8 +143,8 @@ export function ColorComponentInput({ color, onChange }: ColorComponentInputProp
setB(b);
const [h, s, l] = colorFn?.represent_hsl(color) ?? [0, 0, 0];
setH(floor(h, 1));
setS(floor(times(s, 100), 2));
setL(floor(times(l, 100), 2));
setS(floor(multiply(s, 100), 2));
setL(floor(multiply(l, 100), 2));
} catch (e) {
console.error('[Convert RGB]', e);
}