31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import type { InputHTMLAttributes, ReactNode, SelectHTMLAttributes, TextareaHTMLAttributes } from 'react'
|
|
import { cx } from './cx'
|
|
|
|
export const INPUT_CLASS =
|
|
'w-full min-h-9 px-2.5 py-1.5 text-sm text-ink caret-accent bg-surface border border-divider ' +
|
|
'hover:border-ink/45 focus-visible:border-accent focus-visible:outline-offset-0 ' +
|
|
'disabled:opacity-45 disabled:cursor-not-allowed'
|
|
|
|
export function Field({ label, htmlFor, children }: { label: string; htmlFor: string; children: ReactNode }) {
|
|
return (
|
|
<div>
|
|
<label htmlFor={htmlFor} className="block text-xs mb-[5px] text-ink/70">
|
|
{label}
|
|
</label>
|
|
{children}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export function Input({ className, ...rest }: InputHTMLAttributes<HTMLInputElement>) {
|
|
return <input className={cx(INPUT_CLASS, className)} {...rest} />
|
|
}
|
|
|
|
export function Textarea({ className, ...rest }: TextareaHTMLAttributes<HTMLTextAreaElement>) {
|
|
return <textarea className={cx(INPUT_CLASS, 'min-h-[90px] resize-y', className)} {...rest} />
|
|
}
|
|
|
|
export function Select({ className, ...rest }: SelectHTMLAttributes<HTMLSelectElement>) {
|
|
return <select className={cx(INPUT_CLASS, className)} {...rest} />
|
|
}
|