diff --git a/src/assets/images/color.png b/src/assets/images/color.png new file mode 100644 index 0000000..f6bc357 Binary files /dev/null and b/src/assets/images/color.png differ diff --git a/src/components/ColorPicker.tsx b/src/components/ColorPicker.tsx new file mode 100644 index 0000000..18def66 --- /dev/null +++ b/src/components/ColorPicker.tsx @@ -0,0 +1,102 @@ +import { type FC, type InputHTMLAttributes, useState, useRef, useEffect } from 'react' +import { clx } from '../helpers/utils' +import Error from './Error' +import ColorfilterIcon from '@/assets/images/color.png' + +type Props = { + label?: string + className?: string + error_text?: string + isNotRequired?: boolean + value?: string + onChange?: (value: string) => void +} & Omit, 'onChange' | 'value'> + +const ColorPicker: FC = (props: Props) => { + const [color, setColor] = useState(props.value || '#000000') + const colorInputRef = useRef(null) + + const inputClass = clx( + 'w-full bg-white h-10 text-black block pl-10 pr-10 text-xs rounded-xl border border-border', + props.readOnly && 'bg-gray-100 border-0 text-description', + props.className + ) + + const handleColorChange = (event: React.ChangeEvent) => { + const newColor = event.target.value + setColor(newColor) + props.onChange?.(newColor) + } + + const handleTextChange = (event: React.ChangeEvent) => { + const value = event.target.value + if (/^#[0-9A-Fa-f]{0,6}$/.test(value) || value === '') { + const finalColor = value || '#000000' + setColor(finalColor) + props.onChange?.(finalColor) + } + } + + const handleColorIconClick = () => { + if (!props.readOnly) { + colorInputRef.current?.click() + } + } + + useEffect(() => { + if (props.value !== undefined) { + setColor(props.value) + } + }, [props.value]) + + return ( +
+ + +
+ + + + +
+ + + + {props.error_text && ( + + )} +
+
+ ) +} + +export default ColorPicker + diff --git a/src/pages/settings/GeneralSettings.tsx b/src/pages/settings/GeneralSettings.tsx new file mode 100644 index 0000000..2e0cfd0 --- /dev/null +++ b/src/pages/settings/GeneralSettings.tsx @@ -0,0 +1,25 @@ +import ColorPicker from '@/components/ColorPicker' +import Input from '@/components/Input' +import { type FC } from 'react' + +const GeneralSettings: FC = () => { + return ( +
+
+ تنظیمات عمومی +
+ +
+ + + +
+
+ ) +} + +export default GeneralSettings \ No newline at end of file diff --git a/src/pages/settings/Setting.tsx b/src/pages/settings/Setting.tsx index f07226c..503b92c 100644 --- a/src/pages/settings/Setting.tsx +++ b/src/pages/settings/Setting.tsx @@ -2,6 +2,7 @@ import Tabs from '@/components/Tabs' import { Card, KeySquare, Setting4, TruckFast } from 'iconsax-react' import { useState, type FC } from 'react' import { SettingTabEnum } from './enum/Enum' +import GeneralSettings from './GeneralSettings' const Setting: FC = () => { @@ -39,6 +40,12 @@ const Setting: FC = () => { active={activeTab} />
+ +
+ { + activeTab === SettingTabEnum.GENERAL && + } +
) }