Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 74e6ce3

Browse files
authored
Merge pull request #43 from r-park/dev
refactor(views): cleanup and formatting
2 parents e7e9d16 + 60b9ff0 commit 74e6ce3

File tree

32 files changed

+237
-285
lines changed

32 files changed

+237
-285
lines changed

‎src/components/tasks/task-list.js‎

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

‎src/components/tasks/task-list.spec.js‎

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

‎src/main.js‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import './styles/styles.scss';
2-
31
import React from 'react';
42
import ReactDOM from 'react-dom';
53
import { AppContainer } from 'react-hot-loader';
@@ -8,7 +6,8 @@ import { syncHistoryWithStore } from 'react-router-redux';
86

97
import { initAuth } from './core/auth';
108
import configureStore from './core/store';
11-
import Root from './components/root';
9+
import Root from './views/root';
10+
import './views/styles/styles.scss';
1211

1312

1413
const store = configureStore();
@@ -26,8 +25,8 @@ function render(Root) {
2625
}
2726

2827
if (module.hot) {
29-
module.hot.accept('./components/root', () => {
30-
render(require('./components/root').default);
28+
module.hot.accept('./views/root', () => {
29+
render(require('./views/root').default);
3130
});
3231
}
3332

‎src/styles/_grid.scss‎

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

‎src/styles/_settings.scss‎

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

‎src/styles/app/_main.scss‎

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

‎src/styles/tasks/_task-list.scss‎

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

‎src/components/app/app.js‎ renamed to ‎src/views/app/index.js‎

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { connect } from 'react-redux';
33
import { createSelector } from 'reselect';
44
import { authActions, getAuth } from 'src/core/auth';
55
import { paths } from '../routes';
6+
import Header from '../components/header';
67

78

89
export class App extends Component {
@@ -13,15 +14,9 @@ export class App extends Component {
1314
static propTypes = {
1415
auth: PropTypes.object.isRequired,
1516
children: PropTypes.object.isRequired,
16-
history: PropTypes.object.isRequired,
1717
signOut: PropTypes.func.isRequired
1818
};
1919

20-
constructor(props, context) {
21-
super(props, context);
22-
this.signOut = ::this.signOut;
23-
}
24-
2520
componentWillReceiveProps(nextProps) {
2621
const { router } = this.context;
2722
const { auth } = this.props;
@@ -34,29 +29,15 @@ export class App extends Component {
3429
}
3530
}
3631

37-
signOut() {
38-
this.props.signOut();
39-
}
40-
4132
render() {
42-
const { auth, children } = this.props;
43-
4433
return (
4534
<div>
46-
<header className="header">
47-
<div className="g-row">
48-
<div className="g-col">
49-
<h1 className="header__title">Todo React Redux</h1>
50-
51-
<ul className="header__links">
52-
{auth.authenticated ? <li><a className="header__link" onClick={this.signOut} href="#">Sign out</a></li> : null}
53-
<li><a className="header__link header__link--github" href="https://github.com/r-park/todo-react-redux"></a></li>
54-
</ul>
55-
</div>
56-
</div>
57-
</header>
35+
<Header
36+
authenticated={this.props.auth.authenticated}
37+
signOut={this.props.signOut}
38+
/>
5839

59-
<main className="main">{children}</main>
40+
<main className="main">{this.props.children}</main>
6041
</div>
6142
);
6243
}

‎src/views/components/header/index.js‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React, { PropTypes } from 'react';
2+
3+
4+
const Header = ({authenticated, signOut}) => {
5+
return (
6+
<header className="header">
7+
<div className="g-row">
8+
<div className="g-col">
9+
<h1 className="header__title">Todo React Redux</h1>
10+
11+
<ul className="header__actions">
12+
{authenticated ? <li><button className="btn" onClick={signOut}>Sign out</button></li> : null}
13+
<li><a className="link link--github" href="https://github.com/r-park/todo-react-redux"></a></li>
14+
</ul>
15+
</div>
16+
</div>
17+
</header>
18+
);
19+
};
20+
21+
Header.propTypes = {
22+
authenticated: PropTypes.bool.isRequired,
23+
signOut: PropTypes.func.isRequired
24+
};
25+
26+
export default Header;

‎src/components/tasks/notification.js‎ renamed to ‎src/views/components/notification/index.js‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { Component, PropTypes } from 'react';
22

33

4-
exportclass Notification extends Component {
4+
class Notification extends Component {
55
static propTypes = {
66
action: PropTypes.func.isRequired,
77
actionLabel: PropTypes.string.isRequired,
@@ -39,16 +39,17 @@ export class Notification extends Component {
3939
}
4040

4141
render() {
42-
const { action, actionLabel, message } = this.props;
4342
return (
4443
<div className="notification">
45-
<p className="notification__message" ref={c => this.message = c}>{message}</p>
44+
<p className="notification__message" ref={c => this.message = c}>{this.props.message}</p>
4645
<button
47-
className="notification__button"
48-
onClick={action}
46+
className="btn notification__button"
47+
onClick={this.props.action}
4948
ref={c => this.button = c}
50-
type="button">{actionLabel}</button>
49+
type="button">{this.props.actionLabel}</button>
5150
</div>
5251
);
5352
}
5453
}
54+
55+
export default Notification;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /