Skip to content

Commit 79573e5

Browse files
committed
update v0.0.2, for react@15.x.x
1 parent c7a2b9f commit 79573e5

File tree

11 files changed

+171
-125
lines changed

11 files changed

+171
-125
lines changed

.babelrc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
{
2-
"presets": ["react", "es2015"],
3-
"plugins": [],
4-
"env": {
5-
"development": {
6-
}
7-
}
2+
"presets": ["react", "es2015"]
83
}

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
language: node_js
22
node_js:
3-
- "0.12"
3+
- "6.10.2"

demo/dist/bundle.js

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/baidu.js

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,45 @@
1-
'use strict';
1+
"use strict";
22

3-
var _react = require('react');
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8+
9+
var _react = require("react");
410

511
var _react2 = _interopRequireDefault(_react);
612

713
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
814

9-
var Baidu = _react2.default.createClass({
10-
displayName: 'Baidu',
15+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16+
17+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
18+
19+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
1120

12-
render: function render() {
13-
return _react2.default.createElement(
14-
'p',
15-
null,
16-
' TODO !'
17-
);
21+
var Baidu = function (_React$Component) {
22+
_inherits(Baidu, _React$Component);
23+
24+
function Baidu() {
25+
_classCallCheck(this, Baidu);
26+
27+
return _possibleConstructorReturn(this, (Baidu.__proto__ || Object.getPrototypeOf(Baidu)).apply(this, arguments));
1828
}
19-
});
2029

21-
module.exports = Baidu;
30+
_createClass(Baidu, [{
31+
key: "render",
32+
value: function render() {
33+
return _react2.default.createElement(
34+
"div",
35+
{ className: "adsbybaidu" },
36+
"TODO"
37+
);
38+
}
39+
}]);
40+
41+
return Baidu;
42+
}(_react2.default.Component);
43+
44+
exports.default = Baidu;
45+
;

lib/google.js

Lines changed: 56 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,66 @@
11
'use strict';
22

3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
7+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8+
39
var _react = require('react');
410

511
var _react2 = _interopRequireDefault(_react);
612

13+
var _propTypes = require('prop-types');
14+
15+
var _propTypes2 = _interopRequireDefault(_propTypes);
16+
717
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
818

9-
var Google = _react2.default.createClass({
10-
displayName: 'Google',
11-
12-
propTypes: {
13-
style: _react2.default.PropTypes.object,
14-
client: _react2.default.PropTypes.string.isRequired,
15-
slot: _react2.default.PropTypes.string.isRequired,
16-
format: _react2.default.PropTypes.string
17-
},
18-
19-
componentDidMount: function componentDidMount() {
20-
if (window) (window.adsbygoogle = window.adsbygoogle || []).push({});
21-
},
22-
23-
getDefaultProps: function getDefaultProps() {
24-
return {
25-
style: { display: 'block' },
26-
format: 'auto'
27-
};
28-
},
29-
30-
render: function render() {
31-
return _react2.default.createElement('ins', { className: 'adsbygoogle',
32-
style: this.props.style,
33-
'data-ad-client': this.props.client,
34-
'data-ad-slot': this.props.slot,
35-
'data-ad-format': this.props.format });
19+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
20+
21+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
22+
23+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
24+
25+
var Google = function (_React$Component) {
26+
_inherits(Google, _React$Component);
27+
28+
function Google() {
29+
_classCallCheck(this, Google);
30+
31+
return _possibleConstructorReturn(this, (Google.__proto__ || Object.getPrototypeOf(Google)).apply(this, arguments));
3632
}
37-
});
3833

39-
module.exports = Google;
34+
_createClass(Google, [{
35+
key: 'componentDidMount',
36+
value: function componentDidMount() {
37+
if (window) (window.adsbygoogle = window.adsbygoogle || []).push({});
38+
}
39+
}, {
40+
key: 'render',
41+
value: function render() {
42+
return _react2.default.createElement('ins', { className: 'adsbygoogle',
43+
style: this.props.style,
44+
'data-ad-client': this.props.client,
45+
'data-ad-slot': this.props.slot,
46+
'data-ad-format': this.props.format });
47+
}
48+
}]);
49+
50+
return Google;
51+
}(_react2.default.Component);
52+
53+
exports.default = Google;
54+
;
55+
56+
Google.propTypes = {
57+
style: _react2.default.PropTypes.object, // eslint-disable-line
58+
client: _react2.default.PropTypes.string.isRequired,
59+
slot: _react2.default.PropTypes.string.isRequired,
60+
format: _react2.default.PropTypes.string
61+
};
62+
63+
Google.defaultProps = {
64+
style: { display: 'block' },
65+
format: 'auto'
66+
};

lib/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ var _baidu2 = _interopRequireDefault(_baidu);
1414

1515
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1616

17-
var AdSense = {};
18-
AdSense.Google = _google2.default;
19-
AdSense.Baidu = _baidu2.default;
17+
var AdSense = {
18+
Google: _google2.default,
19+
Baidu: _baidu2.default
20+
};
2021

2122
exports.default = AdSense;

package.json

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-adsense",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "A Simple React component for Google AdSense and Baidu advertisement.",
55
"main": "lib/index.js",
66
"scripts": {
@@ -32,29 +32,30 @@
3232
},
3333
"homepage": "https://github.com/hustcc/react-adsense",
3434
"devDependencies": {
35-
"babel-cli": "^6.6.0",
36-
"babel-core": "^6.3.15",
37-
"babel-eslint": "^5.0.0-beta4",
38-
"babel-loader": "^6.2.0",
39-
"babel-preset-es2015": "^6.3.13",
40-
"babel-preset-react": "^6.3.13",
41-
"babel-preset-react-hmre": "^1.0.0",
42-
"eslint": "^1.10.3",
43-
"eslint-plugin-babel": "^3.0.0",
44-
"eslint-plugin-react": "^3.11.3",
45-
"react": "^0.14.0",
46-
"react-dom": "^0.14.0",
47-
"webpack": "^1.12.9",
48-
"css-loader": "~0.16.0",
49-
"jsx-loader": "~0.13.2",
50-
"style-loader": "~0.12.3",
51-
"file-loader": "~0.8.4",
52-
"rimraf": "^2.5.0",
53-
"cross-env": "^1.0.8"
54-
},
55-
"dependencies": {
35+
"babel-cli": "^6.24.1",
36+
"babel-core": "^6.24.1",
37+
"babel-eslint": "^7.2.3",
38+
"babel-loader": "^7.0.0",
39+
"babel-preset-es2015": "^6.24.1",
40+
"babel-preset-react": "^6.24.1",
41+
"babel-preset-react-hmre": "^1.1.1",
42+
"cross-env": "^5.0.0",
43+
"css-loader": "^0.28.4",
44+
"eslint": "^3.19.0",
45+
"eslint-plugin-babel": "^4.1.1",
46+
"eslint-plugin-react": "^7.0.1",
47+
"file-loader": "^0.11.1",
48+
"jsx-loader": "^0.13.2",
49+
"prop-types": "^15.5.10",
50+
"react": "^15.5.4",
51+
"react-dom": "^15.5.4",
52+
"rimraf": "^2.6.1",
53+
"style-loader": "^0.18.1",
54+
"webpack": "^2.6.1"
5655
},
56+
"dependencies": {},
5757
"peerDependencies": {
58-
"react": ">=0.13.2 || ^0.14 || ^15.0.0"
58+
"react": ">=0.13.2 || ^0.14 || ^15.0.0 || >=16.0.0-alpha.1 <17.0.0",
59+
"prop-types": ">=15.0.0"
5960
}
6061
}

src/baidu.jsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import React from 'react';
22

3-
const Baidu = React.createClass({
4-
render: function() {
3+
export default class Baidu extends React.Component {
4+
render() {
55
return (
6-
<p> TODO !</p>
6+
<div className="adsbybaidu">TODO</div>
77
);
8-
},
9-
});
10-
11-
module.exports = Baidu;
8+
}
9+
};

src/google.jsx

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23

3-
const Google = React.createClass({
4-
propTypes: {
5-
style: React.PropTypes.object,
6-
client: React.PropTypes.string.isRequired,
7-
slot: React.PropTypes.string.isRequired,
8-
format: React.PropTypes.string
9-
},
10-
11-
componentDidMount: function() {
4+
export default class Google extends React.Component {
5+
componentDidMount() {
126
if(window) (window.adsbygoogle = window.adsbygoogle || []).push({});
13-
},
14-
15-
getDefaultProps: function() {
16-
return {
17-
style: {display: 'block'},
18-
format: 'auto'
19-
};
20-
},
7+
};
218

22-
render: function() {
9+
render() {
2310
return (
2411
<ins className="adsbygoogle"
2512
style={this.props.style}
@@ -28,6 +15,16 @@ const Google = React.createClass({
2815
data-ad-format={this.props.format}></ins>
2916
);
3017
}
31-
});
18+
};
19+
20+
Google.propTypes = {
21+
style: React.PropTypes.object, // eslint-disable-line
22+
client: React.PropTypes.string.isRequired,
23+
slot: React.PropTypes.string.isRequired,
24+
format: React.PropTypes.string,
25+
};
3226

33-
module.exports = Google;
27+
Google.defaultProps = {
28+
style: {display: 'block'},
29+
format: 'auto',
30+
};

src/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import Google from './google';
22
import Baidu from './baidu';
33

4-
let AdSense = {};
5-
AdSense.Google = Google;
6-
AdSense.Baidu = Baidu;
4+
const AdSense = {
5+
Google,
6+
Baidu
7+
};
78

89
export default AdSense;

0 commit comments

Comments
 (0)