Skip to content

Commit c5cc7d0

Browse files
committed
updted readme and patches
1 parent 92dc80f commit c5cc7d0

3 files changed

Lines changed: 27 additions & 4 deletions

File tree

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,31 @@ A lightweight package to toggle password visibility on click of the icon. you ne
1414
</div>
1515
```
1616

17+
### Properties
18+
- **inputRef** - this is required props , here you need to supply ref of password input field as this prop val,
19+
- **showIcon** - default value for this field is "Show", but here you can pass cutsom funtion which return html of the image tag or icon tag or any icon or text which you want to show.
20+
- **hideIcon** - defaut value fot this fied is "Hide", here also you can provide callback function same as the showIcon if you want to render icon or something else as per your need.
21+
**here is snippet for your ref**
22+
### Code
23+
24+
``` js
25+
const showIcon = () => <i class=""></i>;
26+
const hideIcon = () => <i class=""></i>;
27+
<ReactPasswordToggleIcon inputRef={inputRef} {...props}/>
28+
```
29+
- **parentClassName** - if you want to add custom class to the icon parent div then you can use this props to pass classname,
30+
- **isVisible**: if you want to show password by default on then you can pass bool val true in this prop.
31+
32+
### Steps to integrate
1733
as per above code you need to follow three steps:
1834
- create div and give it position: relative css
1935
- create input and give assign ref to it and place it in div which we have created in previous step
2036
- now import react-password-toggle-icon place it in same div and pass inputRef prop whose value is set to inputfield ref
2137

22-
cheers!!
38+
### Code Sandbox link
39+
[a link](https://codesandbox.io/s/react-password-toggle-icon-forked-rd2xz)
40+
41+
Hope This package will help 😊
42+
43+
cheers 🥂!!
2344

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-password-toggle-icon",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "a lightweight password hide show package",
55
"main": "dist/index.js",
66
"repository": {

src/app.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ class App extends React.PureComponent {
4343
style,
4444
parentClassName
4545
} = this.props;
46-
console.log(typeof inputRef);
46+
4747
const {isVisible} = this.state;
48+
const hideVal = typeof hideIcon === "string" ? hideIcon : hideIcon();
49+
const showVal = typeof showVal === "string" ? showIcon : showIcon();
4850
return (
4951
<div className={"react-password-toggle-icon-wrapper"+" "+parentClassName} onClick={() => this.handleClick(inputRef)} style={{...defaultStyle,...style}}>
50-
{!isVisible ? hideIcon : showIcon}
52+
{isVisible ? hideVal : showVal}
5153
</div>
5254
);
5355
}

0 commit comments

Comments
 (0)