Skip to content

Commit

Permalink
Added support for badge attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartosz Jabłoński committed Mar 22, 2017
1 parent aa64874 commit 883210e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Other properties can be used to customised the rendering.
| onExpired | func | *optional* callback when the challenge is expired and has to be redone by user. By default it will call the onChange with null to signify expired callback. |
| stoken | string | *optional* set the stoken parameter, which allows the captcha to be used from different domains, see [reCAPTCHA secure-token] |
| size | enum | *optional* `compact`, `normal` or `invisible`. This allows you to change the size or do an invisible captcha |
| badge | enum | *optional* `bottomright`, `bottomleft` or `inline`. Positions reCAPTCHA badge |


In order to translate the reCaptcha widget you should create a global variable configuring the desire language, if you don't provide it reCaptcha will pick up the user's interface language.
Expand Down
5 changes: 4 additions & 1 deletion src/recaptcha.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const ReCAPTCHA = React.createClass({
onExpired: PropTypes.func,
size: PropTypes.oneOf(["compact", "normal", "invisible"]),
stoken: PropTypes.string,
badge: PropTypes.oneOf(["bottomright", "bottomleft ", "inline"])
},

getInitialState () {
Expand All @@ -24,6 +25,7 @@ const ReCAPTCHA = React.createClass({
type: "image",
tabindex: 0,
size: "normal",
badge: "bottomright"
};
},

Expand Down Expand Up @@ -68,6 +70,7 @@ const ReCAPTCHA = React.createClass({
"expired-callback": this.handleExpired,
size: this.props.size,
stoken: this.props.stoken,
badge: this.props.badge
});
this.setState({
widgetId: id,
Expand All @@ -86,7 +89,7 @@ const ReCAPTCHA = React.createClass({
render () {
// consume properties owned by the reCATPCHA, pass the rest to the div so the user can style it.
/* eslint-disable no-unused-vars */
const { sitekey, onChange, theme, type, tabindex, onExpired, size, stoken, grecaptcha, ...childProps } = this.props;
const { sitekey, onChange, theme, type, tabindex, onExpired, size, stoken, grecaptcha, badge, ...childProps } = this.props;
/* eslint-enable no-unused-vars */
return (
<div {...childProps} ref="captcha" />
Expand Down

0 comments on commit 883210e

Please sign in to comment.