diff --git a/packages/suika/src/components/Cards/ElementsInfoCard/ElementsInfoCard.tsx b/packages/suika/src/components/Cards/ElementsInfoCard/ElementsInfoCard.tsx index df9bff68..267f2430 100644 --- a/packages/suika/src/components/Cards/ElementsInfoCard/ElementsInfoCard.tsx +++ b/packages/suika/src/components/Cards/ElementsInfoCard/ElementsInfoCard.tsx @@ -109,7 +109,7 @@ export const ElementsInfoCards: FC = () => { { + onChange={(newVal) => { execCommand(item.key, newVal); }} /> @@ -120,7 +120,7 @@ export const ElementsInfoCards: FC = () => { { + onChange={(newVal) => { execCommand(item.key, newVal); }} /> @@ -131,7 +131,7 @@ export const ElementsInfoCards: FC = () => { { + onChange={(newVal) => { execCommand(item.key, newVal); }} /> @@ -143,7 +143,7 @@ export const ElementsInfoCards: FC = () => { { + onChange={(newVal) => { execCommand(item.key, newVal); }} /> @@ -159,7 +159,7 @@ const NumAttrInput: FC<{ min?: number; max?: number; value: string | number; - onBlur: (newValue: number) => void; + onChange: (newValue: number) => void; suffixValue?: string; uiType: string; }> = (props) => { @@ -170,7 +170,7 @@ const NumAttrInput: FC<{ value={props.value} min={props.min} max={props.max} - onBlur={props.onBlur} + onChange={props.onChange} /> ); } else { @@ -180,7 +180,7 @@ const NumAttrInput: FC<{ value={props.value} min={props.min} max={props.max} - onBlur={props.onBlur} + onChange={props.onChange} suffixValue={props.suffixValue} /> ); diff --git a/packages/suika/src/components/Cards/LayerInfoCard/LayerInfoCard.tsx b/packages/suika/src/components/Cards/LayerInfoCard/LayerInfoCard.tsx index 83481dd1..cf3d1bdf 100644 --- a/packages/suika/src/components/Cards/LayerInfoCard/LayerInfoCard.tsx +++ b/packages/suika/src/components/Cards/LayerInfoCard/LayerInfoCard.tsx @@ -63,7 +63,7 @@ export const LayerInfoCard: FC = () => { value={opacity} min={0} max={1} - onBlur={recordOpacityChange} + onChange={recordOpacityChange} /> diff --git a/packages/suika/src/components/Cards/PaintCard/PaintCard.scss b/packages/suika/src/components/Cards/PaintCard/PaintCard.scss index 8b4e2649..c2079176 100644 --- a/packages/suika/src/components/Cards/PaintCard/PaintCard.scss +++ b/packages/suika/src/components/Cards/PaintCard/PaintCard.scss @@ -5,6 +5,22 @@ justify-content: space-between; align-items: center; margin: 0 8px; + + .fill-item-left { + display: flex; + align-items: center; + + .suika-custom-ruler-input-box { + margin-right: 0; + } + + .paint-card-alpha-input { + width: 45px; + margin-left: 0; + padding-left: 4px; + } + } + .color-block { margin: 8px 4px 8px 7px; width: 16px; diff --git a/packages/suika/src/components/Cards/PaintCard/PaintCard.tsx b/packages/suika/src/components/Cards/PaintCard/PaintCard.tsx index 966f7657..cb3e03de 100644 --- a/packages/suika/src/components/Cards/PaintCard/PaintCard.tsx +++ b/packages/suika/src/components/Cards/PaintCard/PaintCard.tsx @@ -19,6 +19,7 @@ import { type FC, useState } from 'react'; import { PaintPicker } from '../../ColorPicker/PaintPicker'; import { ColorHexInput } from '../../input/ColorHexInput'; +import { PercentInput } from '../../input/PercentInput'; import { BaseCard } from '../BaseCard'; const isNearWhite = (rgba: IRGBA, threshold = 85) => { @@ -112,37 +113,58 @@ export const PaintCard: FC = ({ if (paint.type === PaintType.Solid) { return (
- { - setActiveIndex(index); - }} - /> - } - value={parseRGBToHex(paint.attrs)} - onBlur={(newHex) => { - const rgb = parseHexToRGB(newHex); +
+ { + setActiveIndex(index); + }} + /> + } + value={parseRGBToHex(paint.attrs)} + onChange={(newHex) => { + const rgb = parseHexToRGB(newHex); - if (rgb) { - const newSolidPaint: PaintSolid = { - type: PaintType.Solid, - attrs: { - ...rgb, - a: paint.attrs.a, + if (rgb) { + const newSolidPaint: PaintSolid = { + type: PaintType.Solid, + attrs: { + ...rgb, + a: paint.attrs.a, + }, + }; + onChangeComplete(newSolidPaint, index); + } + }} + /> + {/* alpha input */} + { + onChangeComplete( + { + ...paint, + attrs: { + ...paint.attrs, + a: val, + }, }, - }; - onChangeComplete(newSolidPaint, index); - } - }} - /> + index, + ); + }} + /> +
onDelete(index)}> diff --git a/packages/suika/src/components/Cards/StrokeCard/StrokeCard.tsx b/packages/suika/src/components/Cards/StrokeCard/StrokeCard.tsx index 2ed48f4d..36835b93 100644 --- a/packages/suika/src/components/Cards/StrokeCard/StrokeCard.tsx +++ b/packages/suika/src/components/Cards/StrokeCard/StrokeCard.tsx @@ -213,7 +213,7 @@ export const StrokeCard: FC = () => { } value={strokeWidth} min={0} - onBlur={updateStrokeWidth} + onChange={updateStrokeWidth} />
} diff --git a/packages/suika/src/components/ColorPicker/PaintPicker/PaintPicker.scss b/packages/suika/src/components/ColorPicker/PaintPicker/PaintPicker.scss index 1c05b043..248c6567 100644 --- a/packages/suika/src/components/ColorPicker/PaintPicker/PaintPicker.scss +++ b/packages/suika/src/components/ColorPicker/PaintPicker/PaintPicker.scss @@ -2,9 +2,9 @@ border-radius: 4px; background-color: #fff; - box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.08), 0px 10px 24px rgba(0, 0, 0, 0.18), - 0px 2px 5px rgba(0, 0, 0, 0.15), 0px 2px 14px rgba(0, 0, 0, 0.15), - 0px 0px 0px 0.5px rgba(0, 0, 0, 0.2); + // box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.08), 0px 10px 24px rgba(0, 0, 0, 0.18), + // 0px 2px 5px rgba(0, 0, 0, 0.15), 0px 2px 14px rgba(0, 0, 0, 0.15), + // 0px 0px 0px 0.5px rgba(0, 0, 0, 0.2); .sketch-picker { box-shadow: none !important; diff --git a/packages/suika/src/components/input/ColorHexInput.tsx b/packages/suika/src/components/input/ColorHexInput.tsx index eab066d7..8994f290 100644 --- a/packages/suika/src/components/input/ColorHexInput.tsx +++ b/packages/suika/src/components/input/ColorHexInput.tsx @@ -5,11 +5,11 @@ import CustomRuleInput from './CustomRuleInput'; interface IProps { value: string; - onBlur: (newValue: string) => void; + onChange: (newValue: string) => void; prefix?: React.ReactNode; } -export const ColorHexInput: FC = ({ value, onBlur, prefix }) => { +export const ColorHexInput: FC = ({ value, onChange, prefix }) => { const inputRef = useRef(null); useEffect(() => { @@ -31,7 +31,7 @@ export const ColorHexInput: FC = ({ value, onBlur, prefix }) => { return str; }} value={value} - onBlur={(newVal) => onBlur(newVal)} + onChange={(newVal) => onChange(newVal)} /> ); }; diff --git a/packages/suika/src/components/input/CustomRuleInput/index.tsx b/packages/suika/src/components/input/CustomRuleInput/index.tsx index 098404cb..928ebd98 100644 --- a/packages/suika/src/components/input/CustomRuleInput/index.tsx +++ b/packages/suika/src/components/input/CustomRuleInput/index.tsx @@ -1,20 +1,18 @@ import './style.scss'; +import classNames from 'classnames'; import React, { type FC, useEffect, useRef } from 'react'; interface ICustomRuleInputProps { parser: (newValue: string, preValue: string | number) => string | false; value: string | number; - onBlur: (newValue: string) => void; + onChange: (newValue: string) => void; prefix?: React.ReactNode; + classNames?: string[]; } -const CustomRuleInput: FC = ({ - value, - onBlur, - parser, - prefix, -}) => { +const CustomRuleInput: FC = (props) => { + const { value, onChange, parser, prefix } = props; const inputRef = useRef(null); const isActive = useRef(false); @@ -25,7 +23,9 @@ const CustomRuleInput: FC = ({ }, [value]); return ( -
+
{prefix &&
{prefix}
} = ({ const newValue = parser(str, value); if (newValue !== false) { e.target.value = String(newValue); - onBlur(newValue); + onChange(newValue); } else { e.target.value = String(value); } diff --git a/packages/suika/src/components/input/NumberInput.tsx b/packages/suika/src/components/input/NumberInput.tsx index 53ea077a..b7d791cd 100644 --- a/packages/suika/src/components/input/NumberInput.tsx +++ b/packages/suika/src/components/input/NumberInput.tsx @@ -11,20 +11,24 @@ interface INumberInputProps { value: string | number; min?: number; max?: number; - onBlur: (newValue: number) => void; + onChange: (newValue: number) => void; prefix?: React.ReactNode; /** suffix string after input value, such like ° => 12.34° */ suffixValue?: string; + classNames?: string[]; } -const NumberInput: FC = ({ - value, - min = -Infinity, - max = Infinity, - onBlur, - prefix, - suffixValue = '', -}) => { +const NumberInput: FC = (props) => { + const { + value, + min = -Infinity, + max = Infinity, + onChange, + prefix, + suffixValue = '', + classNames, + } = props; + const inputRef = useRef(null); useEffect(() => { @@ -52,7 +56,8 @@ const NumberInput: FC = ({ } }} value={isNumberStr(String(value)) ? value + suffixValue : value} - onBlur={(newVal) => onBlur(Number(newVal))} + classNames={classNames} + onChange={(newVal) => onChange(Number(newVal))} /> ); }; diff --git a/packages/suika/src/components/input/PercentInput.tsx b/packages/suika/src/components/input/PercentInput.tsx index 996a1027..42946827 100644 --- a/packages/suika/src/components/input/PercentInput.tsx +++ b/packages/suika/src/components/input/PercentInput.tsx @@ -7,7 +7,8 @@ interface Props { value: string | number; min?: number; max?: number; - onBlur: (value: number) => void; + onChange: (value: number) => void; + classNames?: string[]; } export const PercentInput: FC = (props) => { @@ -15,7 +16,7 @@ export const PercentInput: FC = (props) => { typeof props.value === 'number' ? Number((props.value * 100).toFixed(2)) : props.value; - const onBlur = (value: number) => props.onBlur(value / 100); + const onChange = (value: number) => props.onChange(value / 100); const min = props.min === undefined ? undefined : props.min * 100; const max = props.max === undefined ? undefined : props.max * 100; @@ -26,8 +27,9 @@ export const PercentInput: FC = (props) => { min={min} max={max} suffixValue="%" - onBlur={onBlur} + onChange={onChange} prefix={props.prefix} + classNames={props.classNames} /> ); };