Skip to content

Commit 352783a

Browse files
committed
Merge branch 'feature/mobile-examples' of https://github.com/ghalestrilo/p5.js-web-editor into feature/mobile-files-tab
2 parents 41ecf10 + ceb8dc5 commit 352783a

File tree

6 files changed

+93
-58
lines changed

6 files changed

+93
-58
lines changed

client/components/Nav.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,13 +608,13 @@ class Nav extends React.PureComponent {
608608
<ul className="nav__items-right" title="user-menu">
609609
<li className="nav__item">
610610
<Link to="/login" className="nav__auth-button">
611-
<span className="nav__item-header">{this.props.t('Nav.Login.Login')}</span>
611+
<span className="nav__item-header">{this.props.t('Nav.Login')}</span>
612612
</Link>
613613
</li>
614-
<span className="nav__item-or">{this.props.t('Nav.Login.LoginOr')}</span>
614+
<span className="nav__item-or">{this.props.t('Nav.LoginOr')}</span>
615615
<li className="nav__item">
616616
<Link to="/signup" className="nav__auth-button">
617-
<span className="nav__item-header">{this.props.t('Nav.Login.SignUp')}</span>
617+
<span className="nav__item-header">{this.props.t('Nav.SignUp')}</span>
618618
</Link>
619619
</li>
620620
</ul>

client/modules/User/components/LoginForm.jsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3-
3+
import { withTranslation } from 'react-i18next';
4+
import i18n from 'i18next';
45
import Button from '../../../common/Button';
56

67
import { domOnlyProps } from '../../../utils/reduxFormUtils';
@@ -18,12 +19,10 @@ function LoginForm(props) {
1819
onSubmit={handleSubmit(props.validateAndLoginUser.bind(this, props.previousPath))}
1920
>
2021
<p className="form__field">
21-
<label htmlFor="email" className="form__label">
22-
Email or Username
23-
</label>
22+
<label htmlFor="email" className="form__label">{props.t('LoginForm.UsernameOrEmail')}</label>
2423
<input
2524
className="form__input"
26-
aria-label="email or username"
25+
aria-label={props.t('LoginForm.UsernameOrEmailARIA')}
2726
type="text"
2827
id="email"
2928
{...domOnlyProps(email)}
@@ -33,12 +32,10 @@ function LoginForm(props) {
3332
)}
3433
</p>
3534
<p className="form__field">
36-
<label htmlFor="password" className="form__label">
37-
Password
38-
</label>
35+
<label htmlFor="password" className="form__label">{props.t('LoginForm.Password')}</label>
3936
<input
4037
className="form__input"
41-
aria-label="password"
38+
aria-label={props.t('LoginForm.PasswordARIA')}
4239
type="password"
4340
id="password"
4441
{...domOnlyProps(password)}
@@ -47,8 +44,10 @@ function LoginForm(props) {
4744
<span className="form-error">{password.error}</span>
4845
)}
4946
</p>
50-
<Button type="submit" disabled={submitting || pristine}>
51-
Log In
47+
<Button
48+
type="submit"
49+
disabled={submitting || pristine}
50+
>{props.t('LoginForm.Submit')}
5251
</Button>
5352
</form>
5453
);
@@ -65,6 +64,7 @@ LoginForm.propTypes = {
6564
pristine: PropTypes.bool,
6665
invalid: PropTypes.bool,
6766
previousPath: PropTypes.string.isRequired,
67+
t: PropTypes.func.isRequired
6868
};
6969

