Skip to content

Commit e1fbf38

Browse files
committed
refactored and fixed eslint with new props
1 parent 85821a6 commit e1fbf38

22 files changed

+294
-161
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"es2015"
66
],
77
"plugins": [
8-
"transform-decorators",
8+
"transform-decorators-legacy",
99
"transform-class-properties"
1010
]
1111
}

.eslintrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"extends": "airbnb",
33
"parser": "babel-eslint",
4+
"globals": {
5+
"location": true,
6+
"window": true
7+
},
48
"rules": {
59
}
610
}

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
- Facebook provider (provide settings to child components)
1616
- Login button (provide user profile and signed request)
1717
- Like button
18-
- Share button
18+
- Share and Share button
1919
- Comments
20-
- CommentsCount
20+
- Comments count
2121
- Embedded post
2222

2323
# Support us
@@ -54,7 +54,28 @@ export default class Example extends Component {
5454
render() {
5555
return (
5656
<FacebookProvider appID="123456789">
57-
<Share href="http://www.facebook.com" />
57+
<Share href="http://www.facebook.com">
58+
<button type="button">Share</button>
59+
</Share>
60+
</FacebookProvider>
61+
);
62+
}
63+
}
64+
```
65+
66+
## Share button
67+
68+
You can use predefined button with bootstrap and font awesome classNames
69+
70+
```js
71+
import React, { Component} from 'react';
72+
import FacebookProvider, { ShareButton } from 'react-facebook';
73+
74+
export default class Example extends Component {
75+
render() {
76+
return (
77+
<FacebookProvider appID="123456789">
78+
<ShareButton href="http://www.facebook.com" />
5879
</FacebookProvider>
5980
);
6081
}

gulpfile.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,3 @@ gulp.task('coveralls', ['test'], () => {
4444
return gulp.src(path.join(__dirname, 'coverage/lcov.info'))
4545
.pipe(coveralls());
4646
});
47-
48-
gulp.doneCallback = (err) => {
49-
process.exit(err ? 1 : 0);
50-
};

package.json

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,41 +36,42 @@
3636
"test": "babel-node ./node_modules/gulp/bin/gulp.js test",
3737
"build": "babel-node ./node_modules/gulp/bin/gulp.js build",
3838
"coveralls": "babel-node ./node_modules/gulp/bin/gulp.js coveralls",
39-
"eslint": "node ./node_modules/eslint/bin/eslint.js --ext .js,.jsx ."
39+
"eslint": "node ./node_modules/eslint/bin/eslint.js --ext .js,.jsx ./src"
4040
},
4141
"dependencies": {
4242
"keymirror": "^0.1.1",
4343
"react-spinner-children": "^1.0.5",
44-
"qs": "^6.2.0",
45-
"can-use-dom": "^0.1.0"
44+
"qs": "^6.2.1",
45+
"can-use-dom": "^0.1.0",
46+
"core-decorators": "^0.12.3"
4647
},
4748
"devDependencies": {
48-
"babel-cli": "^6.10.1",
49-
"babel-core": "^6.10.4",
50-
"babel-eslint": "^6.1.0",
49+
"babel-cli": "^6.14.0",
50+
"babel-core": "^6.14.0",
51+
"babel-eslint": "^6.1.2",
5152
"babel-plugin-transform-decorators-legacy": "^1.3.4",
52-
"babel-plugin-transform-class-properties": "^6.10.2",
53-
"babel-preset-es2015": "^6.9.0",
54-
"babel-preset-react": "^6.11.0",
53+
"babel-plugin-transform-class-properties": "^6.11.5",
54+
"babel-preset-es2015": "^6.14.0",
55+
"babel-preset-react": "^6.11.1",
5556
"babel-preset-stage-0": "^6.5.0",
56-
"babel-preset-stage-1": "^6.5.0",
57+
"babel-preset-stage-1": "^6.13.0",
5758
"core-decorators": "^0.12.3",
58-
"eslint": "^2.13.1",
59-
"eslint-config-airbnb": "^9.0.1",
60-
"eslint-loader": "^1.3.0",
61-
"eslint-plugin-react": "^5.2.2",
62-
"eslint-plugin-jsx-a11y": "^1.5.3",
63-
"eslint-plugin-import": "^1.9.2",
59+
"eslint": "^3.5.0",
60+
"eslint-config-airbnb": "^11.1.0",
61+
"eslint-loader": "^1.5.0",
62+
"eslint-plugin-react": "^6.2.0",
63+
"eslint-plugin-jsx-a11y": "^2.2.1",
64+
"eslint-plugin-import": "^1.14.0",
6465
"gulp": "^3.9.1",
6566
"gulp-babel": "^6.1.2",
6667
"gulp-coveralls": "^0.1.4",
6768
"gulp-jsx-coverage": "^0.3.8",
6869
"gulp-util": "^3.0.7",
69-
"react": "^15.1.0",
70-
"react-addons-test-utils": "^15.1.0",
71-
"react-dom": "^15.1.0",
72-
"should": "^9.0.2",
73-
"mocha": "^2.5.3",
70+
"react": "^15.3.1",
71+
"react-addons-test-utils": "^15.3.1",
72+
"react-dom": "^15.3.1",
73+
"should": "^11.1.0",
74+
"mocha": "^3.0.2",
7475
"jsdom": "^3.1.2 || ^6.5.1"
7576
},
7677
"peerDependencies": {

src/Comments.jsx

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,55 @@
1-
import React, { PropTypes } from 'react';
2-
import Parser from './Parser';
3-
import getCurrentHref from './utils/getCurrentHref';
4-
5-
export default class Comments extends Parser {
6-
static contextTypes = {
7-
...Parser.contextTypes,
8-
};
9-
10-
static propTypes = {
11-
...Parser.propTypes,
12-
href: PropTypes.string,
13-
numPosts: PropTypes.number.isRequired,
14-
orderBy: PropTypes.string.isRequired,
15-
width: PropTypes.oneOfType([
16-
PropTypes.number.isRequired,
17-
PropTypes.string.isRequired
18-
]),
19-
colorScheme: PropTypes.string.isRequired,
20-
children: PropTypes.node,
21-
};
22-
23-
static defaultProps = {
24-
numPosts: 10,
25-
orderBy: 'social', // "social", "reverse_time", or "time"
26-
width: 550,
27-
colorScheme: 'light',
28-
};
29-
30-
renderComponent() {
31-
const {
32-
colorScheme,
33-
href = getCurrentHref(),
34-
numPosts,
35-
orderBy,
36-
width,
37-
children,
38-
} = this.props;
39-
40-
return (
41-
<div
42-
className="fb-comments"
43-
data-colorscheme={colorScheme}
44-
data-numposts={numPosts}
45-
data-href={href}
46-
data-order-by={orderBy}
47-
data-width={width}
48-
>
49-
{children}
50-
</div>
51-
);
52-
}
53-
}
1+
import React, { PropTypes } from 'react';
2+
import Parser from './Parser';
3+
import getCurrentHref from './utils/getCurrentHref';
4+
import ColorScheme from './constants/ColorScheme';
5+
import CommentsOrderBy from './constants/CommentsOrderBy';
6+
7+
export default class Comments extends Parser {
8+
static contextTypes = {
9+
...Parser.contextTypes,
10+
};
11+
12+
static propTypes = {
13+
...Parser.propTypes,
14+
href: PropTypes.string,
15+
numPosts: PropTypes.number.isRequired,
16+
orderBy: PropTypes.string.isRequired,
17+
width: PropTypes.oneOfType([
18+
PropTypes.number.isRequired,
19+
PropTypes.string.isRequired,
20+
]),
21+
colorScheme: PropTypes.string.isRequired,
22+
children: PropTypes.node,
23+
};
24+
25+
static defaultProps = {
26+
numPosts: 10,
27+
orderBy: CommentsOrderBy.SOCIAL,
28+
width: 550,
29+
colorScheme: ColorScheme.LIGHT,
30+
};
31+
32+
renderComponent() {
33+
const {
34+
colorScheme,
35+
href = getCurrentHref(),
36+
numPosts,
37+
orderBy,
38+
width,
39+
children,
40+
} = this.props;
41+
42+
return (
43+
<div
44+
className="fb-comments"
45+
data-colorscheme={colorScheme}
46+
data-numposts={numPosts}
47+
data-href={href}
48+
data-order-by={orderBy}
49+
data-width={width}
50+
>
51+
{children}
52+
</div>
53+
);
54+
}
55+
}

src/CommentsCount.jsx

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
import React, { PropTypes } from 'react';
2-
import Parser from './Parser';
3-
import getCurrentHref from './utils/getCurrentHref';
4-
5-
export default class CommentsCount extends Parser {
6-
static contextTypes = {
7-
...Parser.contextTypes,
8-
};
9-
10-
static propTypes = {
11-
...Parser.propTypes,
12-
href: PropTypes.string,
13-
children: PropTypes.node,
14-
};
15-
16-
renderComponent() {
17-
const { href = getCurrentHref(), children } = this.props;
18-
19-
return (
20-
<span
21-
className="fb-comments-count"
22-
data-href={href}
23-
>
24-
{children}
25-
</span>
26-
);
27-
}
28-
}
1+
import React, { PropTypes } from 'react';
2+
import Parser from './Parser';
3+
import getCurrentHref from './utils/getCurrentHref';
4+
5+
export default class CommentsCount extends Parser {
6+
static contextTypes = {
7+
...Parser.contextTypes,
8+
};
9+
10+
static propTypes = {
11+
...Parser.propTypes,
12+
href: PropTypes.string,
13+
children: PropTypes.node,
14+
};
15+
16+
renderComponent() {
17+
const { href = getCurrentHref(), children } = this.props;
18+
19+
return (
20+
<span
21+
className="fb-comments-count"
22+
data-href={href}
23+
>
24+
{children}
25+
</span>
26+
);
27+
}
28+
}

src/EmbeddedPost.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import Parser from './Parser';
44
export default class EmbeddedPost extends Parser {
55
static propTypes = {
66
href: PropTypes.string.isRequired,
7-
width: PropTypes.number.isRequired,
7+
width: PropTypes.oneOfType([
8+
PropTypes.number.isRequired,
9+
PropTypes.string.isRequired
10+
]),
811
showText: PropTypes.bool.isRequired,
912
children: PropTypes.node,
1013
className: PropTypes.string,

src/Facebook.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ function api(path, method, params, callback) {
3030
const FB = window.FB;
3131
if (!FB) {
3232
callback(new Error('FB is not initialized'));
33-
return void 0;
33+
return undefined;
3434
}
3535

36-
FB.api(path, method, params, callback);
36+
return FB.api(path, method, params, callback);
3737
}
3838

3939
export default class Facebook {

src/FacebookProvider.jsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,27 @@ export default class Facebook extends Component {
3838
}
3939

4040
whenReady(callback) {
41-
const props = this.props;
41+
const {
42+
version,
43+
appID,
44+
cookie,
45+
status,
46+
xfbml,
47+
language,
48+
frictionlessRequests,
49+
init,
50+
} = this.props;
4251

4352
if (!this.facebook) {
4453
this.facebook = facebookInstance = facebookInstance || new FB({
45-
appID: props.appID,
46-
version: props.version,
47-
cookie: props.cookie,
48-
status: props.status,
49-
xfbml: props.xfbml,
50-
language: props.language,
51-
frictionlessRequests: props.frictionlessRequests,
52-
init: props.init,
54+
appID,
55+
version,
56+
cookie,
57+
status,
58+
xfbml,
59+
language,
60+
frictionlessRequests,
61+
init,
5362
});
5463
}
5564

0 commit comments

Comments
 (0)