Skip to content
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

Refactor/lint onboarding slides #4240

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ preact-render-spy (1 nodes)
<label htmlFor="checked_code_of_conduct">
<input
type="checkbox"
name="checked_code_of_conduct"
id="checked_code_of_conduct"
name="checked_code_of_conduct"
checked={false}
onChange={[Function bound handleChange]}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint camelcase: "off" */

import { h, Component } from 'preact';
import PropTypes from 'prop-types';

Expand Down Expand Up @@ -115,8 +117,10 @@ class EmailTermsConditionsForm extends Component {
BACK
</button>
<div
/* eslint-disable react/no-danger */
dangerouslySetInnerHTML={{ __html: textShowing }}
style={{ height: '360px', overflow: 'scroll' }}
/* eslint-enable react/no-danger */
/>
</div>
</div>
Expand All @@ -131,8 +135,8 @@ class EmailTermsConditionsForm extends Component {
<label htmlFor="checked_code_of_conduct">
<input
type="checkbox"
name="checked_code_of_conduct"
id="checked_code_of_conduct"
name="checked_code_of_conduct"
checked={checked_code_of_conduct}
onChange={this.handleChange}
/>
Expand Down
54 changes: 30 additions & 24 deletions app/javascript/onboarding/components/PersonalInfoForm.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
/* eslint camelcase: "off" */

import { h, Component } from 'preact';
import PropTypes from 'prop-types';

import Navigation from './Navigation';
import { getContentOfToken } from '../utilities';

const setupFormTextField = ({ labelText = '', entityName = '', onChangeCallback }) => {
const setupFormTextField = ({
labelText = '',
entityName = '',
onChangeCallback,
}) => {
return (
<label htmlFor={entityName}>
{labelText}
Expand All @@ -16,8 +22,8 @@ const setupFormTextField = ({ labelText = '', entityName = '', onChangeCallback
maxLength="60"
/>
</label>
)
}
);
};

class PersonalInfoForm extends Component {
constructor(props) {
Expand Down Expand Up @@ -96,27 +102,21 @@ class PersonalInfoForm extends Component {
<div className="onboarding-content about">
<h2>About You!</h2>
<form>
{
setupFormTextField({
labelText: 'Where are you located?',
entityName: 'location',
onChangeCallback: this.handleChange
})
}
{
setupFormTextField({
labelText: 'What is your title?',
entityName: 'employment_title',
onChangeCallback: this.handleChange
})
}
{
setupFormTextField({
labelText: 'Where do you work?',
entityName: 'employer_name',
onChangeCallback: this.handleChange
})
}
{setupFormTextField({
labelText: 'Where are you located?',
entityName: 'location',
onChangeCallback: this.handleChange,
})}
{setupFormTextField({
labelText: 'What is your title?',
entityName: 'employment_title',
onChangeCallback: this.handleChange,
})}
{setupFormTextField({
labelText: 'Where do you work?',
entityName: 'employer_name',
onChangeCallback: this.handleChange,
})}
</form>
</div>
<Navigation prev={prev} next={this.onSubmit} />
Expand All @@ -125,6 +125,12 @@ class PersonalInfoForm extends Component {
}
}

setupFormTextField.propTypes = {
labelText: PropTypes.string.isRequired,
entityName: PropTypes.string.isRequired,
onChangeCallback: PropTypes.func.isRequired,
};

PersonalInfoForm.propTypes = {
prev: PropTypes.func.isRequired,
next: PropTypes.string.isRequired,
Expand Down
8 changes: 4 additions & 4 deletions app/javascript/onboarding/components/SlideContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ const SlideContent = ({
);

SlideContent.propTypes = {
imageSource: PropTypes.string,
imageAlt: PropTypes.string,
content: PropTypes.string,
style: PropTypes.object,
imageSource: PropTypes.string.isRequired,
imageAlt: PropTypes.string.isRequired,
content: PropTypes.string.isRequired,
style: PropTypes.shape().isRequired, // bypassing shape validator to allow for additional attributes
};

export default SlideContent;