forked from rajun/ar-test
refactor: restyle input with sm, md and lg sizes
This commit is contained in:
parent
fd36cf889a
commit
cba840a66f
@ -1,21 +1,25 @@
|
||||
import * as React from 'react';
|
||||
import type { ComponentProps } from 'react';
|
||||
import { cva, type VariantProps } from 'class-variance-authority';
|
||||
import { cn } from '~/lib/utils';
|
||||
|
||||
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<'input'>>(
|
||||
({ className, type, ...props }, ref) => {
|
||||
return (
|
||||
<input
|
||||
type={type}
|
||||
className={cn(
|
||||
'flex h-10 w-full rounded-xl border border-neutral-800 bg-[#181818] px-4 py-3 text-sm text-white placeholder-neutral-600 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-white focus-visible:outline-none focus-visible:border-orange-500 disabled:cursor-not-allowed disabled:opacity-50 transition-colors duration-200',
|
||||
className
|
||||
)}
|
||||
ref={ref}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
const inputVariants = cva(
|
||||
'flex w-full rounded-control border border-border-control bg-background text-text-primary transition-[color,border-color,box-shadow] duration-150 focus-visible:border-primary focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-danger/70',
|
||||
{
|
||||
variants: {
|
||||
size: {
|
||||
sm: 'h-8 px-2.5 text-xs',
|
||||
md: 'h-10 px-3 text-base',
|
||||
// Login: taller, with a soft focus ring
|
||||
lg: 'h-12 rounded-field border-border-dialog bg-surface px-3.5 text-base focus-visible:ring-3 focus-visible:ring-primary/15',
|
||||
},
|
||||
mono: { true: 'font-mono', false: '' },
|
||||
},
|
||||
defaultVariants: { size: 'md', mono: false },
|
||||
},
|
||||
);
|
||||
Input.displayName = 'Input';
|
||||
|
||||
export { Input };
|
||||
export interface InputProps extends Omit<ComponentProps<'input'>, 'size'>, VariantProps<typeof inputVariants> {}
|
||||
|
||||
export function Input({ className, size, mono, ...props }: InputProps) {
|
||||
return <input className={cn(inputVariants({ size, mono }), className)} {...props} />;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user