Migrate the existing login form to use React
This commit is contained in:
parent
0ab3768274
commit
d9f30294de
15 changed files with 322 additions and 72 deletions
30
resources/scripts/components/forms/OpenInputField.tsx
Normal file
30
resources/scripts/components/forms/OpenInputField.tsx
Normal file
|
@ -0,0 +1,30 @@
|
|||
import * as React from 'react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
type Props = React.InputHTMLAttributes<HTMLInputElement> & {
|
||||
label: string;
|
||||
};
|
||||
|
||||
export default ({ className, onChange, label, ...props }: Props) => {
|
||||
const [ value, setValue ] = React.useState('');
|
||||
|
||||
const classes = classNames('input open-label', {
|
||||
'has-content': value && value.length > 0,
|
||||
});
|
||||
|
||||
return (
|
||||
<div className={'input-open'}>
|
||||
<input
|
||||
className={classes}
|
||||
onChange={e => {
|
||||
setValue(e.target.value);
|
||||
if (onChange) {
|
||||
onChange(e);
|
||||
}
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
<label htmlFor={props.id}>{label}</label>
|
||||
</div>
|
||||
);
|
||||
};
|
Reference in a new issue