7070
LoginForm.defaultProps = {
@@ -73,4 +73,4 @@ LoginForm.defaultProps = {
7373
invalid: false,
7474
};
7575

76-
export default LoginForm;
76+
export default withTranslation()(LoginForm);

client/modules/User/components/SocialAuthButton.jsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
33
import styled from 'styled-components';
4+
import i18n from 'i18next';
5+
import { withTranslation } from 'react-i18next';
46

57
import { remSize } from '../../../theme';
68

@@ -12,11 +14,6 @@ const authUrls = {
1214
google: '/auth/google'
1315
};
1416

15-
const labels = {
16-
github: 'Login with GitHub',
17-
google: 'Login with Google'
18-
};
19-
2017
const icons = {
2118
github: GithubIcon,
2219
google: GoogleIcon
@@ -31,11 +28,15 @@ const StyledButton = styled(Button)`
3128
width: ${remSize(300)};
3229
`;
3330

34-
function SocialAuthButton({ service }) {
31+
function SocialAuthButton({ service, t }) {
3532
const ServiceIcon = icons[service];
33+
const labels = {
34+
github: t('SocialAuthButton.Github'),
35+
google: t('SocialAuthButton.Google')
36+
};
3637
return (
3738
<StyledButton
38-
iconBefore={<ServiceIcon aria-label={`${service} logo`} />}
39+
iconBefore={<ServiceIcon aria-label={t('SocialAuthButton.LogoARIA', { serviceauth: service })} />}
3940
href={authUrls[service]}
4041
>
4142
{labels[service]}
@@ -46,7 +47,10 @@ function SocialAuthButton({ service }) {
4647
SocialAuthButton.services = services;
4748

4849
SocialAuthButton.propTypes = {
49-
service: PropTypes.oneOf(['github', 'google']).isRequired
50+
service: PropTypes.oneOf(['github', 'google']).isRequired,
51+
t: PropTypes.func.isRequired
5052
};
5153

52-
export default SocialAuthButton;
54+
const SocialAuthButtonPublic = withTranslation()(SocialAuthButton);
55+
SocialAuthButtonPublic.services = services;
56+
export default SocialAuthButtonPublic;

client/modules/User/pages/LoginView.jsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import React from 'react';
33
import { reduxForm } from 'redux-form';
44
import { Link, browserHistory } from 'react-router';
55
import { Helmet } from 'react-helmet';
6+
import { withTranslation } from 'react-i18next';
7+
import i18n from 'i18next';
68
import { validateAndLoginUser } from '../actions';
79
import LoginForm from '../components/LoginForm';
810
import { validateLogin } from '../../../utils/reduxFormUtils';
@@ -34,23 +36,23 @@ class LoginView extends React.Component {
3436
<Nav layout="dashboard" />
3537
<main className="form-container">
3638
<Helmet>
37-
<title>p5.js Web Editor | Login</title>
39+
<title>{this.props.t('LoginView.Title')}</title>
3840
</Helmet>
3941
<div className="form-container__content">
40-
<h2 className="form-container__title">Log In</h2>
42+
<h2 className="form-container__title">{this.props.t('LoginView.Login')}</h2>
4143
<LoginForm {...this.props} />
42-
<h2 className="form-container__divider">Or</h2>
44+
<h2 className="form-container__divider">{this.props.t('LoginView.LoginOr')}</h2>
4345
<div className="form-container__stack">
4446
<SocialAuthButton service={SocialAuthButton.services.github} />
4547
<SocialAuthButton service={SocialAuthButton.services.google} />
4648
</div>
4749
<p className="form__navigation-options">
48-
Don&apos;t have an account?&nbsp;
49-
<Link className="form__signup-button" to="/signup">Sign Up</Link>
50+
{this.props.t('LoginView.DontHaveAccount')}
51+
<Link className="form__signup-button" to="/signup">{this.props.t('LoginView.SignUp')}</Link>
5052
</p>
5153
<p className="form__navigation-options">
52-
Forgot your password?&nbsp;
53-
<Link className="form__reset-password-button" to="/reset-password">Reset your password</Link>
54+
{this.props.t('LoginView.ForgotPassword')}
55+
<Link className="form__reset-password-button" to="/reset-password"> {this.props.t('LoginView.ResetPassword')}</Link>
5456
</p>
5557
</div>
5658
</main>
@@ -76,7 +78,8 @@ LoginView.propTypes = {
7678
previousPath: PropTypes.string.isRequired,
7779
user: PropTypes.shape({
7880
authenticated: PropTypes.bool
79-
})
81+
}),
82+
t: PropTypes.func.isRequired
8083
};
8184

8285
LoginView.defaultProps = {
@@ -85,8 +88,8 @@ LoginView.defaultProps = {
8588
}
8689
};
8790

88-
export default reduxForm({
91+
export default withTranslation()(reduxForm({
8992
form: 'login',
9093
fields: ['email', 'password'],
9194
validate: validateLogin
92-
}, mapStateToProps, mapDispatchToProps)(LoginView);
95+
}, mapStateToProps, mapDispatchToProps)(LoginView));

translations/locales/en-US/translations.json

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,9 @@
3333
"Lang": "Language",
3434
"BackEditor": "Back to Editor",
3535
"WarningUnsavedChanges": "Are you sure you want to leave this page? You have unsaved changes.",
36-
"Login": {
37-
"Login": "Log in",
38-
"LoginOr": "or",
39-
"SignUp": "Sign up",
40-
"Email": "email",
41-
"Username": "username",
42-
"LoginGithub": "Login with Github",
43-
"LoginGoogle": "Login with Google",
44-
"DontHaveAccount": "Don't have an account?",
45-
"ForgotPassword": "Forgot your password?",
46-
"ResetPassword": "Reset your password"
47-
},
36+
"Login": "Log in",
37+
"LoginOr": "or",
38+
"SignUp": "Sign up",
4839
"Auth": {
4940
"Welcome": "Welcome",
5041
"Hello": "Hello",
@@ -57,6 +48,29 @@
5748
"LogOut": "Log Out"
5849
}
5950
},
51+
"LoginForm": {
52+
"UsernameOrEmail": "Email or Username",
53+
"UsernameOrEmailARIA": "Email or Username",
54+
"Password": "Password",
55+
"PasswordARIA": "Password",
56+
"Submit": "Log In"
57+
},
58+
"LoginView": {
59+
"Title": "p5.js Web Editor | Login",
60+
"Login": "Log In",
61+
"LoginOr": "or",
62+
"SignUp": "Sign Up",
63+
"Email": "email",
64+
"Username": "username",
65+
"DontHaveAccount": "Don't have an account? ",
66+
"ForgotPassword": "Forgot your password? ",
67+
"ResetPassword": "Reset your password"
68+
},
69+
"SocialAuthButton": {
70+
"Github": "Login with Github",
71+
"LogoARIA": "{{serviceauth}} logo",
72+
"Google": "Login with Google"
73+
},
6074
"About": {
6175
"Title": "About",
6276
"TitleHelmet": "p5.js Web Editor | About",

translations/locales/es-419/translations.json

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,9 @@
3333
"Lang": "Lenguaje",
3434
"BackEditor": "Regresa al editor",
3535
"WarningUnsavedChanges": "¿Realmente quieres salir de la página? Tienes cambios sin guardar.",
36-
"Login": {
37-
"Login": "Ingresa",
38-
"LoginOr": "o",
39-
"SignUp": "registráte",
40-
"Email": "correo electrónico",
41-
"Username": "Identificación",
42-
"LoginGithub": "Ingresa con Github",
43-
"LoginGoogle": "Ingresa con Google",
44-
"DontHaveAccount": "¿No tienes cuenta?",
45-
"ForgotPassword": "¿Olvidaste tu contraseña?",
46-
"ResetPassword": "Regenera tu contraseña"
47-
},
36+
"Login": "Ingresa",
37+
"LoginOr": "o",
38+
"SignUp": "Registráte",
4839
"Auth": {
4940
"Welcome": "Hola",
5041
"Hello": "Hola",
@@ -57,6 +48,29 @@
5748
"LogOut": "Cerrar sesión"
5849
}
5950
},
51+
"LoginForm": {
52+
"UsernameOrEmail": "Correo o Identificación",
53+
"UsernameOrEmailARIA": "Introduce Correo o Identificación",
54+
"Password": "Contraseña",
55+
"PasswordARIA": "Contraseña",
56+
"Submit": "Ingresa"
57+
},
58+
"LoginView": {
59+
"Title": " Editor Web p5.js | Ingreso",
60+
"Login": "Ingresa",
61+
"LoginOr": "o",
62+
"SignUp": "Registráte",
63+
"Email": "correo electrónico",
64+
"Username": "Identificación",
65+
"DontHaveAccount": "¿No tienes cuenta? ",
66+
"ForgotPassword": "¿Olvidaste tu contraseña? ",
67+
"ResetPassword": "Regenera tu contraseña"
68+
},
69+
"SocialAuthButton": {
70+
"Github": "Ingresa con Github",
71+
"LogoARIA": "Logo de {{serviceauth}}",
72+
"Google": "Ingresa con Google"
73+
},
6074
"About": {
6175
"Title": "Acerca de",
6276
"TitleHelmet": "Editor Web p5.js | Acerca de",

0 commit comments

Comments
 (0)