Add Input component
[MAILPOET-2772]
This commit is contained in:
36
assets/js/src/common/form/input/input.tsx
Normal file
36
assets/js/src/common/form/input/input.tsx
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import classnames from 'classnames';
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
size?: 'small',
|
||||||
|
isFullWidth?: boolean,
|
||||||
|
iconStart?: JSX.Element,
|
||||||
|
iconEnd?: JSX.Element,
|
||||||
|
[attribute: string]: any, // any HTML attributes, e.g. type, name, id, placeholder
|
||||||
|
};
|
||||||
|
|
||||||
|
const Input = ({
|
||||||
|
size,
|
||||||
|
isFullWidth,
|
||||||
|
iconStart,
|
||||||
|
iconEnd,
|
||||||
|
...attributes
|
||||||
|
}: Props) => (
|
||||||
|
<div
|
||||||
|
className={
|
||||||
|
classnames(
|
||||||
|
'mailpoet-form-input',
|
||||||
|
{
|
||||||
|
[`mailpoet-form-input-${size}`]: size,
|
||||||
|
'mailpoet-full-width': isFullWidth,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{iconStart}
|
||||||
|
<input {...attributes} />
|
||||||
|
{iconEnd}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default Input;
|
Reference in New Issue
Block a user