You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.5 KiB
49 lines
1.5 KiB
import React, { FC } from 'react'
|
|
import classNames from 'classnames'
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
|
import { IconDefinition } from '@fortawesome/fontawesome-common-types'
|
|
|
|
import { notificationTypeToClassName } from 'src/utils'
|
|
import { FormNotification } from 'src/types'
|
|
|
|
import './register-form.scss'
|
|
|
|
export interface Props {
|
|
name: string
|
|
label: string
|
|
placeholder?: string
|
|
icon?: IconDefinition
|
|
value?: string
|
|
notification?: FormNotification
|
|
}
|
|
|
|
const RegisterForm: FC<Props> = ({ label, placeholder, icon, value, notification }) => {
|
|
const controlClassNames = classNames({ control: true, 'has-icons-left': !!icon })
|
|
let helpClassNames: string | undefined
|
|
|
|
if (notification) {
|
|
helpClassNames = classNames({
|
|
help: true,
|
|
[notificationTypeToClassName(notification.type)]: true,
|
|
})
|
|
}
|
|
|
|
return (
|
|
<div className="field">
|
|
<label className="label">{label}</label>
|
|
<div className={controlClassNames}>
|
|
<input className="input" type="text" placeholder={placeholder} value={value} />
|
|
{icon &&
|
|
<span className="icon is-small is-left">
|
|
<FontAwesomeIcon icon={icon} />
|
|
</span>
|
|
}
|
|
</div>
|
|
{notification &&
|
|
<p className={helpClassNames}>{notification.message}</p>
|
|
}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default RegisterForm
|