feat(web/input): allow defining icon for number row field

This commit is contained in:
Luke
2022-09-08 12:00:41 +02:00
parent 473a0f480d
commit b638e435ea
4 changed files with 9 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ export const debugInput = () => {
default: 12,
min: 3,
max: 10,
icon: 'receipt',
},
{ type: 'slider', label: 'Slide bar', min: 10, max: 50, step: 2 },
],

View File

@@ -22,7 +22,7 @@ const InputField: React.FC<Props> = (props) => {
<Text>{props.row.label}</Text>
<InputGroup>
{props.row.icon && (
<InputLeftElement pointerEvents="none" children={<FontAwesomeIcon icon={props.row.icon} />} />
<InputLeftElement pointerEvents="none" children={<FontAwesomeIcon icon={props.row.icon} fixedWidth />} />
)}
<Input
onChange={(e: React.ChangeEvent<HTMLInputElement>) => props.handleChange(e.target.value, props.index)}

View File

@@ -6,9 +6,11 @@ import {
NumberInputStepper,
NumberIncrementStepper,
NumberDecrementStepper,
InputLeftElement,
} from '@chakra-ui/react';
import { useEffect } from 'react';
import { INumber } from '../../../interfaces/dialog';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
interface Props {
row: INumber;
@@ -30,7 +32,10 @@ const NumberField: React.FC<Props> = (props) => {
min={props.row.min}
max={props.row.max}
>
<NumberInputField placeholder={props.row.placeholder} />
{props.row.icon && (
<InputLeftElement pointerEvents="none" children={<FontAwesomeIcon icon={props.row.icon} fixedWidth />} />
)}
<NumberInputField placeholder={props.row.placeholder} pl={props.row.icon ? '40px' : undefined} />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />

View File

@@ -27,6 +27,7 @@ export interface INumber {
label: string;
placeholder?: string;
default?: number;
icon?: IconProp;
min?: number;
max?: number;
}