diff --git a/web/src/features/dialog/InputDialog.tsx b/web/src/features/dialog/InputDialog.tsx index 78a945b..4af1280 100644 --- a/web/src/features/dialog/InputDialog.tsx +++ b/web/src/features/dialog/InputDialog.tsx @@ -3,17 +3,18 @@ import React, { FormEvent, useRef } from 'react'; import { useNuiEvent } from '../../hooks/useNuiEvent'; import { useLocales } from '../../providers/LocaleProvider'; import { fetchNui } from '../../utils/fetchNui'; -import { IInput, ICheckbox, ISelect, INumber, ISlider } from '../../interfaces/dialog'; +import { IInput, ICheckbox, ISelect, INumber, ISlider, IColorInput } from '../../interfaces/dialog'; import InputField from './components/fields/input'; import CheckboxField from './components/fields/checkbox'; import SelectField from './components/fields/select'; import NumberField from './components/fields/number'; import SliderField from './components/fields/slider'; import { useFieldArray, useForm } from 'react-hook-form'; +import ColorField from './components/fields/color'; export interface InputProps { heading: string; - rows: Array; + rows: Array; } export type FormValues = { @@ -96,6 +97,7 @@ const InputDialog: React.FC = () => { {row.type === 'select' && } {row.type === 'number' && } {row.type === 'slider' && } + {row.type === 'color' && } ); })} diff --git a/web/src/features/dialog/components/fields/color.tsx b/web/src/features/dialog/components/fields/color.tsx new file mode 100644 index 0000000..c1b3b41 --- /dev/null +++ b/web/src/features/dialog/components/fields/color.tsx @@ -0,0 +1,36 @@ +import { IColorInput } from '../../../../interfaces/dialog'; +import { Control, useController } from 'react-hook-form'; +import { FormValues } from '../../InputDialog'; +import { ColorInput } from '@mantine/core'; + +interface Props { + row: IColorInput; + index: number; + control: Control; +} + +const ColorField: React.FC = (props) => { + const controller = useController({ + name: `test.${props.index}.value`, + control: props.control, + defaultValue: props.row.default, + }); + + return ( + + ); +}; + +export default ColorField; diff --git a/web/src/interfaces/dialog.ts b/web/src/interfaces/dialog.ts index bd43114..2d6f4ad 100644 --- a/web/src/interfaces/dialog.ts +++ b/web/src/interfaces/dialog.ts @@ -51,3 +51,12 @@ export interface ISlider { disabled?: boolean; description?: string; } + +export interface IColorInput { + type: 'color'; + label: string; + default?: string; + disabled?: boolean; + description?: string; + format?: 'hex' | 'hexa' | 'rgb' | 'rgba' | 'hsl' | 'hsla'; +}