Skip to content

Commit

Permalink
fix: add select placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
jsun969 committed Jan 16, 2024
1 parent 63eb0d4 commit 4120698
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/Field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@ export interface FieldProps {
value: string;
onChange: (value: string) => void;
error?: string | null;
type?: string;
type?: 'text' | 'password' | 'select' | 'checkbox';
options?: string[];
placeholder?: string;
}

const Field = ({ label, value, onChange, error, type = 'text', options = [] }: FieldProps) => {
const Field = ({
label,
value,
onChange,
error,
type = 'text',
options = [],
placeholder,
}: FieldProps) => {
const [showPassword, setShowPassword] = useState(false);

const togglePasswordVisibility = () => {
Expand All @@ -34,6 +43,7 @@ const Field = ({ label, value, onChange, error, type = 'text', options = [] }: F
value={value}
className="border text-grey border-gray-300 px-3 py-2 w-full mt-1"
>
{placeholder && <option value="">{placeholder}</option>}
{options.map((option, index) => (
<option key={index} value={option}>
{option}
Expand Down

0 comments on commit 4120698

Please sign in to comment.