Update new input styling
This commit is contained in:
parent
7c4028f8f1
commit
25d61525b3
3 changed files with 45 additions and 8 deletions
|
@ -2,6 +2,29 @@ import React, { forwardRef } from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import styles from './styles.module.css';
|
import styles from './styles.module.css';
|
||||||
|
|
||||||
export default forwardRef<HTMLInputElement, React.ComponentProps<'input'>>(({ className, ...props }, ref) => (
|
enum Variant {
|
||||||
<input ref={ref} className={classNames('form-input', styles.text_input, className)} {...props} />
|
Normal,
|
||||||
|
Snug,
|
||||||
|
Loose,
|
||||||
|
}
|
||||||
|
|
||||||
|
interface InputFieldProps extends React.ComponentProps<'input'> {
|
||||||
|
variant?: Variant;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Component = forwardRef<HTMLInputElement, InputFieldProps>(({ className, variant, ...props }, ref) => (
|
||||||
|
<input
|
||||||
|
ref={ref}
|
||||||
|
className={classNames(
|
||||||
|
'form-input',
|
||||||
|
styles.text_input,
|
||||||
|
{ [styles.loose]: variant === Variant.Loose },
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
));
|
));
|
||||||
|
|
||||||
|
const InputField = Object.assign(Component, { Variants: Variant });
|
||||||
|
|
||||||
|
export default InputField;
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
export { default as Checkbox } from './Checkbox';
|
import Checkbox from '@/components/elements/inputs/Checkbox';
|
||||||
export { default as InputField } from './InputField';
|
import InputField from '@/components/elements/inputs/InputField';
|
||||||
|
|
||||||
|
const Input = Object.assign(
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
Text: InputField,
|
||||||
|
Checkbox: Checkbox,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
export { Input };
|
||||||
export { default as styles } from './styles.module.css';
|
export { default as styles } from './styles.module.css';
|
||||||
|
|
|
@ -12,10 +12,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.text_input {
|
.text_input {
|
||||||
@apply transition-all duration-75;
|
@apply transition-shadow duration-75;
|
||||||
@apply bg-neutral-800 border-neutral-600 rounded px-4 py-2 outline-none;
|
@apply w-full bg-neutral-800 rounded px-4 py-2 outline-none border-0;
|
||||||
|
|
||||||
&:focus {
|
&:focus, &:active {
|
||||||
@apply border-blue-600 ring-2 ring-blue-500;
|
@apply ring-4 ring-blue-300 ring-opacity-75;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.loose {
|
||||||
|
@apply px-6 py-3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue