Skip to content

Commit

Permalink
feat(recover): add submit recover btn custom label
Browse files Browse the repository at this point in the history
  • Loading branch information
akiokio committed Aug 24, 2018
1 parent 415d410 commit 37e31aa
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 9 deletions.
9 changes: 6 additions & 3 deletions dist/ReactSignupLoginComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ var ReactSignupLoginComponent = function (_React$Component) {
styles: _this2.props.styles.recoverPassword,
username: _this2.state.username,
usernameCustomLabel: _this2.props.usernameCustomLabel,
goToLoginCustomLabel: _this2.props.goToLoginCustomLabel
goToLoginCustomLabel: _this2.props.goToLoginCustomLabel,
submitRecoverPasswordCustomLabel: _this2.props.submitRecoverPasswordCustomLabel
});
};
return React.createElement(
Expand Down Expand Up @@ -210,7 +211,8 @@ ReactSignupLoginComponent.propTypes = {
goToSignupCustomLabel: PropTypes.string,
submitLoginCustomLabel: PropTypes.string,
goToLoginCustomLabel: PropTypes.string,
submitSignupCustomLabel: PropTypes.string
submitSignupCustomLabel: PropTypes.string,
submitRecoverPasswordCustomLabel: PropTypes.string
};

ReactSignupLoginComponent.defaultProps = {
Expand All @@ -225,7 +227,8 @@ ReactSignupLoginComponent.defaultProps = {
goToSignupCustomLabel: 'Signup',
goToLoginCustomLabel: 'Login',
submitLoginCustomLabel: 'Signup',
submitSignupCustomLabel: 'Signup'
submitSignupCustomLabel: 'Signup',
submitRecoverPasswordCustomLabel: 'Recover'
};

export default ReactSignupLoginComponent;
8 changes: 5 additions & 3 deletions dist/RecoverPassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ var RecoverPassword = function RecoverPassword(_ref) {
handleRecoverPassword = _ref.handleRecoverPassword,
username = _ref.username,
usernameCustomLabel = _ref.usernameCustomLabel,
goToLoginCustomLabel = _ref.goToLoginCustomLabel;
goToLoginCustomLabel = _ref.goToLoginCustomLabel,
submitRecoverPasswordCustomLabel = _ref.submitRecoverPasswordCustomLabel;
return React.createElement(
'section',
{
Expand Down Expand Up @@ -81,7 +82,7 @@ var RecoverPassword = function RecoverPassword(_ref) {
id: 'submit-recover-password',
name: 'submit-recover-password',
type: 'submit',
value: 'Recover',
value: submitRecoverPasswordCustomLabel,
style: Object.assign({}, localStyles.button, styles.button),
onClick: handleRecoverPassword
})
Expand All @@ -102,7 +103,8 @@ RecoverPassword.propTypes = {
button: PropTypes.object
}),
usernameCustomLabel: PropTypes.string.isRequired,
goToLoginCustomLabel: PropTypes.string.isRequired
goToLoginCustomLabel: PropTypes.string.isRequired,
submitRecoverPasswordCustomLabel: PropTypes.string.isRequired
};

RecoverPassword.defaultProps = {
Expand Down
8 changes: 6 additions & 2 deletions dist/RecoverPassword.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ describe('the main wrapper', function () {
handleRecoverPassword: jest.fn(),
username: '',
usernameCustomLabel: 'Username',
goToLoginCustomLabel: 'Login'
goToLoginCustomLabel: 'Login',
submitRecoverPasswordCustomLabel: 'Help me'
};
it('renders without crashing', function () {
shallow(React.createElement(RecoverPassword, requiredMockProps));
Expand All @@ -26,11 +27,14 @@ describe('the main wrapper', function () {
describe('with custom labels', function () {
var customLabelUsername = 'email?';
var customGoToLogin = 'Back to login';
var customSubmitRecover = 'Help me';
var wrapper = shallow(React.createElement(RecoverPassword, Object.assign({}, requiredMockProps, {
usernameCustomLabel: customLabelUsername,
goToLoginCustomLabel: customGoToLogin
goToLoginCustomLabel: customGoToLogin,
submitRecoverPasswordCustomLabel: customSubmitRecover
})));
it('should render custom labels if provided', function () {
expect(wrapper.find('input[name="submit-recover-password"]').prop('value')).toEqual(customSubmitRecover);
expect(wrapper.find('input[name="username"]').prop('placeholder')).toEqual(customLabelUsername);
expect(wrapper.find('#login-button').text()).toEqual(customGoToLogin);
});
Expand Down
3 changes: 3 additions & 0 deletions src/components/ReactSignupLoginComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class ReactSignupLoginComponent extends React.Component {
username={this.state.username}
usernameCustomLabel={this.props.usernameCustomLabel}
goToLoginCustomLabel={this.props.goToLoginCustomLabel}
submitRecoverPasswordCustomLabel={this.props.submitRecoverPasswordCustomLabel}
/>
);
};
Expand Down Expand Up @@ -184,6 +185,7 @@ ReactSignupLoginComponent.propTypes = {
submitLoginCustomLabel: PropTypes.string,
goToLoginCustomLabel: PropTypes.string,
submitSignupCustomLabel: PropTypes.string,
submitRecoverPasswordCustomLabel: PropTypes.string,
};

ReactSignupLoginComponent.defaultProps = {
Expand All @@ -199,6 +201,7 @@ ReactSignupLoginComponent.defaultProps = {
goToLoginCustomLabel: 'Login',
submitLoginCustomLabel: 'Signup',
submitSignupCustomLabel: 'Signup',
submitRecoverPasswordCustomLabel: 'Recover',
};

export default ReactSignupLoginComponent;
4 changes: 3 additions & 1 deletion src/components/RecoverPassword.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const RecoverPassword = ({
username,
usernameCustomLabel,
goToLoginCustomLabel,
submitRecoverPasswordCustomLabel,
}) => (
<section
id="recover-password-form"
Expand Down Expand Up @@ -72,7 +73,7 @@ const RecoverPassword = ({
id="submit-recover-password"
name="submit-recover-password"
type="submit"
value="Recover"
value={submitRecoverPasswordCustomLabel}
style={Object.assign({}, localStyles.button, styles.button)}
onClick={handleRecoverPassword}
/>
Expand All @@ -94,6 +95,7 @@ RecoverPassword.propTypes = {
}),
usernameCustomLabel: PropTypes.string.isRequired,
goToLoginCustomLabel: PropTypes.string.isRequired,
submitRecoverPasswordCustomLabel: PropTypes.string.isRequired,
};

RecoverPassword.defaultProps = {
Expand Down
4 changes: 4 additions & 0 deletions src/components/RecoverPassword.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('the main wrapper', () => {
username: '',
usernameCustomLabel: 'Username',
goToLoginCustomLabel: 'Login',
submitRecoverPasswordCustomLabel: 'Help me',
};
it('renders without crashing', () => {
shallow(<RecoverPassword {...requiredMockProps} />);
Expand All @@ -26,14 +27,17 @@ describe('the main wrapper', () => {
describe('with custom labels', () => {
const customLabelUsername = 'email?';
const customGoToLogin = 'Back to login';
const customSubmitRecover = 'Help me';
const wrapper = shallow(
<RecoverPassword
{...requiredMockProps}
usernameCustomLabel={customLabelUsername}
goToLoginCustomLabel={customGoToLogin}
submitRecoverPasswordCustomLabel={customSubmitRecover}
/>,
);
it('should render custom labels if provided', () => {
expect(wrapper.find('input[name="submit-recover-password"]').prop('value')).toEqual(customSubmitRecover);
expect(wrapper.find('input[name="username"]').prop('placeholder')).toEqual(customLabelUsername);
expect(wrapper.find('#login-button').text()).toEqual(customGoToLogin);
});
Expand Down
1 change: 1 addition & 0 deletions src/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,6 @@ storiesOf('React signup login component', module)
goToLoginCustomLabel="Back up login"
submitSignupCustomLabel="Custom send"
goToSignupCustomLabel="Create account?"
submitRecoverPasswordCustomLabel="Help me!"
/>
));

0 comments on commit 37e31aa

Please sign in to comment.