mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-17 09:01:48 -05:00
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { CompositeRangeSlider, FormControl, FormLabel } from '@invoke-ai/ui-library';
|
|
import { InformationalPopover } from 'common/components/InformationalPopover/InformationalPopover';
|
|
import { memo, useCallback } from 'react';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
type Props = {
|
|
beginEndStepPct: [number, number];
|
|
onChange: (beginEndStepPct: [number, number]) => void;
|
|
};
|
|
|
|
const formatPct = (v: number) => `${Math.round(v * 100)}%`;
|
|
const ariaLabel = ['Begin Step %', 'End Step %'];
|
|
|
|
export const BeginEndStepPct = memo(({ beginEndStepPct, onChange }: Props) => {
|
|
const { t } = useTranslation();
|
|
const onReset = useCallback(() => {
|
|
onChange([0, 1]);
|
|
}, [onChange]);
|
|
|
|
return (
|
|
<FormControl orientation="horizontal" pe={1}>
|
|
<InformationalPopover feature="controlNetBeginEnd">
|
|
<FormLabel m={0}>{t('controlnet.beginEndStepPercentShort')}</FormLabel>
|
|
</InformationalPopover>
|
|
<CompositeRangeSlider
|
|
aria-label={ariaLabel}
|
|
value={beginEndStepPct}
|
|
onChange={onChange}
|
|
onReset={onReset}
|
|
min={0}
|
|
max={1}
|
|
step={0.05}
|
|
fineStep={0.01}
|
|
minStepsBetweenThumbs={1}
|
|
formatValue={formatPct}
|
|
marks
|
|
withThumbTooltip
|
|
/>
|
|
</FormControl>
|
|
);
|
|
});
|
|
|
|
BeginEndStepPct.displayName = 'BeginEndStepPct';
|