Skip to content

Commit d868bca

Browse files
committed
Enable user to show or hide defalut Twitter icon in button and update documentation
1 parent 58ba227 commit d868bca

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,20 @@
3737
| className |string | |class name for component |
3838
| dialogWidth |number |600 |dialog width |
3939
| dialogHeight |number |400 |dialog height |
40-
40+
| showIcon |bool |true |should default icon be visible |
4141

4242
# Examples
4343

4444
Full example can be found in [example](https://github.com/GenFirst/react-twitter-login/tree/master/example) folder.
4545

46+
You can find tutorial that explains in details how to implement Twitter authentication with RESTful backend [here](https://medium.com/@robince885/how-to-do-twitter-authentication-with-react-and-restful-api-e525f30c62bb).
47+
48+
# Workflow
49+
50+
The detailed explanation of the whole process can be found in Twitter documentation. In picture below you can find out all the steps that are needed.
51+
52+
![Twitter authentication workflow](https://cdn-images-1.medium.com/max/800/1*RTsSRbVeEzPaC68hRT8n2g.png)
53+
4654
# License
4755

4856
react-twitter-auth is released under [MIT License](https://opensource.org/licenses/MIT).

example/twitter-example/src/App.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ class App extends Component {
2323
render() {
2424
return (
2525
<div>
26-
<TwitterLogin loginUrl="http://localhost:4000/api/v1/auth/twitter" onFailure={this.onFailed} onSuccess={this.onSuccess} requestTokenUrl="http://localhost:4000/api/v1/auth/twitter/reverse"/>
26+
<TwitterLogin loginUrl="http://localhost:4000/api/v1/auth/twitter"
27+
onFailure={this.onFailed}
28+
onSuccess={this.onSuccess}
29+
requestTokenUrl="http://localhost:4000/api/v1/auth/twitter/reverse"
30+
showIcon={true}/>
2731
</div>
2832
);
2933
}

src/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,11 @@ class TwitterLogin extends Component {
9797
}
9898

9999
getDefaultButtonContent() {
100+
const defaultIcon = this.props.showIcon? <TwitterIcon color='#00aced' size={25}/> : null;
101+
100102
return (
101103
<span>
102-
<TwitterIcon color='#00aced' size={25}/> {this.props.text}
104+
{defaultIcon} {this.props.text}
103105
</span>
104106
);
105107
}
@@ -128,15 +130,17 @@ TwitterLogin.propTypes = {
128130
style: PropTypes.object,
129131
className: PropTypes.string,
130132
dialogWidth: PropTypes.number,
131-
dialogHeight: PropTypes.number
133+
dialogHeight: PropTypes.number,
134+
showIcon: PropTypes.bool
132135
};
133136

134137
TwitterLogin.defaultProps = {
135138
tag: 'button',
136139
text: 'Sign in with Twitter',
137140
disabled: false,
138141
dialogWidth: 600,
139-
dialogHeight: 400
142+
dialogHeight: 400,
143+
showIcon: true
140144
};
141145

142146
export default TwitterLogin;

0 commit comments

Comments
 (0)