packages/client: Use bloomer in login & register forms
This commit is contained in:
parent
63c27328ff
commit
905501e053
@ -1,4 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import {Control, Field, Input as I, Label} from 'bloomer'
|
||||||
|
import {IconType} from 'react-icons'
|
||||||
|
|
||||||
export interface IInputProps {
|
export interface IInputProps {
|
||||||
name: string
|
name: string
|
||||||
@ -7,6 +9,8 @@ export interface IInputProps {
|
|||||||
onChange?: (name: this['name'], value: string) => void
|
onChange?: (name: this['name'], value: string) => void
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
readOnly?: boolean
|
readOnly?: boolean
|
||||||
|
label: string
|
||||||
|
Icon?: IconType
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Input extends React.PureComponent<IInputProps> {
|
export class Input extends React.PureComponent<IInputProps> {
|
||||||
@ -16,15 +20,25 @@ export class Input extends React.PureComponent<IInputProps> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
|
const {Icon} = this.props
|
||||||
return (
|
return (
|
||||||
<input
|
<Field>
|
||||||
name={this.props.name}
|
<Label>{this.props.label}</Label>
|
||||||
type={this.props.type}
|
<Control hasIcons>
|
||||||
value={this.props.value}
|
<I
|
||||||
onChange={this.handleChange}
|
className='input'
|
||||||
placeholder={this.props.placeholder}
|
name={this.props.name}
|
||||||
readOnly={!!this.props.readOnly}
|
type={this.props.type}
|
||||||
/>
|
value={this.props.value}
|
||||||
|
onChange={this.handleChange}
|
||||||
|
placeholder={this.props.placeholder}
|
||||||
|
readOnly={!!this.props.readOnly}
|
||||||
|
/>
|
||||||
|
{Icon && <span className='icon is-left is-small'>
|
||||||
|
<Icon />
|
||||||
|
</span>}
|
||||||
|
</Control>
|
||||||
|
</Field>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import React from 'react'
|
|||||||
import {ICredentials, IUser} from '@rondo/common'
|
import {ICredentials, IUser} from '@rondo/common'
|
||||||
import {Input} from '../components/Input'
|
import {Input} from '../components/Input'
|
||||||
import {Redirect} from '../components/Redirect'
|
import {Redirect} from '../components/Redirect'
|
||||||
|
import {FaUser, FaLock} from 'react-icons/fa'
|
||||||
|
|
||||||
export interface ILoginFormProps {
|
export interface ILoginFormProps {
|
||||||
error?: string
|
error?: string
|
||||||
@ -23,6 +24,8 @@ export class LoginForm extends React.PureComponent<ILoginFormProps> {
|
|||||||
<form onSubmit={this.props.onSubmit}>
|
<form onSubmit={this.props.onSubmit}>
|
||||||
<p className='error'>{this.props.error}</p>
|
<p className='error'>{this.props.error}</p>
|
||||||
<Input
|
<Input
|
||||||
|
Icon={FaUser}
|
||||||
|
label='Username'
|
||||||
name='username'
|
name='username'
|
||||||
type='text'
|
type='text'
|
||||||
onChange={this.props.onChange}
|
onChange={this.props.onChange}
|
||||||
@ -30,13 +33,16 @@ export class LoginForm extends React.PureComponent<ILoginFormProps> {
|
|||||||
placeholder='Username'
|
placeholder='Username'
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
|
Icon={FaLock}
|
||||||
|
label='Password'
|
||||||
name='password'
|
name='password'
|
||||||
type='password'
|
type='password'
|
||||||
onChange={this.props.onChange}
|
onChange={this.props.onChange}
|
||||||
value={this.props.data.password}
|
value={this.props.data.password}
|
||||||
placeholder='Password'
|
placeholder='Password'
|
||||||
/>
|
/>
|
||||||
<Input
|
<input
|
||||||
|
className='button is-primary'
|
||||||
name='submit'
|
name='submit'
|
||||||
type='submit'
|
type='submit'
|
||||||
value='Log In'
|
value='Log In'
|
||||||
|
|||||||
@ -21,6 +21,7 @@ export class RegisterForm extends React.PureComponent<IRegisterFormProps> {
|
|||||||
<form onSubmit={this.props.onSubmit}>
|
<form onSubmit={this.props.onSubmit}>
|
||||||
<p className='error'>{this.props.error}</p>
|
<p className='error'>{this.props.error}</p>
|
||||||
<Input
|
<Input
|
||||||
|
label='Username'
|
||||||
name='username'
|
name='username'
|
||||||
type='email'
|
type='email'
|
||||||
onChange={this.props.onChange}
|
onChange={this.props.onChange}
|
||||||
@ -28,16 +29,18 @@ export class RegisterForm extends React.PureComponent<IRegisterFormProps> {
|
|||||||
placeholder='Email'
|
placeholder='Email'
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
|
label='Password'
|
||||||
name='password'
|
name='password'
|
||||||
type='password'
|
type='password'
|
||||||
onChange={this.props.onChange}
|
onChange={this.props.onChange}
|
||||||
value={this.props.data.password}
|
value={this.props.data.password}
|
||||||
placeholder='Password'
|
placeholder='Password'
|
||||||
/>
|
/>
|
||||||
<Input
|
<input
|
||||||
|
className='button is-primary'
|
||||||
name='submit'
|
name='submit'
|
||||||
type='submit'
|
type='submit'
|
||||||
value='Register'
|
value='Log In'
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user