Skip to content

Commit e6fd870

Browse files
committed
Updated webpack, babel, eslint. ES module build added. Split to separately importable pieces.
1 parent 4cb5207 commit e6fd870

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1128
-909
lines changed

.babelrc

+35-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,37 @@
11
{
2-
"presets": ["es2015", "stage-0", "react"],
3-
"plugins": ["transform-runtime", "transform-class-properties"]
2+
"env": {
3+
"commonjs": {
4+
"presets": ["env"],
5+
"plugins": [
6+
"transform-runtime",
7+
"transform-react-jsx",
8+
"transform-class-properties",
9+
"transform-object-rest-spread"
10+
]
11+
},
12+
"es": {
13+
"presets": [
14+
[
15+
"env",
16+
{ "modules": false }
17+
]
18+
],
19+
"plugins": [
20+
"transform-runtime",
21+
"transform-react-jsx",
22+
"transform-class-properties",
23+
"transform-object-rest-spread"
24+
]
25+
},
26+
"with_react_hot_loader": {
27+
"presets": ["env"],
28+
"plugins": [
29+
"react-hot-loader/babel",
30+
"transform-runtime",
31+
"transform-react-jsx",
32+
"transform-class-properties",
33+
"transform-object-rest-spread"
34+
]
35+
}
36+
}
437
}

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
demos/demo0/bundle.js

