Skip to content

Commit

Permalink
feat(base-input): add icons props
Browse files Browse the repository at this point in the history
  • Loading branch information
Yakutoc authored and apust committed Aug 10, 2020
1 parent 9bd9617 commit e5327bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
22 changes: 8 additions & 14 deletions src/packages/core/src/base-input/BaseInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@ export function BaseInput<T extends HTMLAttributesComposite>(props: BaseInputPro
error,
hint,
label,
name = '',
onBlur,
onChange,
onFocus,
onKeyDown,
value,
width = '100%',
icons,
...rest
} = props;

Expand All @@ -34,25 +29,24 @@ export function BaseInput<T extends HTMLAttributesComposite>(props: BaseInputPro
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
<label className="_e_input__field">
{
cloneElement(children, {
cloneElement<T>(children, {
className: '_e_input__control',
disabled: appearance === 'disabled',
name,
onChange,
onFocus,
onBlur,
onKeyDown,
placeholder: ' ',
readOnly: appearance === 'readonly',
value,
...rest,
})
}
}
<span className="_e_input__label">
{ label }
</span>
<span className="_e_input__background" />
<span className="_e_input__line" />
{ icons && (
<div className="_e_input__icon">
{ icons }
</div>
)}
</label>
{
hint
Expand Down
7 changes: 5 additions & 2 deletions src/packages/core/src/base-input/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import {
InputHTMLAttributes,
TextareaHTMLAttributes,
ReactElement,
ReactNode,
} from 'react';

export type HTMLAttributesComposite =
| InputHTMLAttributes<HTMLInputElement>
| TextareaHTMLAttributes<HTMLTextAreaElement>
| InputHTMLAttributes<HTMLSelectElement>;
| InputHTMLAttributes<HTMLSelectElement>
| TextareaHTMLAttributes<HTMLTextAreaElement>;

export type AbstractInput<T extends HTMLAttributesComposite> = T & {
/**
Expand All @@ -31,6 +32,8 @@ export type AbstractInput<T extends HTMLAttributesComposite> = T & {
*/
hint?: string;

icons?: ReactNode,

/**
* Field label.
*/
Expand Down

0 comments on commit e5327bd

Please sign in to comment.