Skip to content

Commit 06ff577

Browse files
committed
Remove usage of Object.assign
1 parent 7cb2607 commit 06ff577

File tree

4 files changed

+55
-60
lines changed

4 files changed

+55
-60
lines changed

.babelrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
22
"stage": 0,
3-
"loose": "all",
4-
"plugins": [ "object-assign" ]
3+
"loose": "all"
54
}
Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
1-
import React from 'react';
2-
import { Link } from 'react-router';
1+
import React from 'react'
2+
import { Link } from 'react-router'
33

4-
const styles = {};
4+
const dark = 'hsl(200, 20%, 20%)'
5+
const light = '#fff'
6+
const styles = {}
7+
8+
styles.wrapper = {
9+
padding: '10px 20px',
10+
overflow: 'hidden',
11+
background: dark,
12+
color: light
13+
}
14+
15+
styles.link = {
16+
padding: 11,
17+
color: light,
18+
fontWeight: 200
19+
}
20+
21+
styles.activeLink = {
22+
...styles.link,
23+
background: light,
24+
color: dark
25+
}
526

627
class GlobalNav extends React.Component {
728

@@ -10,19 +31,19 @@ class GlobalNav extends React.Component {
1031
id: 1,
1132
name: 'Ryan Florence'
1233
}
13-
};
34+
}
1435

15-
constructor (props, context) {
16-
super(props, context);
17-
this.logOut = this.logOut.bind(this);
36+
constructor(props, context) {
37+
super(props, context)
38+
this.logOut = this.logOut.bind(this)
1839
}
1940

20-
logOut () {
21-
alert('log out');
41+
logOut() {
42+
alert('log out')
2243
}
2344

24-
render () {
25-
var { user } = this.props;
45+
render() {
46+
var { user } = this.props
2647
return (
2748
<div style={styles.wrapper}>
2849
<div style={{float: 'left'}}>
@@ -35,29 +56,8 @@ class GlobalNav extends React.Component {
3556
<Link style={styles.link} to="/profile">{user.name}</Link> <button onClick={this.logOut}>log out</button>
3657
</div>
3758
</div>
38-
);
59+
)
3960
}
4061
}
4162

42-
var dark = 'hsl(200, 20%, 20%)';
43-
var light = '#fff';
44-
45-
styles.wrapper = {
46-
padding: '10px 20px',
47-
overflow: 'hidden',
48-
background: dark,
49-
color: light
50-
};
51-
52-
styles.link = {
53-
padding: 11,
54-
color: light,
55-
fontWeight: 200
56-
}
57-
58-
styles.activeLink = Object.assign({}, styles.link, {
59-
background: light,
60-
color: dark
61-
});
62-
63-
export default GlobalNav;
63+
export default GlobalNav
Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,50 @@
1-
import React from 'react';
2-
import { Link } from 'react-router';
3-
import AnnouncementsRoute from '../routes/Announcements';
4-
import AssignmentsRoute from '../routes/Assignments';
5-
import GradesRoute from '../routes/Grades';
1+
import React from 'react'
2+
import { Link } from 'react-router'
3+
import AnnouncementsRoute from '../routes/Announcements'
4+
import AssignmentsRoute from '../routes/Assignments'
5+
import GradesRoute from '../routes/Grades'
66

7-
const styles = {};
7+
const styles = {}
88

99
styles.nav = {
1010
borderBottom: '1px solid #aaa'
11-
};
11+
}
1212

1313
styles.link = {
1414
display: 'inline-block',
1515
padding: 10,
16-
textDecoration: 'none',
17-
};
16+
textDecoration: 'none'
17+
}
1818

19-
styles.activeLink = Object.assign({}, styles.link, {
19+
styles.activeLink = {
20+
...styles.link,
2021
//color: 'red'
21-
});
22+
}
2223

2324
class Nav extends React.Component {
2425

2526
render () {
26-
var { course } = this.props;
27-
var pages = [
27+
const { course } = this.props
28+
const pages = [
2829
['announcements', 'Announcements'],
2930
['assignments', 'Assignments'],
3031
['grades', 'Grades'],
31-
];
32+
]
33+
3234
return (
3335
<nav style={styles.nav}>
3436
{pages.map((page, index) => (
3537
<Link
3638
key={page[0]}
37-
activeStyle={index === 0 ?
38-
Object.assign({}, styles.activeLink, { paddingLeft: 0 }) :
39-
styles.activeLink}
40-
style={index === 0 ?
41-
Object.assign({}, styles.link, { paddingLeft: 0 }) :
42-
styles.link }
39+
activeStyle={index === 0 ? { ...styles.activeLink, paddingLeft: 0 } : styles.activeLink}
40+
style={index === 0 ? { ...styles.link, paddingLeft: 0 } : styles.link}
4341
to={`/course/${course.id}/${page[0]}`}
4442
>{page[1]}</Link>
4543
))}
4644
</nav>
47-
);
45+
)
4846
}
4947

5048
}
5149

52-
export default Nav;
53-
50+
export default Nav

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"babel-core": "^5.4.7",
3636
"babel-eslint": "^3.1.23",
3737
"babel-loader": "^5.0.0",
38-
"babel-plugin-object-assign": "^1.2.0",
3938
"bundle-loader": "^0.5.2",
4039
"css-loader": "^0.19.0",
4140
"eslint": "1.4.0",

0 commit comments

Comments
 (0)