.eslintrc

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
{
2-
"extends": "eslint-config-airbnb",
2+
"extends": "airbnb",
33
"env": {
4-
"es6": true
4+
"es6": true,
5+
"browser": true
56
},
67
"parser": "babel-eslint",
7-
"ecmaFeatures": {
8-
"modules": true,
9-
"jsx": true
10-
},
118
"plugins": [
129
"react"
1310
],
1411
"rules": {
15-
"react/prefer-es6-class": 0,
1612
"react/jsx-closing-bracket-location": 0,
17-
"react/no-did-mount-set-state": 0,
18-
"react/no-is-mounted": 0,
19-
"react/prefer-stateless-function": 0
13+
"react/jsx-first-prop-new-line": 0,
14+
"react/require-default-props": 0,
15+
"react/forbid-prop-types": 0,
16+
"jsx-a11y/href-no-hash": 0,
17+
"jsx-a11y/no-static-element-interactions": 0,
18+
"no-underscore-dangle": 0,
19+
"object-curly-newline": ["error", { "consistent": true }],
20+
"prefer-template": 0
2021
}
2122
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules/
22
lib/
3+
es/
34
*.log
45
demos/demo0/bundle.js

demos/demo0/Demo.jsx

+28-33
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
/* eslint-disable react/prefer-stateless-function */
2+
/* eslint-disable import/no-unresolved, import/extensions, import/no-extraneous-dependencies */
23
import React, { Component } from 'react';
3-
import {
4-
ShareButtons,
5-
ShareCounts,
6-
generateShareIcon,
7-
} from 'react-share';
84

9-
import exampleImage from './react-share-pin-example.png';
5+
import {
6+
FacebookShareCount,
7+
GooglePlusShareCount,
8+
LinkedinShareCount,
9+
PinterestShareCount,
10+
VKShareCount,
11+
OKShareCount,
12+
RedditShareCount,
13+
TumblrShareCount,
1014

11-
const {
1215
FacebookShareButton,
1316
GooglePlusShareButton,
1417
LinkedinShareButton,
@@ -23,33 +26,25 @@ const {
2326
TumblrShareButton,
2427
LivejournalShareButton,
2528
MailruShareButton,
26-
} = ShareButtons;
2729

28-
const {
29-
FacebookShareCount,
30-
GooglePlusShareCount,
31-
LinkedinShareCount,
32-
PinterestShareCount,
33-
VKShareCount,
34-
OKShareCount,
35-
RedditShareCount,
36-
TumblrShareCount,
37-
} = ShareCounts;
38-
39-
const FacebookIcon = generateShareIcon('facebook');
40-
const TwitterIcon = generateShareIcon('twitter');
41-
const GooglePlusIcon = generateShareIcon('google');
42-
const LinkedinIcon = generateShareIcon('linkedin');
43-
const PinterestIcon = generateShareIcon('pinterest');
44-
const VKIcon = generateShareIcon('vk');
45-
const OKIcon = generateShareIcon('ok');
46-
const TelegramIcon = generateShareIcon('telegram');
47-
const WhatsappIcon = generateShareIcon('whatsapp');
48-
const RedditIcon = generateShareIcon('reddit');
49-
const TumblrIcon = generateShareIcon('tumblr');
50-
const MailruIcon = generateShareIcon('mailru');
51-
const EmailIcon = generateShareIcon('email');
52-
const LivejournalIcon = generateShareIcon('livejournal');
30+
FacebookIcon,
31+
TwitterIcon,
32+
GooglePlusIcon,
33+
LinkedinIcon,
34+
PinterestIcon,
35+
VKIcon,
36+
OKIcon,
37+
TelegramIcon,
38+
WhatsappIcon,
39+
RedditIcon,
40+
TumblrIcon,
41+
MailruIcon,
42+
EmailIcon,
43+
LivejournalIcon,
44+
} from 'react-share';
45+
46+
import exampleImage from './react-share-pin-example.png';
47+
5348

5449
class Demo extends Component {
5550
render() {

demos/demo0/index.jsx

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
/* eslint-disable import/no-extraneous-dependencies */
12
import React from 'react';
23
import ReactDOM from 'react-dom';
34
import Demo from './Demo';
45

56
ReactDOM.render(<Demo />, document.querySelector('#content'));
7+
8+
if (module.hot) {
9+
module.hot.accept();
10+
}

package.json

+30-26
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
"name": "react-share",
33
"version": "1.19.0",
44
"description": "Easy social media share buttons and share counts.",
5-
"main": "./lib/react-share.js",
5+
"main": "./lib/index.js",
6+
"module": "./es/index.js",
67
"engines": {
78
"node": ">=4.0.0",
89
"npm": ">=3.0.0"
910
},
1011
"scripts": {
11-
"build": "npm run lint && npm run build-src && npm run build-demos",
12-
"build-src": "babel ./src --out-dir ./lib",
13-
"build-demos": "NODE_ENV=production webpack -p --config webpack.demos.config.js",
14-
"run-demos": "NODE_ENV=development webpack-dev-server --config webpack.demos.config.js --content-base demos/ --progress --colors",
15-
"lint": "eslint --ext .jsx ./src ./demos",
12+
"build": "npm run lint && npm run build:commonjs && npm run build:es && npm run build-demos",
13+
"build:commonjs": "rimraf ./lib && cross-env BABEL_ENV=commonjs babel ./src --out-dir ./lib",
14+
"build:es": "rimraf ./es && cross-env BABEL_ENV=es babel ./src --out-dir ./es",
15+
"build-demos": "webpack -p --config webpack.demos.config.js",
16+
"run-demos": "webpack-dev-server --hot --config webpack.demos.config.js --content-base demos/ --progress",
17+
"lint": "eslint --ext .jsx --ext .js ./src ./demos",
1618
"prepublish": "npm run build",
1719
"start": "npm run run-demos"
1820
},
@@ -38,28 +40,30 @@
3840
},
3941
"license": "MIT",
4042
"devDependencies": {
41-
"babel-cli": "6.18.0",
42-
"babel-core": "6.18.2",
43-
"babel-eslint": "7.1.1",
44-
"babel-loader": "6.2.10",
45-
"babel-plugin-transform-class-properties": "6.18.0",
46-
"babel-plugin-transform-runtime": "6.15.0",
47-
"babel-preset-airbnb": "1.1.1",
48-
"babel-preset-es2015": "6.18.0",
49-
"babel-preset-react": "6.16.0",
50-
"babel-preset-stage-0": "6.16.0",
51-
"eslint": "2.13.1",
52-
"eslint-config-airbnb": "7.0.0",
53-
"eslint-loader": "1.6.3",
54-
"eslint-plugin-jsx-a11y": "0.6.2",
55-
"eslint-plugin-react": "4.3.0",
56-
"file-loader": "0.9.0",
43+
"babel-cli": "6.26.0",
44+
"babel-core": "6.26.0",
45+
"babel-eslint": "8.1.2",
46+
"babel-loader": "7.1.2",
47+
"babel-plugin-transform-class-properties": "6.24.1",
48+
"babel-plugin-transform-object-rest-spread": "6.26.0",
49+
"babel-plugin-transform-react-jsx": "^6.24.1",
50+
"babel-plugin-transform-runtime": "6.23.0",
51+
"babel-preset-env": "1.6.1",
52+
"cross-env": "5.1.3",
53+
"eslint": "4.14.0",
54+
"eslint-config-airbnb": "16.1.0",
55+
"eslint-loader": "1.9.0",
56+
"eslint-plugin-import": "2.8.0",
57+
"eslint-plugin-jsx-a11y": "6.0.3",
58+
"eslint-plugin-react": "7.5.1",
59+
"file-loader": "1.1.6",
5760
"react": "15.5.4",
5861
"react-dom": "15.5.4",
59-
"react-hot-loader": "1.3.1",
60-
"url-loader": "0.5.8",
61-
"webpack": "1.13.3",
62-
"webpack-dev-server": "1.16.3"
62+
"react-hot-loader": "^3.1.3",
63+
"rimraf": "^2.6.2",
64+
"url-loader": "0.6.2",
65+
"webpack": "3.10.0",
66+
"webpack-dev-server": "2.9.7"
6367
},
6468
"dependencies": {
6569
"babel-runtime": "^6.6.1",

src/EmailIcon.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import iconFactory from './utils/iconFactory';
2+
3+
const EmailIcon = iconFactory('email', {
4+
icon: 'M17,22v20h30V22H17z M41.1,25L32,32.1L22.9,25H41.1z M20,39V26.6l12,9.3l12-9.3V39H20z',
5+
mask: 'M41.1,25H22.9l9.1,7.1L41.1,25z M44,26.6l-12,9.3l-12-9.3V39h24V26.6z M0,0v64h64V0H0z M47,42H17V22h30V42z',
6+
color: '#7f7f7f',
7+
});
8+
9+
export default EmailIcon;

src/EmailShareButton.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import PropTypes from 'prop-types';
2+
3+
import objectToGetParams from './utils/objectToGetParams';
4+
import createShareButton from './utils/createShareButton';
5+
6+
function emailLink(url, { subject, body }) {
7+
return 'mailto:' + objectToGetParams({ subject, body: body || subject });
8+
}
9+
10+
const EmailShareButton = createShareButton('email', emailLink, props => ({
11+
subject: props.subject,
12+
body: props.body,
13+
}), {
14+
subject: PropTypes.string,
15+
body: PropTypes.string,
16+
}, {
17+
openWindow: false,
18+
onClick: (link) => { window.location.href = link; },
19+
});
20+
21+
export default EmailShareButton;

src/FacebookIcon.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import iconFactory from './utils/iconFactory';
2+
3+
const FacebookIcon = iconFactory('facebook', {
4+
icon: 'M34.1,47V33.3h4.6l0.7-5.3h-5.3v-3.4c0-1.5,0.4-2.6,2.6-2.6l2.8,0v-4.8c-0.5-0.1-2.2-0.2-4.1-0.2 c-4.1,0-6.9,2.5-6.9,7V28H24v5.3h4.6V47H34.1z',
5+
mask: 'M0,0v64h64V0H0z M39.6,22l-2.8,0c-2.2,0-2.6,1.1-2.6,2.6V28h5.3l-0.7,5.3h-4.6V47h-5.5V33.3H24V28h4.6V24 c0-4.6,2.8-7,6.9-7c2,0,3.6,0.1,4.1,0.2V22z',
6+
color: '#3b5998',
7+
});
8+
9+
export default FacebookIcon;

src/FacebookShareButton.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import PropTypes from 'prop-types';
2+
3+
import assert from 'assert';
4+
5+
import objectToGetParams from './utils/objectToGetParams';
6+
import createShareButton from './utils/createShareButton';
7+
8+
function facebookLink(url, { quote, hashtag }) {
9+
assert(url, 'facebook.url');
10+
11+
return 'https://www.facebook.com/sharer/sharer.php' + objectToGetParams({
12+
u: url,
13+
quote,
14+
hashtag,
15+
});
16+
}
17+
18+
const FacebookShareButton = createShareButton('facebook', facebookLink, (props) => {
19+
/* eslint-disable no-console */
20+
if (props.picture) {
21+
console.warn('FacebookShareButton warning: picture is a deprecated prop.');
22+
}
23+
24+
if (props.title) {
25+
console.warn('FacebookShareButton warning: title is a deprecated prop. Use "quote" instead.');
26+
}
27+
28+
if (props.description) {
29+
console.warn(`FacebookShareButton warning: description is a deprecated prop.
30+
Use "quote" instead.`);
31+
}
32+
/* eslint-enable no-console */
33+
34+
return {
35+
quote: props.quote,
36+
hashtag: props.hashtag,
37+
};
38+
}, {
39+
quote: PropTypes.string,
40+
hashtag: PropTypes.string,
41+
}, {
42+
windowWidth: 550,
43+
windowHeight: 400,
44+
});
45+
46+
export default FacebookShareButton;

src/FacebookShareCount.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import jsonp from 'jsonp';
2+
3+
import shareCountFactory from './utils/shareCountFactory';
4+
5+
function getFacebookShareCount(shareUrl, callback) {
6+
const endpoint = `https://graph.facebook.com/?id=${shareUrl}`;
7+
8+
jsonp(endpoint, (err, data) => {
9+
callback(!err && data && data.share && data.share.share_count
10+
? data.share.share_count
11+
: undefined);
12+
});
13+
}
14+
15+
export default shareCountFactory(getFacebookShareCount);

src/GooglePlusIcon.js

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/GooglePlusShareButton.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import assert from 'assert';
2+
3+
import objectToGetParams from './utils/objectToGetParams';
4+
import createShareButton from './utils/createShareButton';
5+
6+
function googlePlusLink(url) {
7+
assert(url, 'googlePlus.url');
8+
9+
return 'https://plus.google.com/share' + objectToGetParams({ url });
10+
}
11+
12+
const GooglePlusShareButton = createShareButton(
13+
'googlePlus',
14+
googlePlusLink,
15+
undefined,
16+
undefined,
17+
{
18+
windowWidth: 550,
19+
windowHeight: 400,
20+
},
21+
);
22+
23+
export default GooglePlusShareButton;

0 commit comments

Comments
 (0)