Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Commit

Permalink
Merge pull request #70 from Synthetixio/text-input
Browse files Browse the repository at this point in the history
feat(textinput): added icon prop to text input
  • Loading branch information
fritzschoff authored May 10, 2022
2 parents b68cb57 + 3ab5e01 commit 1d5847c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ interface TextInputProps extends HTMLAttributes<HTMLDivElement> {
placeholder?: string;
size?: 'medium' | 'small';
value: string;
onInput: FormEventHandler;
onInput: FormEventHandler<HTMLInputElement>;
icon?: JSX.Element;
}

export default function TextInput({
Expand All @@ -23,6 +24,7 @@ export default function TextInput({
size = 'medium',
value,
name,
icon,
...rest
}: TextInputProps) {
return (
Expand All @@ -37,6 +39,7 @@ export default function TextInput({
name={name}
/>
{label && <StyledLabel htmlFor={id}>{label}</StyledLabel>}
{icon && icon}
</StyledInputWrapper>
);
}
Expand Down
14 changes: 14 additions & 0 deletions stories/TextInput.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ export const Template: ComponentStory<typeof TextInput> = (args) => (
label="TextArea Label"
placeholder="Some placeholder..."
value="Lorem ipsum"
icon={
<div
style={{
position: 'absolute',
top: '20px',
right: 1,
color: 'white',
zIndex: 10,
cursor: 'pointer',
}}
>
CLICK ME
</div>
}
/>
);

Expand Down

0 comments on commit 1d5847c

Please sign in to comment.