Skip to content

Commit 53729e2

Browse files
feat(login): login page and progress on login form
1 parent 7e350d4 commit 53729e2

File tree

16 files changed

+270
-47
lines changed

16 files changed

+270
-47
lines changed

src/App.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ import React, { Fragment } from 'react';
77
import { HashRouter as Router, Route } from 'react-router-dom';
88
import { CssBaseline } from '@material-ui/core';
99

10-
import { Home } from './pages';
10+
import { Home, Login } from './pages';
1111

1212
const App = () => (
1313
<Fragment>
1414
<CssBaseline />
1515
<Router>
16-
<Route exact path="/" component={Home} />
16+
<Fragment>
17+
<Route exact path="/" component={Home} />
18+
<Route path="/login" component={Login} />
19+
</Fragment>
1720
</Router>
1821
</Fragment>
1922
);

src/components/LoginForm/LoginForm.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/**
2+
* @file LoginForm.js
3+
* Exports a component that allows users to log into EditVR.
4+
*/
5+
6+
import React, { Component } from 'react';
7+
import PropTypes from 'prop-types';
8+
import { TextField, Button, withStyles } from '@material-ui/core';
9+
10+
import LoginFormStyles from './LoginForm.style';
11+
12+
class LoginForm extends Component {
13+
static propTypes = {
14+
classes: PropTypes.shape({
15+
textField: PropTypes.string.isRequired,
16+
button: PropTypes.string.isRequired
17+
}).isRequired
18+
};
19+
20+
state = {
21+
username: null,
22+
password: null,
23+
apiLoading: false,
24+
apiMessage: null
25+
};
26+
27+
/**
28+
* Handles field update action.
29+
*
30+
* @param {object} event - Field update event.
31+
*/
32+
handleFieldUpdate = event => {
33+
const state = {};
34+
state[event.target.id] = event.target.value;
35+
this.setState(state);
36+
};
37+
38+
/**
39+
* Handles a login form submit action.
40+
*
41+
* @param {object} event - Submit event object.
42+
*/
43+
handleSubmit = event => {};
44+
45+
/**
46+
* {@inheretdoc}
47+
*/
48+
render() {
49+
const { classes } = this.props;
50+
const { apiLoading, apiMessage } = this.state;
51+
52+
return (
53+
<form onSubmit={this.handleSubmit}>
54+
<TextField
55+
id="username"
56+
label="Username"
57+
type="text"
58+
required
59+
onChange={this.handleFieldUpdate}
60+
className={classes.textField}
61+
/>
62+
<TextField
63+
id="password"
64+
label="Password"
65+
type="password"
66+
required
67+
onChange={this.handleFieldUpdate}
68+
className={classes.textField}
69+
/>
70+
<Button
71+
variant="raised"
72+
color="primary"
73+
type="submit"
74+
className={classes.button}
75+
>
76+
Log In
77+
</Button>
78+
</form>
79+
);
80+
}
81+
}
82+
83+
export default withStyles(LoginFormStyles)(LoginForm);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @file LoginForm.style.js
3+
* Exports LoginForm component styles.
4+
*/
5+
6+
export default theme => ({
7+
textField: {
8+
width: '100%',
9+
marginTop: `${theme.spacing.unit * 2}px`
10+
},
11+
button: {
12+
marginTop: `${theme.spacing.unit * 3}px`,
13+
marginRight: theme.spacing.unit
14+
}
15+
});

src/components/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* @file index.js
3+
* Exports all components.
4+
*/
5+
6+
import LoginForm from './LoginForm/LoginForm';
7+
8+
export { LoginForm };

src/layouts/Footer.style.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,17 @@ export default () => ({
1515
position: 'relative'
1616
},
1717
logo: {
18-
width: '230px'
18+
maxWidth: '230px',
19+
width: '100%'
1920
},
2021
text: {
2122
color: 'rgba(255,255,255,.5)',
22-
left: '86px',
23-
top: '-1px',
24-
position: 'absolute'
23+
marginBottom: '10px'
24+
},
25+
'@media (min-width: 380px)': {
26+
text: {
27+
marginLeft: '86px',
28+
marginBottom: '-20px'
29+
}
2530
}
2631
});

