Skip to content

Commit bb025ff

Browse files
committedOct 24, 2015
initial commit
0 parents  commit bb025ff

27 files changed

+1545
-0
lines changed
 

‎.eslintrc

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"extends": "eslint-config-airbnb",
3+
"env": {
4+
"es6": true,
5+
"jasmine": true
6+
},
7+
"parser": "babel-eslint",
8+
"ecmaFeatures": {
9+
"modules": true,
10+
"jsx": true
11+
},
12+
"plugins": [
13+
"react"
14+
],
15+
"rules": {
16+
"strict": 0,
17+
"quotes": [2, "single"],
18+
"comma-dangle": [2, "never"],
19+
"max-len": [1, 80, 4],
20+
"no-trailing-spaces": [2, { skipBlankLines: true }],
21+
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
22+
"no-unused-vars": [1, {"vars": "all", "args": "after-used"}],
23+
"semi": [1, "always"],
24+
"no-unused-expressions": 1,
25+
"no-loop-func": 0,
26+
"jsx-quotes": [2, "prefer-double"],
27+
28+
"react/jsx-no-undef": 2,
29+
"react/jsx-uses-react": 2,
30+
"react/jsx-uses-vars": 2,
31+
"react/jsx-boolean-value": 0,
32+
"react/no-did-mount-set-state": 2,
33+
"react/no-did-update-set-state": 2,
34+
"react/no-unknown-property": 2,
35+
"react/prop-types": 2,
36+
"react/react-in-jsx-scope": 2,
37+
"react/self-closing-comp": 2,
38+
"react/wrap-multilines": 2,
39+
"react/no-did-mount-set-state": 0,
40+
"react/sort-comp": [
41+
2, {
42+
"order": [
43+
"displayName",
44+
"propTypes",
45+
"contextTypes",
46+
"childContextTypes",
47+
"mixins",
48+
"statics",
49+
"defaultProps",
50+
"getDefaultProps",
51+
"getInitialState",
52+
"getChildContext",
53+
"componentWillMount",
54+
"componentDidMount",
55+
"componentWillReceiveProps",
56+
"shouldComponentUpdate",
57+
"componentWillUpdate",
58+
"componentDidUpdate",
59+
"componentWillUnmount",
60+
"/^on.+$/",
61+
"/^get.+$/",
62+
"/^render.+$/",
63+
"/^.+$/", // All other methods go here
64+
"render"
65+
]
66+
}
67+
]
68+
}
69+
}

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

