mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-07 12:15:06 -05:00
Implement `dnd-kit` for image drag and drop - vastly simplifies logic bc we can drag and drop non-serializable data (like an `ImageDTO`) - also much prettier - also will fix conflicts with file upload via OS drag and drop, bc `dnd-kit` does not use native HTML drag and drop API - Implemented for Init image, controlnet, and node editor so far More progress on the ControlNet UI
43 lines
1.0 KiB
TypeScript
43 lines
1.0 KiB
TypeScript
import { useAppDispatch } from 'app/store/storeHooks';
|
|
import IAISlider from 'common/components/IAISlider';
|
|
import { controlNetWeightChanged } from 'features/controlNet/store/controlNetSlice';
|
|
import { memo, useCallback } from 'react';
|
|
|
|
type ParamControlNetWeightProps = {
|
|
controlNetId: string;
|
|
weight: number;
|
|
};
|
|
|
|
const ParamControlNetWeight = (props: ParamControlNetWeightProps) => {
|
|
const { controlNetId, weight } = props;
|
|
const dispatch = useAppDispatch();
|
|
|
|
const handleWeightChanged = useCallback(
|
|
(weight: number) => {
|
|
dispatch(controlNetWeightChanged({ controlNetId, weight }));
|
|
},
|
|
[controlNetId, dispatch]
|
|
);
|
|
|
|
const handleWeightReset = () => {
|
|
dispatch(controlNetWeightChanged({ controlNetId, weight: 1 }));
|
|
};
|
|
|
|
return (
|
|
<IAISlider
|
|
label="Weight"
|
|
value={weight}
|
|
onChange={handleWeightChanged}
|
|
withInput
|
|
withReset
|
|
handleReset={handleWeightReset}
|
|
withSliderMarks
|
|
min={0}
|
|
max={1}
|
|
step={0.01}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default memo(ParamControlNetWeight);
|