-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement ReCaptcha component #317
Conversation
src/components/ReCaptcha/index.js
Outdated
const getUrl = () => { | ||
if (lang) { | ||
return `https://www.google.com/recaptcha/api.js?render=explicit&hl=${lang}`; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put this in other file(get-url.js) in order to test it and then below call it as getUrl(lang)
/** The color theme of the widget. */ | ||
theme: PropTypes.oneOf(['light', 'dark']), | ||
/** The size of the widget. */ | ||
size: PropTypes.oneOf(['normal', 'compact']), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here you forgot to pass a tabIndex prop that defaults to 0
src/components/ReCaptcha/index.js
Outdated
error: undefined, | ||
onChange: () => {}, | ||
className: undefined, | ||
style: {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in all components we are setting style to undefined
src/components/ReCaptcha/loader.js
Outdated
import RenderIf from '../RenderIf'; | ||
import './styles.css'; | ||
|
||
export default class ReCaptchaLoader extends Component { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it better call this ReCaptchaComponent and the file component.js
src/components/ReCaptcha/loader.js
Outdated
explicit: true, | ||
sitekey: value, | ||
theme, | ||
size, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pass tabIndex here
src/components/ReCaptcha/loader.js
Outdated
const { error, style } = this.props; | ||
return ( | ||
<div className={this.getContainerClassNames()} style={style}> | ||
<div id="reCaptcha-container" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id="recaptcha-container"
src/components/ReCaptcha/loader.js
Outdated
return ( | ||
<div className={this.getContainerClassNames()} style={style}> | ||
<div id="reCaptcha-container" /> | ||
<RenderIf isTrue={error}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review the console and you will see a warning because you are not passing a bool here your are passing undefined, a node or a string. So:
<RenderIf isTrue={!!error}>
src/components/ReCaptcha/loader.js
Outdated
} | ||
|
||
ReCaptchaLoader.propTypes = { | ||
/** Specifies the site key for the recaptcha. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here you don't need to put description, they are only needed in the index.js
src/components/ReCaptcha/loader.js
Outdated
ReCaptchaLoader.defaultProps = { | ||
value: undefined, | ||
theme: 'light', | ||
size: 'normal', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And you can put the props that receive a value different form undefined and null as required.
In this case theme, size, onChange can be set as required since they come from index with 'light', 'normal' and () => {}.
src/components/ReCaptcha/loader.js
Outdated
renderReCaptcha() { | ||
const { value, theme, size, onChange } = this.props; | ||
window.grecaptcha.render('reCaptcha-container', { | ||
explicit: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this
} | ||
|
||
renderReCaptcha() { | ||
const { value, theme, size, tabIndex, onChange } = this.props; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 6 locations. Consider refactoring.
Pull Request Test Coverage Report for Build 1481
💛 - Coveralls |
Code Climate has analyzed commit a7be0f6 and detected 1 issue on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
fixes #290