Files
psalmtafel-webservice/components/FormElements.tsx
T

54 lines
1.8 KiB
TypeScript

import { ChangeEvent, ReactNode } from "react";
import { ComponentPropsWithoutRef } from "react";
interface TextfieldProps extends ComponentPropsWithoutRef<"input"> {}
function Textfield({value, onChange, placeholder}: TextfieldProps) {
return (
<input
className="w-full border border-neutral-700 rounded-lg px-4 py-2.5 placeholder-neutral-500 focus:outline-none focus:border-blue-400 text-sm"
value={value}
onChange={onChange}
placeholder={placeholder}
/>
)
}
function Dropdown({ children, ...props }: ComponentPropsWithoutRef<"select">) {
return (
<select
className="w-full border border-neutral-700 rounded-lg px-3 py-2 focus:outline-none focus:border-blue-400 text-sm h-[38px]"
{...props}
>
{children}
</select>
);
}
function File({ ...props }: ComponentPropsWithoutRef<"input">) {
return (
<input
type="file"
className="p-1 text-sm w-full rounded-lg border border-neutral-300 dark:border-neutral-700 bg-white dark:bg-black text-black dark:text-white cursor-pointer file:mr-4 file:py-2 file:px-4 file:rounded-sm file:border-0 file:font-semibold file:transition file:bg-neutral-100 file:text-neutral-900 dark:file:bg-neutral-800 dark:file:text-white hover:file:bg-neutral-900 hover:file:text-white dark:hover:file:bg-white dark:hover:file:text-black"
{...props}
/>
);
}
function Button({ children, ...props }: ComponentPropsWithoutRef<"button">) {
return (
<button
className="w-full bg-blue-600 hover:bg-blue-700 text-white font-semibold rounded-lg px-4 py-2.5 transition text-sm shadow-sm"
{...props}
>
{children}
</button>
)
}
export const Input = {
Text: Textfield,
Select: Dropdown,
File: File,
Button: Button,
};