-
Notifications
You must be signed in to change notification settings - Fork 705
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added view toggle for password input field (#4303)
Signed-off-by: Hrishav <[email protected]>
- Loading branch information
1 parent
8ad33ad
commit 11b8597
Showing
11 changed files
with
172 additions
and
29 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
chaoscenter/web/src/components/PasswordInput/PasswordInput.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.fieldContainer { | ||
gap: 0.15rem; | ||
.inputContainer { | ||
:global { | ||
.bp3-form-group { | ||
margin-bottom: 0 !important; | ||
} | ||
.bp3-input-group .bp3-input:not(:last-child) { | ||
padding-right: 36px !important; | ||
} | ||
} | ||
position: relative; | ||
} | ||
.eyeIcon { | ||
position: absolute; | ||
right: 0.5rem; | ||
top: 50%; | ||
transform: translateY(-50%); | ||
z-index: 1; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
chaoscenter/web/src/components/PasswordInput/PasswordInput.module.scss.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
declare namespace PasswordInputModuleScssNamespace { | ||
export interface IPasswordInputModuleScss { | ||
eyeIcon: string; | ||
fieldContainer: string; | ||
inputContainer: string; | ||
} | ||
} | ||
|
||
declare const PasswordInputModuleScssModule: PasswordInputModuleScssNamespace.IPasswordInputModuleScss; | ||
|
||
export = PasswordInputModuleScssModule; |
45 changes: 45 additions & 0 deletions
45
chaoscenter/web/src/components/PasswordInput/PasswordInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react'; | ||
import { Icon, IconName } from '@harnessio/icons'; | ||
import { FormInput, Layout, Text } from '@harnessio/uicore'; | ||
import { Color, FontVariation } from '@harnessio/design-system'; | ||
import style from './PasswordInput.module.scss'; | ||
|
||
interface PassowrdInputProps { | ||
disabled?: boolean; | ||
placeholder?: string; | ||
name: string; | ||
label: string; | ||
} | ||
|
||
const PassowrdInput = (props: PassowrdInputProps): React.ReactElement => { | ||
const { disabled, label, name, placeholder } = props; | ||
const [showPassword, setShowPassword] = React.useState(false); | ||
const stateIcon: IconName = showPassword ? 'eye-off' : 'eye-open'; | ||
|
||
function handleToggleClick(): void { | ||
setShowPassword(!showPassword); | ||
} | ||
|
||
return ( | ||
<Layout.Vertical className={style.fieldContainer}> | ||
{label && ( | ||
<Text font={{ variation: FontVariation.BODY, weight: 'semi-bold' }} color={Color.GREY_600}> | ||
{label} | ||
</Text> | ||
)} | ||
<div className={style.inputContainer}> | ||
<FormInput.Text | ||
name={name} | ||
inputGroup={{ | ||
type: showPassword ? 'text' : 'password' | ||
}} | ||
placeholder={placeholder} | ||
disabled={disabled} | ||
/> | ||
<Icon name={stateIcon} size={20} onClick={handleToggleClick} className={style.eyeIcon} /> | ||
</div> | ||
</Layout.Vertical> | ||
); | ||
}; | ||
|
||
export default PassowrdInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import PassowrdInput from './PasswordInput'; | ||
|
||
export default PassowrdInput; |
7 changes: 7 additions & 0 deletions
7
chaoscenter/web/src/components/UserNameInput/UserNameInput.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.mainWrapper { | ||
:global { | ||
.bp3-form-group { | ||
margin-bottom: 0 !important; | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
chaoscenter/web/src/components/UserNameInput/UserNameInput.module.scss.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
declare namespace UserNameInputModuleScssNamespace { | ||
export interface IUserNameInputModuleScss { | ||
mainWrapper: string; | ||
} | ||
} | ||
|
||
declare const UserNameInputModuleScssModule: UserNameInputModuleScssNamespace.IUserNameInputModuleScss; | ||
|
||
export = UserNameInputModuleScssModule; |
28 changes: 28 additions & 0 deletions
28
chaoscenter/web/src/components/UserNameInput/UserNameInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import { Color, FontVariation } from '@harnessio/design-system'; | ||
import { FormInput, Layout, Text } from '@harnessio/uicore'; | ||
import style from './UserNameInput.module.scss'; | ||
|
||
interface UserNameInputProps { | ||
disabled?: boolean; | ||
placeholder?: string; | ||
name: string; | ||
label: string; | ||
} | ||
|
||
const UserNameInput = (props: UserNameInputProps): React.ReactElement => { | ||
const { disabled, label, name, placeholder } = props; | ||
|
||
return ( | ||
<Layout.Vertical style={{ gap: '0.15rem' }} className={style.mainWrapper}> | ||
{label && ( | ||
<Text font={{ variation: FontVariation.BODY, weight: 'semi-bold' }} color={Color.GREY_600}> | ||
{label} | ||
</Text> | ||
)} | ||
<FormInput.Text name={name} placeholder={placeholder} disabled={disabled} /> | ||
</Layout.Vertical> | ||
); | ||
}; | ||
|
||
export default UserNameInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import UserNameInput from './UserNameInput'; | ||
|
||
export default UserNameInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters