Spaces:
Configuration error

README / frontend /src /components /features /settings /settings-input.tsx
gauravanu001's picture
upload
2d63f96 verified
Raw History Blame Contribute Delete
1.37 kB
import { cn } from "#/utils/utils";
import { OptionalTag } from "./optional-tag";
interface SettingsInputProps {
testId?: string;
name?: string;
label: string;
type: React.HTMLInputTypeAttribute;
defaultValue?: string;
placeholder?: string;
showOptionalTag?: boolean;
isDisabled?: boolean;
startContent?: React.ReactNode;
className?: string;
onChange?: (value: string) => void;
}
export function SettingsInput({
testId,
name,
label,
type,
defaultValue,
placeholder,
showOptionalTag,
isDisabled,
startContent,
className,
onChange,
}: SettingsInputProps) {
return (
<label className={cn("flex flex-col gap-2.5 w-fit", className)}>
<div className="flex items-center gap-2">
{startContent}
<span className="text-sm">{label}</span>
{showOptionalTag && <OptionalTag />}
</div>
<input
data-testid={testId}
onChange={(e) => onChange?.(e.target.value)}
name={name}
disabled={isDisabled}
type={type}
defaultValue={defaultValue}
placeholder={placeholder}
className={cn(
"bg-tertiary border border-[#717888] h-10 w-full rounded p-2 placeholder:italic placeholder:text-tertiary-alt",
"disabled:bg-[#2D2F36] disabled:border-[#2D2F36] disabled:cursor-not-allowed",
)}
/>
</label>
);
}