Skip to content

Commit e6bc926

Browse files
author
Octave
committed
add lib
1 parent a3ec878 commit e6bc926

File tree

6 files changed

+5937
-1
lines changed

6 files changed

+5937
-1
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
build
2-
lib
32
node_modules
43
npm-debug.log

lib/components/ThemeProvider.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
'use strict';
2+
3+
exports.__esModule = true;
4+
exports.default = undefined;
5+
6+
var _class, _temp;
7+
8+
var _react = require('react');
9+
10+
var _propTypes = require('prop-types');
11+
12+
var _propTypes2 = _interopRequireDefault(_propTypes);
13+
14+
var _themrShape = require('../utils/themr-shape');
15+
16+
var _themrShape2 = _interopRequireDefault(_themrShape);
17+
18+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19+
20+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
21+
22+
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; }
23+
24+
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; }
25+
26+
var ThemeProvider = (_temp = _class = function (_Component) {
27+
_inherits(ThemeProvider, _Component);
28+
29+
function ThemeProvider() {
30+
_classCallCheck(this, ThemeProvider);
31+
32+
return _possibleConstructorReturn(this, _Component.apply(this, arguments));
33+
}
34+
35+
ThemeProvider.prototype.getChildContext = function getChildContext() {
36+
return {
37+
themr: {
38+
theme: this.props.theme
39+
}
40+
};
41+
};
42+
43+
ThemeProvider.prototype.render = function render() {
44+
return _react.Children.only(this.props.children);
45+
};
46+
47+
return ThemeProvider;
48+
}(_react.Component), _class.propTypes = {
49+
children: _propTypes2.default.element.isRequired,
50+
theme: _propTypes2.default.object.isRequired
51+
}, _class.defaultProps = {
52+
theme: {}
53+
}, _class.childContextTypes = {
54+
themr: _themrShape2.default.isRequired
55+
}, _temp);
56+
exports.default = ThemeProvider;

0 commit comments

Comments
 (0)