Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 Use InputType #231

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions packages/react/components/input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,16 @@ const Input = (
const classes = hashClass(styled, clsx('input', localStatus && is(localStatus)))
const wrapperClasses = hashClass(
styled,
clsx('field', className, type === 'password' && securityGauge && 'has-gauge'),
clsx('field', className, type === InputType.PASSWORD && securityGauge && has('gauge')),
)

const hasIcon = iconNameLeft || iconNameRight

const controlClasses = hashClass(
styled,
clsx('control', {
[has('icons-right')]: hasIcon ?? (iconNameRight || type === 'password'),
['has-icons-left']: iconNameLeft || type === InputType.SEARCH,
[has('icons-right')]: hasIcon ?? (iconNameRight || type === InputType.PASSWORD),
[has('icons-left')]: iconNameLeft || type === InputType.SEARCH,
}),
)

Expand All @@ -154,7 +154,7 @@ const Input = (
({ className, name, color, closeIconSearch, onPress }: IconWrapper) => {
return (
<div
{...(type === 'password' && { 'data-show-pwd': true })}
{...(type === InputType.PASSWORD && { 'data-show-pwd': true })}
onClick={(e) => {
onPress && onPress()
if (onIconClick) {
Expand Down Expand Up @@ -211,7 +211,7 @@ const Input = (
return (
<div className={wrapperClasses} data-has-gauge={securityGauge ? true : undefined}>
{label && (
<label className="input-label">
<label className='input-label'>
{label}{' '}
{required && (
<Text markup={TextMarkup.SPAN} typo={TypographyColor.TEXT_ERROR}>
Expand All @@ -221,15 +221,15 @@ const Input = (
</label>
)}
{sample && (
<Text className="input-sample" level={TextLevels.TWO}>
<Text className='input-sample' level={TextLevels.TWO}>
{sample}
</Text>
)}
<div className={controlClasses}>
<input
id={id}
required={required}
role={'textbox'}
role='textbox'
{...others}
aria-label={accessibilityLabel}
type={inputType}
Expand Down Expand Up @@ -295,16 +295,16 @@ const Input = (
}}
/>
{hasIcon && !localStatus && !loading && <IconWrapper name={iconNameLeft as unknown as IconName} />}
{iconNameLeft && !loading && <IconWrapper className={'icon-left'} name={iconNameLeft as unknown as IconName} />}
{iconNameRight && !loading && type !== 'password' && (
<IconWrapper className={'icon-right'} name={iconNameRight as unknown as IconName} />
{iconNameLeft && !loading && <IconWrapper className='icon-left' name={iconNameLeft as unknown as IconName} />}
{iconNameRight && !loading && type !== InputType.PASSWORD && (
<IconWrapper className='icon-right' name={iconNameRight as unknown as IconName} />
)}
{!loading && type === 'password' && (
{!loading && type === InputType.PASSWORD && (
<IconWrapper
className={'icon-right'}
className='icon-right'
name={isShowPwd ? IconName.EYE_SLASH : IconName.EYE}
onPress={() => {
if (inputType === 'password') {
if (inputType === InputType.PASSWORD) {
setInputType(InputType.TEXT)
setIsShowPwd(true)
} else {
Expand All @@ -318,7 +318,7 @@ const Input = (
</div>
{help && <Text className={helpClasses}>{help}</Text>}

{securityGauge && type === 'password' && (
{securityGauge && type === InputType.PASSWORD && (
<InputGauge validationRules={validationRules} styled={styled} inputValue={_value} />
)}
</div>
Expand Down