Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gild

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gild - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

79

lib/index.js

@@ -12,4 +12,2 @@ 'use strict';

var _react2 = _interopRequireDefault(_react);
var _lodash = require('lodash.omit');

@@ -19,12 +17,8 @@

var _jss = require('jss');
var _recompose = require('recompose');
var _jss2 = _interopRequireDefault(_jss);
var _withSheet = require('./with-sheet');
var _isEqual = require('is-equal');
var _withSheet2 = _interopRequireDefault(_withSheet);
var _isEqual2 = _interopRequireDefault(_isEqual);
var _recompose = require('recompose');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -44,61 +38,12 @@

var withSheet = function withSheet(mapThemeToCss) {
var refs = 0;
var sheet = null;
var cache = null;
var attach = function attach(nextState) {
var force = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
if ((0, _isEqual2.default)(nextState, cache)) return;
cache = nextState;
if (force || !sheet) sheet = _jss2.default.createStyleSheet(nextState);
sheet.attach();
};
var ref = function ref(nextState) {
if (refs === 0) attach(nextState);
refs++;
return sheet;
};
var deref = function deref() {
refs--;
if (refs === 0) {
sheet.detach();
cache = null;
}
};
return (0, _recompose.compose)((0, _recompose.lifecycle)({
componentWillMount: function componentWillMount() {
var nextState = mapThemeToCss(this.props.theme);
ref(nextState);
},
componentWillReceiveProps: function componentWillReceiveProps(nextProps) {
if (!(0, _isEqual2.default)(this.props.theme, nextProps.theme)) {
attach(mapThemeToCss(nextProps.theme), true);
}
},
componentWillUnmount: function componentWillUnmount() {
deref();
}
}), (0, _recompose.withProps)(function () {
return {
sheet: sheet
};
var connectTheme = exports.connectTheme = function connectTheme(mapThemeToCss) {
return (0, _recompose.compose)(function (comp) {
return (0, _recompose.setDisplayName)((0, _recompose.wrapDisplayName)(comp, 'gild'))(comp);
}, (0, _recompose.getContext)({ theme: _react.PropTypes.object }), (0, _recompose.branch)(function (props) {
return props.theme;
}, (0, _recompose.compose)((0, _withSheet2.default)(mapThemeToCss), (0, _recompose.mapProps)(function (props) {
return _extends({}, props, { theme: props.sheet.classes });
}), omitProp('sheet')), function (c) {
return c;
}));
};
var connectTheme = exports.connectTheme = function connectTheme(mapThemeToCss) {
return function (BaseComponent) {
return (0, _recompose.compose)((0, _recompose.setDisplayName)((0, _recompose.wrapDisplayName)(BaseComponent, 'gild')), (0, _recompose.getContext)({ theme: _react.PropTypes.object }), (0, _recompose.branch)(function (props) {
return props.theme;
}, (0, _recompose.compose)(withSheet(mapThemeToCss), (0, _recompose.mapProps)(function (props) {
return _extends({}, props, { theme: props.sheet.classes });
}), omitProp('sheet')), function (c) {
return c;
}))(BaseComponent);
};
};

2

package.json
{
"name": "gild",
"version": "0.1.3",
"version": "0.1.4",
"description": "Pass theme object via react context to jss on a component",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc