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

Milestone 54 / Convert Navbar to React #2306

Merged
merged 40 commits into from
Jun 8, 2017
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
4bd85f2
Navbar dropdowns conversion to React (#2230)
joykare May 17, 2017
25c289a
Merge branch 'development' into brent-milestone-54
brent-hoover May 18, 2017
e4cbd77
Convert login views to React (#2250)
May 19, 2017
b4ea7a8
Merge branch 'development' into brent-milestone-54
brent-hoover May 19, 2017
0ee4c7d
Merge branch 'development' into brent-milestone-54
brent-hoover May 23, 2017
43b7dc7
[WIP]Main navbar container conversion to React (#2277)
joykare May 23, 2017
3c6bcd8
Convert to react: Tag navigation (#2251)
impactmass May 23, 2017
be2f9dc
Merge branch 'development' into brent-milestone-54
brent-hoover May 23, 2017
84b23f2
Init toggle visibility
impactmass May 24, 2017
4b98e66
Close tags with overlay
impactmass May 24, 2017
75d6c7f
Remove JQuery references(part 1)
May 24, 2017
fd3b4ab
Merge branch 'development' into brent-milestone-54
May 24, 2017
31f2037
Add router.go for tag click
impactmass May 25, 2017
b1154e4
Merge branch 'development' into brent-milestone-54
brent-hoover May 26, 2017
4f7756e
Mobile fixes and remove blaze files
impactmass May 26, 2017
351f913
Fix click on mobile
impactmass May 30, 2017
fed360a
Remove jquery
impactmass May 30, 2017
d758ed6
Merge branch 'development' into brent-milestone-54
impactmass May 30, 2017
8458bb3
Remove jquery .closest
impactmass May 30, 2017
c090dcb
Merge branch 'development' into brent-milestone-54
impactmass May 31, 2017
6192884
UI tagnav classes update
impactmass May 31, 2017
b3b1dae
Merge branch 'development' into brent-milestone-54
impactmass Jun 1, 2017
a9eeb4d
Fixes
impactmass Jun 1, 2017
8e6e705
Fix undefined refs after merge with development
impactmass Jun 1, 2017
b36709c
Remove unused vars
mikemurray Jun 1, 2017
3ceff6b
Editing should turn off on toggle
impactmass Jun 2, 2017
9d787a8
Use Translation component over data-i18n
Jun 2, 2017
8649653
Fix Brand name glitch
joykare Jun 5, 2017
24cdc7d
Merge branch 'development' into brent-milestone-54
impactmass Jun 6, 2017
2070e71
Merge branch 'development' into brent-milestone-54
Jun 7, 2017
328a80d
Prefer standalone PropTypes import over React.PropTypes
Jun 7, 2017
fcd02ae
Inport i18next and Reaction in same line
Jun 7, 2017
8cefcb0
Space at end of self-closing tag
Jun 7, 2017
7759560
One-lining imports
Jun 8, 2017
b260dc0
Place '&nbsp' inside span for less random-looking code
Jun 8, 2017
408a53a
Add comment about style
impactmass Jun 8, 2017
ffcaab6
Merge branch 'development' into brent-milestone-54
impactmass Jun 8, 2017
3a09838
Use Divider component as separator
Jun 8, 2017
1fba3c8
Merge branch 'development' into brent-milestone-54
Jun 8, 2017
88dec41
Merge branch 'development' into brent-milestone-54
mikemurray Jun 8, 2017
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
3 changes: 3 additions & 0 deletions client/modules/accounts/components/auth/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export LoginButtons from "./loginButtons";
export SignIn from "./signIn";
export SignUp from "./signUp";
76 changes: 76 additions & 0 deletions client/modules/accounts/components/auth/loginButtons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React, { Component } from "react";
import PropTypes from "prop-types";
import { Button, Divider, Translation } from "/imports/plugins/core/ui/client/components";

class LoginButtons extends Component {
static propTypes = {
capitalizeName: PropTypes.func,
currentView: PropTypes.string,
loginServices: PropTypes.func,
onSeparator: PropTypes.func,
onSocialClick: PropTypes.func
}

renderLoginButtons() {
const enabledServices = this.props.loginServices().filter((service) =>{
return service.enabled;
});

return (
<div>
{this.props.loginServices &&
enabledServices.map((service) => (
<Button
key={service._id}
className={`btn-block provider-${service.name}`}
primary={true}
bezelStyle="solid"
type="button"
data-provider={`${service.name}`}
onClick={() => this.props.onSocialClick(service.name)}
>
<i className={`fa fa-${service.name}`} />

{this.props.currentView === "loginFormSignInView" &&
<span>
<Translation defaultValue="Sign in with" i18nKey="accountsUI.signInWith" />
</span>
}
{this.props.currentView === "loginFormSignUpView" &&
<span>
<Translation defaultValue="Sign up with" i18nKey="accountsUI.signUpWith" />
</span>
}

<span>
&nbsp;
<Translation defaultValue={this.props.capitalizeName(service.name)} i18nKey={`social.${service.name}`} />
</span>
</Button>
))
}
</div>
);
}

renderSeparator() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a <Divider /> component, would it work for what you are trying to do here?
https://styleguide.reactioncommerce.com/reaction/guide/divider

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No @kieckhafer, it wouldn't. This renders the word or between the social login buttons and the auth forms.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can render words as well with <Divider label="or" />
@rymorgan what do you think, this is more a design question than anything else

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kieha I agree with @kieckhafer it should be the divider component with 'or' as the label.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Last thing is the Avatar component, but it seems like that PR won't be pulled in yet so i'll create a new issue for it and approve this.

if (this.props.onSeparator()) {
return (
<div className="loginForm-seperator">
<Divider id="auth-divider" label="or" i18nKeyLabel="accountsUI.or" />
</div>
);
}
}

render() {
return (
<div>
{this.renderLoginButtons()}
{this.renderSeparator()}
</div>
);
}
}

export default LoginButtons;
182 changes: 182 additions & 0 deletions client/modules/accounts/components/auth/signIn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
import React, { Component } from "react";
import PropTypes from "prop-types";
import classnames from "classnames";
import { Button, TextField, Translation } from "/imports/plugins/core/ui/client/components";

class SignIn extends Component {
static propTypes = {
credentials: PropTypes.object,
isLoading: PropTypes.bool,
loginFormMessages: PropTypes.func,
messages: PropTypes.object,
onError: PropTypes.func,
onForgotPasswordClick: PropTypes.func,
onFormSubmit: PropTypes.func,
onSignUpClick: PropTypes.func,
uniqueId: PropTypes.string
}

constructor(props) {
super(props);

this.state = {
email: props.credentials.email,
password: props.credentials.password
};

this.handleFieldChange = this.handleFieldChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}

handleFieldChange = (event, value, field) => {
this.setState({
[field]: value
});
}

handleSubmit = (event) => {
if (this.props.onFormSubmit) {
this.props.onFormSubmit(event, this.state.email, this.state.password);
}
}

renderEmailErrors() {
if (this.props.onError(this.props.messages.errors && this.props.messages.errors.email)) {
return (
<span className="help-block">
<Translation
defaultValue={this.props.messages.errors.email.reason}
i18nKey={this.props.messages.errors.email.i18nKeyReason}
/>
</span>
);
}
}

renderPasswordErrors() {
return (
<span className="help-block">
{this.props.onError(this.props.messages.errors && this.props.messages.errors.password) &&
this.props.messages.errors.password.map((error, i) => (
<Translation
key={i}
defaultValue={error.reason}
i18nKey={error.i18nKeyReason}
/>
))
}
</span>
);
}

renderFormMessages() {
if (this.props.loginFormMessages) {
return (
<div>
{this.props.loginFormMessages()}
</div>
);
}
}

renderSpinnerOnWait() {
if (this.props.isLoading === true) {
return (
<div style={{ textAlign: "center" }}>
<i className="fa fa-spinner fa-spin" />
</div>
);
}
return (
<Button
className="btn-block"
primary={true}
bezelStyle="solid"
i18nKeyLabel="accountsUI.signIn"
label="Sign In"
type="submit"
tabIndex="3"
eventAction="submitSignInForm"
/>
);
}

render() {
const emailClasses = classnames({
"form-group": true,
"form-group-email": true,
"has-error has-feedback": this.props.onError(this.props.messages.errors && this.props.messages.errors.email)
});

const passwordClasses = classnames({
"form-group": true,
"has-error has-feedback": this.props.onError(this.props.messages.errors && this.props.messages.errors.password)
});
return (
<div>
<div className="loginForm-title">
<h2>
<Translation defaultValue="Sign In" i18nKey="accountsUI.signIn" />
</h2>
</div>

<form className="login-form" onSubmit={this.handleSubmit} noValidate>

{this.renderFormMessages()}

<div className={emailClasses}>
<TextField
i18nKeyLabel="accountsUI.emailAddress"
label="Email"
name="email"
type="email"
tabIndex="1"
id={`email-${this.props.uniqueId}`}
value={this.state.email}
onChange={this.handleFieldChange}
/>
{this.renderEmailErrors()}
</div>

<div className={passwordClasses}>
<TextField
i18nKeyLabel="accountsUI.password"
label="Password"
name="password"
type="password"
tabIndex="2"
id={`password-${this.props.uniqueId}`}
value={this.state.password}
onChange={this.handleFieldChange}
/>
{this.renderPasswordErrors()}
</div>

<div className="form-group">
{this.renderSpinnerOnWait()}
</div>

<div className="form-group flex flex-justify-spaceBetween">
<a
href="#"
tabIndex="4"
onClick={this.props.onForgotPasswordClick}
>
<Translation defaultValue="Reset Password" i18nKey="accountsUI.forgotPassword" />
</a>
<a
href="#"
tabIndex="5"
onClick={this.props.onSignUpClick}
>
<Translation defaultValue="Register" i18nKey="accountsUI.signUp" />
</a>
</div>

</form>
</div>
);
}
}

export default SignIn;
Loading