-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Visibility toggle for PasswordInput (#377)
* Update fuselage.d.ts * Update index.js * Update spec.js * Update index.js * Update fuselage.d.ts * Update index.js * Update spec.js * Update PasswordInput.stories.mdx * Invert toggle state icon * Convert PasswordInput to TypeScript Co-authored-by: gabriellsh <40830821+gabriellsh@users.noreply.github.com> Co-authored-by: Tasso Evangelista <tasso.evangelista@rocket.chat>
- Loading branch information
1 parent
3333d7f
commit 5ef1bec
Showing
23 changed files
with
117 additions
and
145 deletions.
There are no files selected for viewing
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
Binary file modified
BIN
+2.1 KB
(510%)
.../fuselage/.loki/reference/chrome_iphone7_Forms_Inputs_PasswordInput_Default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.13 KB
(510%)
...fuselage/.loki/reference/chrome_iphone7_Forms_Inputs_PasswordInput_Disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.83 KB
(440%)
.../fuselage/.loki/reference/chrome_iphone7_Forms_Inputs_PasswordInput_Invalid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+18.7 KB
(130%)
...s/fuselage/.loki/reference/chrome_iphone7_Forms_Inputs_PasswordInput_States.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.01 KB
(150%)
.../.loki/reference/chrome_iphone7_Forms_Inputs_PasswordInput_With_Placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.89 KB
(250%)
...selage/.loki/reference/chrome_iphone7_Forms_Inputs_PasswordInput_With_Value.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+720 Bytes
(350%)
...s/fuselage/.loki/reference/chrome_laptop_Forms_Inputs_PasswordInput_Default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+719 Bytes
(350%)
.../fuselage/.loki/reference/chrome_laptop_Forms_Inputs_PasswordInput_Disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+654 Bytes
(320%)
...s/fuselage/.loki/reference/chrome_laptop_Forms_Inputs_PasswordInput_Invalid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+6.5 KB
(120%)
...es/fuselage/.loki/reference/chrome_laptop_Forms_Inputs_PasswordInput_States.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+679 Bytes
(140%)
...e/.loki/reference/chrome_laptop_Forms_Inputs_PasswordInput_With_Placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+665 Bytes
(200%)
...uselage/.loki/reference/chrome_laptop_Forms_Inputs_PasswordInput_With_Value.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion
2
...lage/src/components/PasswordInput/spec.js → ...ents/PasswordInput/PasswordInput.spec.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
93 changes: 0 additions & 93 deletions
93
packages/fuselage/src/components/PasswordInput/PasswordInput.stories.mdx
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
packages/fuselage/src/components/PasswordInput/PasswordInput.stories.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,51 @@ | ||
import { Meta, Story } from '@storybook/react'; | ||
import React from 'react'; | ||
|
||
import { Icon, PasswordInput } from '../..'; | ||
import PropsVariation from '../../.storybook/PropsVariation'; | ||
|
||
export default { | ||
title: 'Forms/Inputs/PasswordInput', | ||
component: PasswordInput, | ||
parameters: { jest: ['PasswordInput.spec.tsx'] }, | ||
} as Meta; | ||
|
||
export const Default: Story = () => <PasswordInput />; | ||
|
||
export const WithValue: Story = () => <PasswordInput defaultValue='password' />; | ||
|
||
export const WithIconAddon: Story = () => ( | ||
<PasswordInput addon={<Icon name='send' size={20} />} /> | ||
); | ||
|
||
export const Invalid: Story = () => <PasswordInput error='Error' />; | ||
|
||
export const Disabled: Story = () => <PasswordInput disabled />; | ||
|
||
export const WithPlaceholder: Story = () => ( | ||
<PasswordInput placeholder='Placeholder' /> | ||
); | ||
|
||
export const States: Story = () => ( | ||
<PropsVariation | ||
component={PasswordInput} | ||
common={{ onChange: () => undefined }} | ||
xAxis={{ | ||
'default': {}, | ||
'with placeholder': { placeholder: 'Placeholder' }, | ||
'with value': { value: 'Value' }, | ||
'with icon': { addon: <Icon name='key' size='x20' />, value: 'Value' }, | ||
}} | ||
yAxis={{ | ||
'default': {}, | ||
'hover': { className: 'hover' }, | ||
'active': { className: 'active' }, | ||
'focus': { className: 'focus' }, | ||
'disabled': { disabled: true }, | ||
'errored': { error: 'Error' }, | ||
'errored + hover': { className: 'hover', error: 'Error' }, | ||
'errored + active': { className: 'active', error: 'Error' }, | ||
'errored + focus': { className: 'focus', error: 'Error' }, | ||
}} | ||
/> | ||
); |
36 changes: 36 additions & 0 deletions
36
packages/fuselage/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,36 @@ | ||
import { useToggle } from '@rocket.chat/fuselage-hooks'; | ||
import React, { ComponentProps, forwardRef, Ref } from 'react'; | ||
|
||
import { Icon } from '../Icon'; | ||
import { InputBox } from '../InputBox'; | ||
|
||
// TODO: fix a11y issues | ||
|
||
type PasswordInputProps = Omit<ComponentProps<typeof InputBox>, 'type'>; | ||
|
||
const PasswordInput = forwardRef(function PasswordInput( | ||
props: PasswordInputProps, | ||
ref: Ref<HTMLInputElement> | ||
) { | ||
const [hidden, toggle] = useToggle(true); | ||
const handleAddonClick = () => { | ||
toggle(); | ||
}; | ||
|
||
return ( | ||
<InputBox | ||
type={hidden ? 'password' : 'text'} | ||
addon={ | ||
<Icon | ||
name={hidden ? 'eye-off' : 'eye'} | ||
size={20} | ||
onClick={handleAddonClick} | ||
/> | ||
} | ||
ref={ref} | ||
{...props} | ||
/> | ||
); | ||
}); | ||
|
||
export default PasswordInput; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
export { default } from './PasswordInput'; |
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