IOPaint/lama_cleaner/app/src/components/Settings/NumberInputSetting.tsx

66 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-04-15 18:11:51 +02:00
import React from 'react'
import NumberInput from '../shared/NumberInput'
import SettingBlock from './SettingBlock'
interface NumberInputSettingProps {
title: string
2022-09-15 16:21:27 +02:00
allowFloat?: boolean
2022-07-18 15:20:52 +02:00
desc?: string
2022-04-15 18:11:51 +02:00
value: string
suffix?: string
2022-09-15 16:21:27 +02:00
width?: number
widthUnit?: string
disable?: boolean
2022-04-15 18:11:51 +02:00
onValue: (val: string) => void
}
function NumberInputSetting(props: NumberInputSettingProps) {
2022-09-15 16:21:27 +02:00
const {
title,
allowFloat,
desc,
value,
suffix,
onValue,
width,
widthUnit,
disable,
} = props
2022-04-15 18:11:51 +02:00
return (
<SettingBlock
className="sub-setting-block"
title={title}
2022-07-18 15:20:52 +02:00
desc={desc}
2022-04-15 18:11:51 +02:00
input={
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
gap: '8px',
}}
>
<NumberInput
2022-09-15 16:21:27 +02:00
allowFloat={allowFloat}
style={{ width: `${width}${widthUnit}` }}
2022-04-15 18:11:51 +02:00
value={`${value}`}
2022-09-15 16:21:27 +02:00
disabled={disable}
2022-04-15 18:11:51 +02:00
onValue={onValue}
/>
{suffix && <span>{suffix}</span>}
</div>
}
/>
)
}
2022-09-15 16:21:27 +02:00
NumberInputSetting.defaultProps = {
allowFloat: false,
width: 80,
widthUnit: 'px',
disable: false,
}
2022-04-15 18:11:51 +02:00
export default NumberInputSetting