src/layouts/Layout.style.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default theme => ({
1212
position: 'absolute',
1313
overflowX: 'scroll'
1414
},
15-
centerColumn: {
15+
thinWrapper: {
1616
padding: '0 1rem',
1717
maxWidth: 600,
1818
margin: '0 auto',
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @file Home.js
3-
* Exports a React component that renders EditVR's home page layout.
2+
* @file ThinLayout.js
3+
* Exports a React component that renders EditVR's thin layout.
44
*/
55

66
import React from 'react';
@@ -12,28 +12,26 @@ import Footer from './Footer';
1212
import Header from './Header';
1313
import LayoutStyles from './Layout.style';
1414

15-
const Home = ({ children, classes }) => (
15+
const ThinLayout = ({ children, classes }) => (
1616
<div id="layout__wrapper" className={classes.wrapper}>
17-
<div id="layout__center" className={classes.centerColumn}>
17+
<div id="layout__thin-wrapper" className={classes.thinWrapper}>
1818
<Header />
1919
{children}
2020
<Footer />
2121
</div>
2222
</div>
2323
);
2424

25-
Home.propTypes = {
25+
ThinLayout.propTypes = {
2626
children: PropTypes.node,
2727
classes: PropTypes.shape({
2828
wrapper: PropTypes.string.isRequired,
29-
centerColumn: PropTypes.string.isRequired
29+
thinWrapper: PropTypes.string.isRequired
3030
}).isRequired
3131
};
3232

33-
Home.defaultProps = {
33+
ThinLayout.defaultProps = {
3434
children: null
3535
};
3636

37-
const HomeLayout = ThemeProvider(withStyles(LayoutStyles)(Home));
38-
39-
export { HomeLayout };
37+
export default ThemeProvider(withStyles(LayoutStyles)(ThinLayout));

src/layouts/HomeLayout.test.js renamed to src/layouts/ThinLayout.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
/**
2-
* @file HomeLayout.test.js
3-
* Contains tests for HomeLayout.js.
2+
* @file ThinLayout.test.js
3+
* Contains tests for ThinLayout.js.
44
*/
55

66
import React from 'react';
77
import renderer from 'react-test-renderer';
88

9-
import { HomeLayout } from './index';
9+
import { ThinLayout } from './index';
1010

11-
describe('<HomeLayout />', () => {
11+
describe('<ThinLayout />', () => {
1212
it('Matches its snapshot', () => {
1313
expect(
1414
renderer
1515
.create(
16-
<HomeLayout>
16+
<ThinLayout>
1717
<div>child</div>
18-
</HomeLayout>
18+
</ThinLayout>
1919
)
2020
.toJSON()
2121
).toMatchSnapshot();
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`<ThinLayout /> Matches its snapshot 1`] = `
4+
<div
5+
className="ThinLayout-wrapper-1"
6+
id="layout__wrapper"
7+
>
8+
<div
9+
className={undefined}
10+
id="layout__thin-wrapper"
11+
>
12+
<header
13+
className="Header-wrapper-3"
14+
>
15+
<img
16+
alt="EditVR logo"
17+
className="Header-logo-4"
18+
src="editvr-logo.svg"
19+
/>
20+
</header>
21+
<div>
22+
child
23+
</div>
24+
<footer
25+
className="Footer-wrapper-5"
26+
>
27+
<div
28+
className="Footer-elements-6"
29+
>
30+
<a
31+
href="https://fourkitchens.com"
32+
>
33+
<p
34+
className="MuiTypography-root-9 MuiTypography-body1-18 Footer-text-8"
35+
type="body1"
36+
>
37+
EditVR is a product of
38+
</p>
39+
<img
40+
alt="Four Kitchens"
41+
className="Footer-logo-7"
42+
src="4k-logo-reversed.svg"
43+
/>
44+
</a>
45+
</div>
46+
</footer>
47+
</div>
48+
</div>
49+
`;

src/layouts/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
* Exports all layout components.
44
*/
55

6-
export * from './HomeLayout';
6+
import ThinLayout from './ThinLayout';
7+
8+
export { ThinLayout };

src/pages/Home.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/pages/Home/Home.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* @file Home.js
3+
* Exports a React component that renders EditVR's home page.
4+
*/
5+
6+
import React from 'react';
7+
import PropTypes from 'prop-types';
8+
import { Typography, Button, withStyles } from '@material-ui/core';
9+
import { NavLink } from 'react-router-dom';
10+
11+
import { ThinLayout } from '../../layouts';
12+
import HomeStyles from './Home.style';
13+
14+
const Home = ({ classes }) => (
15+
<ThinLayout>
16+
<Typography type="body1">
17+
<b>EditVR is a free, open-source WebVR editor</b> that lets you produce
18+
interactive and affordable 360 tours and VR stories. EditVR makes
19+
immersive experiences available to everyone using devices they already
20+
own. Nothing to buy, download, or install!
21+
</Typography>
22+
23+
<NavLink to="/login">
24+
<Button className={classes.button} variant="raised" color="primary">
25+
Login
26+
</Button>
27+
</NavLink>
28+
<NavLink to="/register">
29+
<Button className={classes.button} variant="raised" color="primary">
30+
Register
31+
</Button>
32+
</NavLink>
33+
</ThinLayout>
34+
);
35+
36+
Home.propTypes = {
37+
classes: PropTypes.shape({
38+
button: PropTypes.string.isRequired
39+
}).isRequired
40+
};
41+
42+
export default withStyles(HomeStyles)(Home);

src/pages/Home/Home.style.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @file Home.style.js
3+
* Exports Home component styles.
4+
*/
5+
6+
export default theme => ({
7+
button: {
8+
marginTop: `${theme.spacing.unit * 3}px`,
9+
marginRight: theme.spacing.unit
10+
}
11+
});

src/pages/Login/Login.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @file Login.js
3+
* Exports a React component that renders EditVR's login.
4+
*/
5+
6+
import React from 'react';
7+
import { Typography } from '@material-ui/core';
8+
9+
import { LoginForm } from '../../components';
10+
import { ThinLayout } from '../../layouts';
11+
12+
const Login = () => (
13+
<ThinLayout>
14+
<Typography variant="headline">Log into EditVR</Typography>
15+
<LoginForm />
16+
</ThinLayout>
17+
);
18+
19+
export default Login;

src/pages/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
* Exports all page components.
44
*/
55

6-
export * from './Home';
6+
import Home from './Home/Home';
7+
import Login from './Login/Login';
8+
9+
export { Home, Login };

0 commit comments

Comments
 (0)