mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-19 07:56:02 +01:00
feat(web/input): allow defining icon for number row field
This commit is contained in:
@@ -27,6 +27,7 @@ export const debugInput = () => {
|
|||||||
default: 12,
|
default: 12,
|
||||||
min: 3,
|
min: 3,
|
||||||
max: 10,
|
max: 10,
|
||||||
|
icon: 'receipt',
|
||||||
},
|
},
|
||||||
{ type: 'slider', label: 'Slide bar', min: 10, max: 50, step: 2 },
|
{ type: 'slider', label: 'Slide bar', min: 10, max: 50, step: 2 },
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const InputField: React.FC<Props> = (props) => {
|
|||||||
<Text>{props.row.label}</Text>
|
<Text>{props.row.label}</Text>
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
{props.row.icon && (
|
{props.row.icon && (
|
||||||
<InputLeftElement pointerEvents="none" children={<FontAwesomeIcon icon={props.row.icon} />} />
|
<InputLeftElement pointerEvents="none" children={<FontAwesomeIcon icon={props.row.icon} fixedWidth />} />
|
||||||
)}
|
)}
|
||||||
<Input
|
<Input
|
||||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => props.handleChange(e.target.value, props.index)}
|
onChange={(e: React.ChangeEvent<HTMLInputElement>) => props.handleChange(e.target.value, props.index)}
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ import {
|
|||||||
NumberInputStepper,
|
NumberInputStepper,
|
||||||
NumberIncrementStepper,
|
NumberIncrementStepper,
|
||||||
NumberDecrementStepper,
|
NumberDecrementStepper,
|
||||||
|
InputLeftElement,
|
||||||
} from '@chakra-ui/react';
|
} from '@chakra-ui/react';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { INumber } from '../../../interfaces/dialog';
|
import { INumber } from '../../../interfaces/dialog';
|
||||||
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
row: INumber;
|
row: INumber;
|
||||||
@@ -30,7 +32,10 @@ const NumberField: React.FC<Props> = (props) => {
|
|||||||
min={props.row.min}
|
min={props.row.min}
|
||||||
max={props.row.max}
|
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>
|
<NumberInputStepper>
|
||||||
<NumberIncrementStepper />
|
<NumberIncrementStepper />
|
||||||
<NumberDecrementStepper />
|
<NumberDecrementStepper />
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export interface INumber {
|
|||||||
label: string;
|
label: string;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
default?: number;
|
default?: number;
|
||||||
|
icon?: IconProp;
|
||||||
min?: number;
|
min?: number;
|
||||||
max?: number;
|
max?: number;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user