Skip to content

Commit

Permalink
add custom icon to input field (#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jxnis authored Sep 15, 2023
1 parent 1908025 commit f14cb23
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/components/inputs/input-field/inputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
maxChars?: number
initialCounter?: number
defaultValue?: number | undefined
customIcon?: JSX.Element
}

export const MbInput = forwardRef<HTMLInputElement, InputProps>(
Expand All @@ -44,6 +45,7 @@ export const MbInput = forwardRef<HTMLInputElement, InputProps>(
defaultValue,
inputSize = ESize.MEDIUM,
onChange,
customIcon,
...restProps
},
ref
Expand Down Expand Up @@ -134,6 +136,7 @@ export const MbInput = forwardRef<HTMLInputElement, InputProps>(
)}
</div>
)}
{!!customIcon && !hasIcon && customIcon}
</div>
{maxChars ? (
<MbCharCounter
Expand Down
10 changes: 10 additions & 0 deletions src/stories/components/inputs/InputField.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react'

import { ESize } from '../../../consts/properties'
import { MbInput, EControlStatus } from '../../../index'
import { MbIcon, EIconName } from '../../../index'

export default {
title: 'Components/Inputs/Input',
Expand All @@ -25,6 +26,15 @@ export const Input = Template.bind({})
Input.args = {
label: 'Label',
hasIcon: true,
customIcon: (
<MbIcon
name={EIconName.ARROW_DROP_DOWN}
className={`flex transform transition ease-in-out duration-300`}
size="16px"
color="blue-300"
darkColor="blue-100"
/>
),
disabled: false,
placeholder: 'Placeholder',
type: 'text',
Expand Down

1 comment on commit f14cb23

@vercel
Copy link

@vercel vercel bot commented on f14cb23 Sep 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.