‎LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Klaus Nygård
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# react-share
2+
3+
> Easy social media share buttons and share counts.
4+
5+
<img src="example.png" alt="Share buttons and counts example" />
6+
7+
#### Features:
8+
* open popup-share window
9+
* share counts from most popular social media sites
10+
* use custom icons or generate de-facto social media icons
11+
12+
See demos/demo0 for a concrete example.
13+
14+
## Install
15+
16+
```shell
17+
npm install react-share --save
18+
```
19+
20+
## Compatibility
21+
22+
Compatible with React versions `0.13.x` and `0.14.x`.
23+
24+
## API
25+
26+
```js
27+
import {
28+
ShareButtons,
29+
ShareCounts,
30+
generateShareIcon
31+
} from 'react-share';
32+
```
33+
34+
### Share buttons
35+
36+
```js
37+
const {
38+
FacebookShareButton,
39+
GooglePlusShareButton,
40+
LinkedinShareButton,
41+
TwitterShareButton
42+
} = ShareButtons;
43+
```
44+
45+
Required props for all:
46+
47+
* `children`: A React node (e.g. string or element)
48+
* `url`: URL of the shared page (string)
49+
50+
51+
Required props for `LinkedinShareButton`, `TwitterShareButton`
52+
and `FacebookShareButton`:
53+
54+
* `title`: Title of the shared page (string)
55+
56+
### Share counts
57+
58+
```js
59+
const {
60+
FacebookShareCount,
61+
GooglePlusShareCount,
62+
LinkedinShareCount,
63+
TwitterShareCount
64+
} = ShareCounts;
65+
```
66+
67+
All share count components take in only one mandatory prop: `url`, which is the
68+
URL you are sharing. `className` prop is optional.
69+
70+
Example:
71+
72+
```jsx
73+
<TwitterShareCount url={shareUrl} />
74+
```
75+
76+
If you want to render anything else but the count,
77+
you can provide a function as a child element that takes in `shareCount` as an
78+
argument and returns an element:
79+
80+
```jsx
81+
<TwitterShareCount url={shareUrl}>
82+
{shareCount => (
83+
<span className="myShareCountWrapper">{shareCount}</span>
84+
)}
85+
</TwitterShareCount>
86+
```
87+
88+
### Icons
89+
90+
```js
91+
const FacebookIcon = generateShareIcon('facebook');
92+
const TwitterIcon = generateShareIcon('twitter');
93+
const GooglePlusIcon = generateShareIcon('google');
94+
const LinkedinIcon = generateShareIcon('linkedin');
95+
```
96+
97+
Props:
98+
99+
* `size`: Icon size in pixels (number)
100+
* `round`: Whether to show round or rect icons (bool)
101+
102+
Example:
103+
```
104+
<TwitterIcon size={32} round={true} />
105+
```
106+
107+
## License
108+
109+
MIT
110+
111+
## Icons
112+
113+
Icon paths provided by:
114+
[react-social-icons](https://github.com/jaketrent/react-social-icons).

‎build/generateIcon.js

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, '__esModule', {
4+
value: true
5+
});
6+
exports.generateIcon = generateIcon;
7+
8+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
9+
10+
var _react = require('react');
11+
12+
var _react2 = _interopRequireDefault(_react);
13+
14+
var _icons = require('./icons');
15+
16+
var _icons2 = _interopRequireDefault(_icons);
17+
18+
function generateIcon(network) {
19+
if (!_icons2['default'][network.toLowerCase()]) {
20+
throw new Error('invalid network name for a social icon');
21+
}
22+
23+
var iconConfig = _icons2['default'][network.toLowerCase()];
24+
25+
return _react2['default'].createClass({
26+
propTypes: {
27+
className: _react2['default'].PropTypes.string,
28+
round: _react2['default'].PropTypes.bool,
29+
size: _react2['default'].PropTypes.number
30+
},
31+
32+
getDefaultProps: function getDefaultProps() {
33+
return {
34+
size: 64
35+
};
36+
},
37+
38+
render: function render() {
39+
var _props = this.props;
40+
var className = _props.className;
41+
var round = _props.round;
42+
var size = _props.size;
43+
44+
var baseStyle = {
45+
display: 'inline-block',
46+
width: size,
47+
height: size
48+
};
49+
50+
var svgStyle = {
51+
fill: 'white',
52+
width: size,
53+
height: size
54+
};
55+
56+
var classes = 'social-icon social-icon--' + network + ' ' + className;
57+
58+
return _react2['default'].createElement(
59+
'div',
60+
{ style: baseStyle },
61+
_react2['default'].createElement(
62+
'svg',
63+
{ viewBox: '0 0 64 64',
64+
style: svgStyle,
65+
className: classes },
66+
_react2['default'].createElement(
67+
'g',
68+
null,
69+
!round ? _react2['default'].createElement('rect', {
70+
width: '64',
71+
height: '64',
72+
style: { fill: iconConfig.color } }) : _react2['default'].createElement('circle', {
73+
cx: '32',
74+
cy: '32',
75+
r: '31',
76+
style: { fill: iconConfig.color } })
77+
),
78+
_react2['default'].createElement(
79+
'g',
80+
null,
81+
_react2['default'].createElement('path', { d: iconConfig.icon })
82+
)
83+
)
84+
);
85+
}
86+
});
87+
}

‎build/icons.js

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

‎build/react-share.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
Object.defineProperty(exports, '__esModule', {
4+
value: true
5+
});
6+
7+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
8+
9+
var _generateIcon = require('./generateIcon');
10+
11+
var _shareButtons = require('./share-buttons');
12+
13+
var ShareButtons = _interopRequireWildcard(_shareButtons);
14+
15+
var _shareCounts = require('./share-counts');
16+
17+
var ShareCounts = _interopRequireWildcard(_shareCounts);
18+
19+
exports.generateShareIcon = _generateIcon.generateIcon;
20+
exports.ShareButtons = ShareButtons;
21+
exports.ShareCounts = ShareCounts;

0 commit comments

Comments
 (0)
Please sign in to comment.