@cloudflare/style-container
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -6,2 +6,10 @@ # Change Log | ||
<a name="1.0.7"></a> | ||
## [1.0.7](http://stash.cfops.it:7999/fe/stratus/compare/@cloudflare/style-container@1.0.6...@cloudflare/style-container@1.0.7) (2018-06-05) | ||
**Note:** Version bump only for package @cloudflare/style-container | ||
<a name="1.0.6"></a> | ||
@@ -18,3 +26,3 @@ ## [1.0.6](http://stash.cfops.it:7999/www/cf-ux/compare/@cloudflare/style-container@1.0.5...@cloudflare/style-container@1.0.6) (2018-05-25) | ||
<a name="1.0.5"></a> | ||
<a name="1.0.5"></a> | ||
## [1.0.5](http://stash.cfops.it:7999/www/cf-ux/compare/@cloudflare/style-container@1.0.4...@cloudflare/style-container@1.0.5) (2018-05-24) | ||
@@ -27,3 +35,3 @@ | ||
<a name="1.0.4"></a> | ||
<a name="1.0.4"></a> | ||
## [1.0.4](http://stash.cfops.it:7999/www/cf-ux/compare/@cloudflare/style-container@1.0.3...@cloudflare/style-container@1.0.4) (2018-05-24) | ||
@@ -40,3 +48,3 @@ | ||
<a name="1.0.3"></a> | ||
<a name="1.0.3"></a> | ||
## [1.0.3](http://stash.cfops.it:7999/www/cf-ux/compare/@cloudflare/style-container@1.0.2...@cloudflare/style-container@1.0.3) (2018-05-14) | ||
@@ -52,3 +60,3 @@ | ||
<a name="1.0.2"></a> | ||
<a name="1.0.2"></a> | ||
## [1.0.2](http://stash.cfops.it:7999/www/cf-ux/compare/@cloudflare/style-container@1.0.1...@cloudflare/style-container@1.0.2) (2018-05-10) | ||
@@ -64,3 +72,3 @@ | ||
<a name="1.0.1"></a> | ||
<a name="1.0.1"></a> | ||
## 1.0.1 (2018-05-09) | ||
@@ -73,3 +81,3 @@ | ||
<a name="9.0.0"></a> | ||
<a name="9.0.0"></a> | ||
# [9.0.0](http://stash.cfops.it:7999/www/cf-ux/compare/cf-style-container@8.1.4...cf-style-container@9.0.0) (2018-05-08) | ||
@@ -98,3 +106,3 @@ | ||
<a name="8.1.4"></a> | ||
<a name="8.1.4"></a> | ||
## [8.1.4](http://stash.cfops.it:7999/www/cf-ux/compare/cf-style-container@8.1.3...cf-style-container@8.1.4) (2018-05-04) | ||
@@ -101,0 +109,0 @@ |
@@ -0,3 +1,22 @@ | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.getDisplayName = undefined; | ||
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; }; }(); | ||
var _react = require('react'); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _propTypes = require('prop-types'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _reactFela = require('react-fela'); | ||
var _displayName = require('./displayName'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -7,11 +26,7 @@ | ||
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; } | ||
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; } /* eslint-disable behance/no-deprecated */ | ||
// eslint-disable-line behance/no-deprecated | ||
/* eslint-disable behance/no-deprecated */ | ||
import React, { PureComponent } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withTheme } from 'react-fela'; // eslint-disable-line behance/no-deprecated | ||
import { hocDisplayName, addDisplayName } from './displayName'; | ||
export var getDisplayName = hocDisplayName('WithStaticStyles'); | ||
var getDisplayName = exports.getDisplayName = (0, _displayName.hocDisplayName)('WithStaticStyles'); | ||
@@ -38,3 +53,3 @@ var applyStaticStyles = function applyStaticStyles(staticStyles, ComponentToWrap) { | ||
value: function render() { | ||
return React.createElement(ComponentToWrap, this.props); | ||
return _react2.default.createElement(ComponentToWrap, this.props); | ||
} | ||
@@ -44,14 +59,14 @@ }]); | ||
return CompWithStaticStyles; | ||
}(PureComponent); | ||
}(_react.PureComponent); | ||
CompWithStaticStyles.contextTypes = { | ||
renderer: PropTypes.object | ||
renderer: _propTypes2.default.object | ||
}; | ||
CompWithStaticStyles.propTypes = { | ||
theme: PropTypes.object | ||
theme: _propTypes2.default.object | ||
}; | ||
var WithThemeHOC = withTheme(CompWithStaticStyles); | ||
addDisplayName(WithThemeHOC, ComponentToWrap, getDisplayName); | ||
var WithThemeHOC = (0, _reactFela.withTheme)(CompWithStaticStyles); | ||
(0, _displayName.addDisplayName)(WithThemeHOC, ComponentToWrap, getDisplayName); | ||
@@ -61,2 +76,2 @@ return WithThemeHOC; | ||
export default applyStaticStyles; | ||
exports.default = applyStaticStyles; |
@@ -0,3 +1,26 @@ | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.getDisplayName = undefined; | ||
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; }; }(); | ||
var _react = require('react'); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _propTypes = require('prop-types'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _reactFela = require('react-fela'); | ||
var _mergeThemes = require('./mergeThemes'); | ||
var _mergeThemes2 = _interopRequireDefault(_mergeThemes); | ||
var _displayName = require('./displayName'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -7,12 +30,7 @@ | ||
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; } | ||
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; } /* eslint-disable behance/no-deprecated */ | ||
// eslint-disable-line behance/no-deprecated | ||
/* eslint-disable behance/no-deprecated */ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withTheme, ThemeProvider } from 'react-fela'; // eslint-disable-line behance/no-deprecated | ||
import mergeThemes from './mergeThemes'; | ||
import { hocDisplayName, addDisplayName } from './displayName'; | ||
export var getDisplayName = hocDisplayName('Themed'); | ||
var getDisplayName = exports.getDisplayName = (0, _displayName.hocDisplayName)('Themed'); | ||
@@ -36,6 +54,6 @@ var applyTheme = function applyTheme(ComponentToWrap) { | ||
value: function render() { | ||
return React.createElement( | ||
ThemeProvider, | ||
{ theme: mergeThemes.apply(undefined, [this.props.theme || {}].concat(themes)) }, | ||
React.createElement(ComponentToWrap, this.props) | ||
return _react2.default.createElement( | ||
_reactFela.ThemeProvider, | ||
{ theme: _mergeThemes2.default.apply(undefined, [this.props.theme || {}].concat(themes)) }, | ||
_react2.default.createElement(ComponentToWrap, this.props) | ||
); | ||
@@ -46,11 +64,11 @@ } | ||
return ThemedComponent; | ||
}(Component); | ||
}(_react.Component); | ||
ThemedComponent._isFelaComponent = true; | ||
ThemedComponent.propTypes = { | ||
theme: PropTypes.object | ||
theme: _propTypes2.default.object | ||
}; | ||
var WithThemeHOC = withTheme(ThemedComponent); | ||
addDisplayName(WithThemeHOC, ComponentToWrap, getDisplayName); | ||
var WithThemeHOC = (0, _reactFela.withTheme)(ThemedComponent); | ||
(0, _displayName.addDisplayName)(WithThemeHOC, ComponentToWrap, getDisplayName); | ||
@@ -60,2 +78,2 @@ return WithThemeHOC; | ||
export default applyTheme; | ||
exports.default = applyTheme; |
@@ -1,5 +0,12 @@ | ||
import { createComponent as createFelaComponent } from 'react-fela'; // eslint-disable-line behance/no-deprecated | ||
import { hocDisplayName, addDisplayName } from './displayName'; | ||
export var getDisplayName = hocDisplayName('FelaComponent'); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.getDisplayName = undefined; | ||
var _reactFela = require('react-fela'); | ||
var _displayName = require('./displayName'); | ||
var getDisplayName = exports.getDisplayName = (0, _displayName.hocDisplayName)('FelaComponent'); | ||
//similar to react-fela's createComponent. However, it automatically adds PropTypes from `[type]` | ||
@@ -10,2 +17,3 @@ //in case that it is a React Component. | ||
//You should use this HOC every time when you want to use Fela in your component. | ||
// eslint-disable-line behance/no-deprecated | ||
var createComponent = function createComponent(rule) { | ||
@@ -15,8 +23,8 @@ var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'div'; | ||
var Component = createFelaComponent(rule, type, type.propTypes ? passThroughProps.concat(Object.keys(type.propTypes)) : passThroughProps); | ||
var Component = (0, _reactFela.createComponent)(rule, type, type.propTypes ? passThroughProps.concat(Object.keys(type.propTypes)) : passThroughProps); | ||
addDisplayName(Component, type, getDisplayName); | ||
(0, _displayName.addDisplayName)(Component, type, getDisplayName); | ||
return Component; | ||
}; | ||
export default createComponent; | ||
exports.default = createComponent; |
@@ -1,12 +0,19 @@ | ||
import { connect } from 'react-fela'; // eslint-disable-line behance/no-deprecated | ||
import { hocDisplayName, addDisplayName } from './displayName'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.getDisplayName = undefined; | ||
export var getDisplayName = hocDisplayName('ConnectedFelaComponent'); | ||
var _reactFela = require('react-fela'); | ||
var _displayName = require('./displayName'); | ||
var getDisplayName = exports.getDisplayName = (0, _displayName.hocDisplayName)('ConnectedFelaComponent'); // eslint-disable-line behance/no-deprecated | ||
var createComponentStyles = function createComponentStyles(styleFunctions, component) { | ||
var ConnectedComponent = connect(styleFunctions)(component); | ||
addDisplayName(ConnectedComponent, component, getDisplayName); | ||
var ConnectedComponent = (0, _reactFela.connect)(styleFunctions)(component); | ||
(0, _displayName.addDisplayName)(ConnectedComponent, component, getDisplayName); | ||
return ConnectedComponent; | ||
}; | ||
export default createComponentStyles; | ||
exports.default = createComponentStyles; |
@@ -0,1 +1,6 @@ | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.borderRadiusProps = exports.borderWidthProps = exports.borderStyleProps = exports.sizeProps = exports.spacingProps = exports.colorProps = undefined; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
@@ -5,2 +10,16 @@ | ||
var _propTypes = require('prop-types'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _createComponent = require('./createComponent'); | ||
var _createComponent2 = _interopRequireDefault(_createComponent); | ||
var _ = require('.'); | ||
var _index = require('@cloudflare/style-const/src/index.js'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
@@ -10,11 +29,7 @@ | ||
import PropTypes from 'prop-types'; | ||
import createComponent from './createComponent'; | ||
import { combineRules } from '.'; | ||
// eslint-disable-line behance/no-deprecated | ||
import { variables as theme } from '@cloudflare/style-const'; // eslint-disable-line behance/no-deprecated | ||
var sizePropType = _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.array, _propTypes2.default.number]); | ||
var scalePropType = _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number, _propTypes2.default.array]); | ||
var sizePropType = PropTypes.oneOfType([PropTypes.string, PropTypes.array, PropTypes.number]); | ||
var scalePropType = PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]); | ||
var shorthandSpacingProps = { | ||
@@ -91,3 +106,3 @@ m: ['margin'], | ||
propTypes[_prop] = PropTypes.string; | ||
propTypes[_prop] = _propTypes2.default.string; | ||
} | ||
@@ -213,3 +228,3 @@ } catch (err) { | ||
var propValues = arr(rules[property]).map(function (val) { | ||
return theme.space[val] || val; | ||
return _index.variables.space[val] || val; | ||
}).map(dec(property)).map(media).reduce(merge, {}); | ||
@@ -233,8 +248,8 @@ | ||
return acc[part]; | ||
}, theme.colors); | ||
}, _index.variables.colors); | ||
} catch (e) { | ||
return val; | ||
} | ||
} else if (typeof theme.colors[val] === 'string') { | ||
return theme.colors[val]; | ||
} else if (typeof _index.variables.colors[val] === 'string') { | ||
return _index.variables.colors[val]; | ||
} | ||
@@ -252,3 +267,3 @@ return val; | ||
var fontSize = arr(rules.fontSize).map(function (val) { | ||
return theme.fontSizes[val] || val; | ||
return _index.variables.fontSizes[val] || val; | ||
}).map(dec('fontSize')).map(media).reduce(merge, {}); | ||
@@ -280,3 +295,3 @@ | ||
var combinedRules = combineRules(rule, propsRule); | ||
var combinedRules = (0, _.combineRules)(rule, propsRule); | ||
return function (props, renderer) { | ||
@@ -294,3 +309,3 @@ return processRules(combinedRules(props, renderer)); | ||
var Component = createComponent.apply(undefined, [styledRule].concat(rest)); | ||
var Component = _createComponent2.default.apply(undefined, [styledRule].concat(rest)); | ||
Component.propTypes = styledPropTypes; | ||
@@ -300,4 +315,8 @@ return Component; | ||
export default createStyledComponent; | ||
export { colorProps, spacingProps, sizeProps, borderStyleProps, borderWidthProps, borderRadiusProps }; | ||
exports.default = createStyledComponent; | ||
exports.colorProps = colorProps; | ||
exports.spacingProps = spacingProps; | ||
exports.sizeProps = sizeProps; | ||
exports.borderStyleProps = borderStyleProps; | ||
exports.borderWidthProps = borderWidthProps; | ||
exports.borderRadiusProps = borderRadiusProps; |
@@ -1,9 +0,18 @@ | ||
import getReactDisplayName from 'react-display-name'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.addDisplayName = exports.hocDisplayName = undefined; | ||
var _reactDisplayName = require('react-display-name'); | ||
var _reactDisplayName2 = _interopRequireDefault(_reactDisplayName); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// create displayName function for a component (WrappedComponent) which is wrapped | ||
// by a HOC. | ||
// hocType can be either a string (such as 'div') or a React Component | ||
export var hocDisplayName = function hocDisplayName(hocType) { | ||
var hocDisplayName = exports.hocDisplayName = function hocDisplayName(hocType) { | ||
return function (WrappedComponent) { | ||
return hocType + '(' + getReactDisplayName(WrappedComponent) + ')'; | ||
return hocType + '(' + (0, _reactDisplayName2.default)(WrappedComponent) + ')'; | ||
}; | ||
@@ -14,3 +23,3 @@ }; | ||
// In addition adds setDisplayName function for setting proper display after HOC is created. | ||
export var addDisplayName = function addDisplayName(HOC, WrappedComponent, getDisplayName) { | ||
var addDisplayName = exports.addDisplayName = function addDisplayName(HOC, WrappedComponent, getDisplayName) { | ||
HOC.displayName = getDisplayName(WrappedComponent); | ||
@@ -17,0 +26,0 @@ HOC.setDisplayName = function (displayName) { |
@@ -1,12 +0,54 @@ | ||
import { combineRules } from 'fela'; // eslint-disable-line behance/no-deprecated | ||
import { ThemeProvider, connect, withTheme } from 'react-fela'; // eslint-disable-line behance/no-deprecated | ||
import { capitalize } from 'underscore.string'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.createStyledComponent = exports.getApplyStatisticStylesDisplayName = exports.applyStaticStyles = exports.getWithRendererDisplayName = exports.withRenderer = exports.withTheme = exports.capitalize = exports.getCreateComponentStylesDisplayName = exports.createComponentStyles = exports.combineRules = exports.connect = exports.ThemeProvider = exports.getApplyThemeDisplayName = exports.applyTheme = exports.getCreateComponentDisplayName = exports.createComponent = undefined; | ||
import applyStaticStyles, { getDisplayName as getApplyStatisticStylesDisplayName } from './applyStaticStyles'; | ||
import applyTheme, { getDisplayName as getApplyThemeDisplayName } from './applyTheme'; | ||
import createComponent, { getDisplayName as getCreateComponentDisplayName } from './createComponent'; | ||
import createComponentStyles, { getDisplayName as getCreateComponentStylesDisplayName } from './createComponentStyles'; | ||
import createStyledComponent from './createStyledComponent'; | ||
import withRenderer, { getDisplayName as getWithRendererDisplayName } from './withRenderer'; | ||
var _fela = require('fela'); | ||
export { createComponent, getCreateComponentDisplayName, applyTheme, getApplyThemeDisplayName, ThemeProvider, connect, combineRules, createComponentStyles, getCreateComponentStylesDisplayName, capitalize, withTheme, withRenderer, getWithRendererDisplayName, applyStaticStyles, getApplyStatisticStylesDisplayName, createStyledComponent }; | ||
var _reactFela = require('react-fela'); | ||
var _underscore = require('underscore.string'); | ||
var _applyStaticStyles = require('./applyStaticStyles'); | ||
var _applyStaticStyles2 = _interopRequireDefault(_applyStaticStyles); | ||
var _applyTheme = require('./applyTheme'); | ||
var _applyTheme2 = _interopRequireDefault(_applyTheme); | ||
var _createComponent = require('./createComponent'); | ||
var _createComponent2 = _interopRequireDefault(_createComponent); | ||
var _createComponentStyles = require('./createComponentStyles'); | ||
var _createComponentStyles2 = _interopRequireDefault(_createComponentStyles); | ||
var _createStyledComponent = require('./createStyledComponent'); | ||
var _createStyledComponent2 = _interopRequireDefault(_createStyledComponent); | ||
var _withRenderer = require('./withRenderer'); | ||
var _withRenderer2 = _interopRequireDefault(_withRenderer); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
// eslint-disable-line behance/no-deprecated | ||
exports.createComponent = _createComponent2.default; | ||
exports.getCreateComponentDisplayName = _createComponent.getDisplayName; | ||
exports.applyTheme = _applyTheme2.default; | ||
exports.getApplyThemeDisplayName = _applyTheme.getDisplayName; | ||
exports.ThemeProvider = _reactFela.ThemeProvider; | ||
exports.connect = _reactFela.connect; | ||
exports.combineRules = _fela.combineRules; | ||
exports.createComponentStyles = _createComponentStyles2.default; | ||
exports.getCreateComponentStylesDisplayName = _createComponentStyles.getDisplayName; | ||
exports.capitalize = _underscore.capitalize; | ||
exports.withTheme = _reactFela.withTheme; | ||
exports.withRenderer = _withRenderer2.default; | ||
exports.getWithRendererDisplayName = _withRenderer.getDisplayName; | ||
exports.applyStaticStyles = _applyStaticStyles2.default; | ||
exports.getApplyStatisticStylesDisplayName = _applyStaticStyles.getDisplayName; | ||
exports.createStyledComponent = _createStyledComponent2.default; // eslint-disable-line behance/no-deprecated |
@@ -0,1 +1,4 @@ | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var mergeThemes = function mergeThemes(baseTheme) { | ||
@@ -19,2 +22,2 @@ for (var _len = arguments.length, themes = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
export default mergeThemes; | ||
exports.default = mergeThemes; |
@@ -0,1 +1,6 @@ | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.getDisplayName = undefined; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
@@ -5,2 +10,14 @@ | ||
var _react = require('react'); | ||
var _react2 = _interopRequireDefault(_react); | ||
var _propTypes = require('prop-types'); | ||
var _propTypes2 = _interopRequireDefault(_propTypes); | ||
var _displayName = require('./displayName'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -10,10 +27,6 @@ | ||
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; } | ||
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; } /* eslint-disable behance/no-deprecated */ | ||
/* eslint-disable behance/no-deprecated */ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { hocDisplayName, addDisplayName } from './displayName'; | ||
export var getDisplayName = hocDisplayName('withRenderer'); | ||
var getDisplayName = exports.getDisplayName = (0, _displayName.hocDisplayName)('withRenderer'); | ||
@@ -33,3 +46,3 @@ var withRenderer = function withRenderer(ComponentToWrap) { | ||
value: function render() { | ||
return React.createElement(ComponentToWrap, _extends({ renderer: this.context.renderer }, this.props)); | ||
return _react2.default.createElement(ComponentToWrap, _extends({ renderer: this.context.renderer }, this.props)); | ||
} | ||
@@ -39,6 +52,6 @@ }]); | ||
return WithRendererComponent; | ||
}(Component); | ||
}(_react.Component); | ||
WithRendererComponent.contextTypes = { renderer: PropTypes.object }; | ||
addDisplayName(WithRendererComponent, ComponentToWrap, getDisplayName); | ||
WithRendererComponent.contextTypes = { renderer: _propTypes2.default.object }; | ||
(0, _displayName.addDisplayName)(WithRendererComponent, ComponentToWrap, getDisplayName); | ||
@@ -48,2 +61,2 @@ return WithRendererComponent; | ||
export default withRenderer; | ||
exports.default = withRenderer; |
@@ -8,2 +8,4 @@ 'use strict'; | ||
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; }; }(); | ||
var _react = require('react'); | ||
@@ -23,19 +25,39 @@ | ||
/* eslint-disable behance/no-deprecated */ | ||
const getDisplayName = exports.getDisplayName = (0, _displayName.hocDisplayName)('WithStaticStyles'); // eslint-disable-line behance/no-deprecated | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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; } | ||
const applyStaticStyles = (staticStyles, ComponentToWrap) => { | ||
class CompWithStaticStyles extends _react.PureComponent { | ||
componentWillMount() { | ||
const contextTheme = this.props.theme || {}; | ||
staticStyles = typeof staticStyles === 'function' ? staticStyles(contextTheme) : staticStyles; | ||
this.context.renderer.renderStatic(staticStyles); | ||
} | ||
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; } /* eslint-disable behance/no-deprecated */ | ||
// eslint-disable-line behance/no-deprecated | ||
render() { | ||
return _react2.default.createElement(ComponentToWrap, this.props); | ||
var getDisplayName = exports.getDisplayName = (0, _displayName.hocDisplayName)('WithStaticStyles'); | ||
var applyStaticStyles = function applyStaticStyles(staticStyles, ComponentToWrap) { | ||
var CompWithStaticStyles = function (_PureComponent) { | ||
_inherits(CompWithStaticStyles, _PureComponent); | ||
function CompWithStaticStyles() { | ||
_classCallCheck(this, CompWithStaticStyles); | ||
return _possibleConstructorReturn(this, (CompWithStaticStyles.__proto__ || Object.getPrototypeOf(CompWithStaticStyles)).apply(this, arguments)); | ||
} | ||
} | ||
_createClass(CompWithStaticStyles, [{ | ||
key: 'componentWillMount', | ||
value: function componentWillMount() { | ||
var contextTheme = this.props.theme || {}; | ||
staticStyles = typeof staticStyles === 'function' ? staticStyles(contextTheme) : staticStyles; | ||
this.context.renderer.renderStatic(staticStyles); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
return _react2.default.createElement(ComponentToWrap, this.props); | ||
} | ||
}]); | ||
return CompWithStaticStyles; | ||
}(_react.PureComponent); | ||
CompWithStaticStyles.contextTypes = { | ||
@@ -49,3 +71,3 @@ renderer: _propTypes2.default.object | ||
const WithThemeHOC = (0, _reactFela.withTheme)(CompWithStaticStyles); | ||
var WithThemeHOC = (0, _reactFela.withTheme)(CompWithStaticStyles); | ||
(0, _displayName.addDisplayName)(WithThemeHOC, ComponentToWrap, getDisplayName); | ||
@@ -52,0 +74,0 @@ |
@@ -8,2 +8,4 @@ 'use strict'; | ||
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; }; }(); | ||
var _react = require('react'); | ||
@@ -27,17 +29,40 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
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; } | ||
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; } /* eslint-disable behance/no-deprecated */ | ||
// eslint-disable-line behance/no-deprecated | ||
const getDisplayName = exports.getDisplayName = (0, _displayName.hocDisplayName)('Themed'); /* eslint-disable behance/no-deprecated */ | ||
const applyTheme = (ComponentToWrap, ...themes) => { | ||
class ThemedComponent extends _react.Component { | ||
render() { | ||
return _react2.default.createElement( | ||
_reactFela.ThemeProvider, | ||
{ theme: (0, _mergeThemes2.default)(this.props.theme || {}, ...themes) }, | ||
_react2.default.createElement(ComponentToWrap, this.props) | ||
); | ||
} | ||
var getDisplayName = exports.getDisplayName = (0, _displayName.hocDisplayName)('Themed'); | ||
var applyTheme = function applyTheme(ComponentToWrap) { | ||
for (var _len = arguments.length, themes = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
themes[_key - 1] = arguments[_key]; | ||
} | ||
var ThemedComponent = function (_Component) { | ||
_inherits(ThemedComponent, _Component); | ||
function ThemedComponent() { | ||
_classCallCheck(this, ThemedComponent); | ||
return _possibleConstructorReturn(this, (ThemedComponent.__proto__ || Object.getPrototypeOf(ThemedComponent)).apply(this, arguments)); | ||
} | ||
_createClass(ThemedComponent, [{ | ||
key: 'render', | ||
value: function render() { | ||
return _react2.default.createElement( | ||
_reactFela.ThemeProvider, | ||
{ theme: _mergeThemes2.default.apply(undefined, [this.props.theme || {}].concat(themes)) }, | ||
_react2.default.createElement(ComponentToWrap, this.props) | ||
); | ||
} | ||
}]); | ||
return ThemedComponent; | ||
}(_react.Component); | ||
ThemedComponent._isFelaComponent = true; | ||
@@ -48,3 +73,3 @@ ThemedComponent.propTypes = { | ||
const WithThemeHOC = (0, _reactFela.withTheme)(ThemedComponent); | ||
var WithThemeHOC = (0, _reactFela.withTheme)(ThemedComponent); | ||
(0, _displayName.addDisplayName)(WithThemeHOC, ComponentToWrap, getDisplayName); | ||
@@ -51,0 +76,0 @@ |
@@ -12,3 +12,3 @@ 'use strict'; | ||
const getDisplayName = exports.getDisplayName = (0, _displayName.hocDisplayName)('FelaComponent'); | ||
var getDisplayName = exports.getDisplayName = (0, _displayName.hocDisplayName)('FelaComponent'); | ||
@@ -21,5 +21,8 @@ //similar to react-fela's createComponent. However, it automatically adds PropTypes from `[type]` | ||
// eslint-disable-line behance/no-deprecated | ||
const createComponent = (rule, type = 'div', passThroughProps = []) => { | ||
const Component = (0, _reactFela.createComponent)(rule, type, type.propTypes ? passThroughProps.concat(Object.keys(type.propTypes)) : passThroughProps); | ||
var createComponent = function createComponent(rule) { | ||
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'div'; | ||
var passThroughProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
var Component = (0, _reactFela.createComponent)(rule, type, type.propTypes ? passThroughProps.concat(Object.keys(type.propTypes)) : passThroughProps); | ||
(0, _displayName.addDisplayName)(Component, type, getDisplayName); | ||
@@ -26,0 +29,0 @@ return Component; |
@@ -12,7 +12,7 @@ 'use strict'; | ||
const getDisplayName = exports.getDisplayName = (0, _displayName.hocDisplayName)('ConnectedFelaComponent'); // eslint-disable-line behance/no-deprecated | ||
var getDisplayName = exports.getDisplayName = (0, _displayName.hocDisplayName)('ConnectedFelaComponent'); // eslint-disable-line behance/no-deprecated | ||
const createComponentStyles = (styleFunctions, component) => { | ||
const ConnectedComponent = (0, _reactFela.connect)(styleFunctions)(component); | ||
var createComponentStyles = function createComponentStyles(styleFunctions, component) { | ||
var ConnectedComponent = (0, _reactFela.connect)(styleFunctions)(component); | ||
(0, _displayName.addDisplayName)(ConnectedComponent, component, getDisplayName); | ||
@@ -19,0 +19,0 @@ return ConnectedComponent; |
@@ -10,2 +10,4 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _propTypes = require('prop-types'); | ||
@@ -21,12 +23,16 @@ | ||
var _styleConst = require('@cloudflare/style-const'); | ||
var _index = require('@cloudflare/style-const/src/index.js'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
// eslint-disable-line behance/no-deprecated | ||
const sizePropType = _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.array, _propTypes2.default.number]); | ||
const scalePropType = _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number, _propTypes2.default.array]); | ||
var sizePropType = _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.array, _propTypes2.default.number]); | ||
var scalePropType = _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number, _propTypes2.default.array]); | ||
const shorthandSpacingProps = { | ||
var shorthandSpacingProps = { | ||
m: ['margin'], | ||
@@ -48,19 +54,19 @@ ml: ['marginLeft'], | ||
const spacingProps = ['padding', 'paddingLeft', 'paddingRight', 'paddingBottom', 'paddingTop', 'margin', 'marginLeft', 'marginRight', 'marginBottom', 'marginTop', ...Object.keys(shorthandSpacingProps)]; | ||
var spacingProps = ['padding', 'paddingLeft', 'paddingRight', 'paddingBottom', 'paddingTop', 'margin', 'marginLeft', 'marginRight', 'marginBottom', 'marginTop'].concat(_toConsumableArray(Object.keys(shorthandSpacingProps))); | ||
const sizeProps = ['width', 'height', 'minWidth', 'minHeight', 'maxWidth', 'maxHeight']; | ||
var sizeProps = ['width', 'height', 'minWidth', 'minHeight', 'maxWidth', 'maxHeight']; | ||
const colorProps = ['color', 'backgroundColor', 'borderColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'borderBottomColor']; | ||
var colorProps = ['color', 'backgroundColor', 'borderColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'borderBottomColor']; | ||
const borderStyleProps = ['borderStyle', 'borderTopStyle', 'borderBottomStyle', 'borderLeftStyle', 'borderRightStyle']; | ||
var borderStyleProps = ['borderStyle', 'borderTopStyle', 'borderBottomStyle', 'borderLeftStyle', 'borderRightStyle']; | ||
const borderWidthProps = ['borderWidth', 'borderTopWidth', 'borderBottomWidth', 'borderLeftWidth', 'borderRightWidth']; | ||
var borderWidthProps = ['borderWidth', 'borderTopWidth', 'borderBottomWidth', 'borderLeftWidth', 'borderRightWidth']; | ||
const borderRadiusProps = ['borderRadius', 'borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomLeftRadius', 'borderbottomRightRadius']; | ||
var borderRadiusProps = ['borderRadius', 'borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomLeftRadius', 'borderbottomRightRadius']; | ||
const propsSet = new Set(spacingProps.concat(sizeProps, colorProps, borderStyleProps, borderWidthProps, borderRadiusProps, 'fontSize', 'textAlign', 'display')); | ||
var propsSet = new Set(spacingProps.concat(sizeProps, colorProps, borderStyleProps, borderWidthProps, borderRadiusProps, 'fontSize', 'textAlign', 'display')); | ||
// Function to construct the prop types object | ||
const makePropTypes = () => { | ||
const propTypes = { | ||
var makePropTypes = function makePropTypes() { | ||
var propTypes = { | ||
fontSize: scalePropType, | ||
@@ -70,46 +76,130 @@ textAlign: sizePropType, | ||
}; | ||
for (let prop of spacingProps.concat(borderWidthProps, borderRadiusProps)) { | ||
propTypes[prop] = scalePropType; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = spacingProps.concat(borderWidthProps, borderRadiusProps)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var prop = _step.value; | ||
propTypes[prop] = scalePropType; | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
for (let prop of colorProps.concat(borderStyleProps)) { | ||
propTypes[prop] = _propTypes2.default.string; | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
try { | ||
for (var _iterator2 = colorProps.concat(borderStyleProps)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
var _prop = _step2.value; | ||
propTypes[_prop] = _propTypes2.default.string; | ||
} | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2.return) { | ||
_iterator2.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
} | ||
} | ||
for (let prop of sizeProps) { | ||
propTypes[prop] = sizePropType; | ||
var _iteratorNormalCompletion3 = true; | ||
var _didIteratorError3 = false; | ||
var _iteratorError3 = undefined; | ||
try { | ||
for (var _iterator3 = sizeProps[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { | ||
var _prop2 = _step3.value; | ||
propTypes[_prop2] = sizePropType; | ||
} | ||
} catch (err) { | ||
_didIteratorError3 = true; | ||
_iteratorError3 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion3 && _iterator3.return) { | ||
_iterator3.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError3) { | ||
throw _iteratorError3; | ||
} | ||
} | ||
} | ||
return propTypes; | ||
}; | ||
const styledPropTypes = makePropTypes(); | ||
var styledPropTypes = makePropTypes(); | ||
// Fela rule which turns component props into a style object | ||
const propsRule = props => Object.keys(props).filter(prop => propsSet.has(prop)).reduce((o, prop) => (o[prop] = props[prop], o), {}); | ||
var propsRule = function propsRule(props) { | ||
return Object.keys(props).filter(function (prop) { | ||
return propsSet.has(prop); | ||
}).reduce(function (o, prop) { | ||
return o[prop] = props[prop], o; | ||
}, {}); | ||
}; | ||
// Static breakpoints | ||
const bp = [null, `tablet`, `desktop`]; | ||
var bp = [null, 'tablet', 'desktop']; | ||
// Ensure value is an array | ||
const arr = n => Array.isArray(n) ? n : [n]; | ||
var arr = function arr(n) { | ||
return Array.isArray(n) ? n : [n]; | ||
}; | ||
// Tranform value array into object array | ||
// [32, 64] into [{margin: 32}, {margin: 64}] | ||
const dec = props => val => arr(props).reduce((acc, prop) => (acc[prop] = val, acc), {}); | ||
var dec = function dec(props) { | ||
return function (val) { | ||
return arr(props).reduce(function (acc, prop) { | ||
return acc[prop] = val, acc; | ||
}, {}); | ||
}; | ||
}; | ||
// Transform object array into breakpoint syntax | ||
// [{margin: 32}, {margin: 64}] into [{margin: 32}, {"@media screen and (min-width: )": {margin: 64}}] | ||
const media = (d, i) => d !== undefined && d !== null ? bp[i] ? { [bp[i]]: d } : d : null; | ||
var media = function media(d, i) { | ||
return d !== undefined && d !== null ? bp[i] ? _defineProperty({}, bp[i], d) : d : null; | ||
}; | ||
// Recursive object merge | ||
const merge = (a, b) => Object.assign({}, a, b, Object.keys(b).reduce((obj, key) => Object.assign(obj, { | ||
[key]: a[key] !== null && typeof a[key] === 'object' ? merge(a[key], b[key]) : b[key] | ||
}), {})); | ||
var merge = function merge(a, b) { | ||
return Object.assign({}, a, b, Object.keys(b).reduce(function (obj, key) { | ||
return Object.assign(obj, _defineProperty({}, key, a[key] !== null && _typeof(a[key]) === 'object' ? merge(a[key], b[key]) : b[key])); | ||
}, {})); | ||
}; | ||
const processRules = customRules => { | ||
let rules = _extends({}, customRules); | ||
var processRules = function processRules(customRules) { | ||
var rules = _extends({}, customRules); | ||
// Expand shorthand spacing properties | ||
['padding', 'margin'].forEach(property => { | ||
['padding', 'margin'].forEach(function (property) { | ||
if (rules.hasOwnProperty(property)) { | ||
['Top', 'Bottom', 'Left', 'Right'].forEach(position => { | ||
const attr = `${property}${position}`; | ||
['Top', 'Bottom', 'Left', 'Right'].forEach(function (position) { | ||
var attr = '' + property + position; | ||
// Don't overwrite pre-existing longhand properties | ||
@@ -125,4 +215,6 @@ if (!rules[attr]) { | ||
// Expand custom shorthand spacing properties | ||
Object.keys(rules).filter(property => Object.keys(shorthandSpacingProps).includes(property)).forEach(property => { | ||
Object.assign(rules, shorthandSpacingProps[property].reduce((a, b) => { | ||
Object.keys(rules).filter(function (property) { | ||
return Object.keys(shorthandSpacingProps).includes(property); | ||
}).forEach(function (property) { | ||
Object.assign(rules, shorthandSpacingProps[property].reduce(function (a, b) { | ||
a[b] = rules[property]; | ||
@@ -136,4 +228,8 @@ return a; | ||
// Convert spacing scales | ||
rules = Object.keys(rules).filter(property => spacingProps.includes(property)).map(property => { | ||
const propValues = arr(rules[property]).map(val => _styleConst.variables.space[val] || val).map(dec(property)).map(media).reduce(merge, {}); | ||
rules = Object.keys(rules).filter(function (property) { | ||
return spacingProps.includes(property); | ||
}).map(function (property) { | ||
var propValues = arr(rules[property]).map(function (val) { | ||
return _index.variables.space[val] || val; | ||
}).map(dec(property)).map(media).reduce(merge, {}); | ||
@@ -146,4 +242,6 @@ delete rules[property]; | ||
// Convert colors to theme | ||
rules = Object.keys(rules).filter(property => colorProps.includes(property)).map(property => { | ||
const propValues = arr(rules[property]).map(val => { | ||
rules = Object.keys(rules).filter(function (property) { | ||
return colorProps.includes(property); | ||
}).map(function (property) { | ||
var propValues = arr(rules[property]).map(function (val) { | ||
// Handle nested '.' syntax | ||
@@ -153,8 +251,10 @@ if (val.includes('.')) { | ||
try { | ||
return val.split('.').reduce((acc, part) => acc[part], _styleConst.variables.colors); | ||
return val.split('.').reduce(function (acc, part) { | ||
return acc[part]; | ||
}, _index.variables.colors); | ||
} catch (e) { | ||
return val; | ||
} | ||
} else if (typeof _styleConst.variables.colors[val] === 'string') { | ||
return _styleConst.variables.colors[val]; | ||
} else if (typeof _index.variables.colors[val] === 'string') { | ||
return _index.variables.colors[val]; | ||
} | ||
@@ -171,3 +271,5 @@ return val; | ||
if (rules.fontSize) { | ||
let fontSize = arr(rules.fontSize).map(val => _styleConst.variables.fontSizes[val] || val).map(dec('fontSize')).map(media).reduce(merge, {}); | ||
var fontSize = arr(rules.fontSize).map(function (val) { | ||
return _index.variables.fontSizes[val] || val; | ||
}).map(dec('fontSize')).map(media).reduce(merge, {}); | ||
@@ -181,3 +283,3 @@ delete rules.fontSize; | ||
if (rules.display) { | ||
let display = arr(rules.display).map(dec('display')).map(media).reduce(merge, {}); | ||
var display = arr(rules.display).map(dec('display')).map(media).reduce(merge, {}); | ||
@@ -192,12 +294,23 @@ delete rules.display; | ||
const emptyRule = () => ({}); | ||
var emptyRule = function emptyRule() { | ||
return {}; | ||
}; | ||
const makeStyledRule = (rule = emptyRule) => { | ||
const combinedRules = (0, _.combineRules)(rule, propsRule); | ||
return (props, renderer) => processRules(combinedRules(props, renderer)); | ||
var makeStyledRule = function makeStyledRule() { | ||
var rule = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : emptyRule; | ||
var combinedRules = (0, _.combineRules)(rule, propsRule); | ||
return function (props, renderer) { | ||
return processRules(combinedRules(props, renderer)); | ||
}; | ||
}; | ||
function createStyledComponent(rule, ...rest) { | ||
const styledRule = makeStyledRule(rule); | ||
const Component = (0, _createComponent2.default)(styledRule, ...rest); | ||
function createStyledComponent(rule) { | ||
var styledRule = makeStyledRule(rule); | ||
for (var _len = arguments.length, rest = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
rest[_key - 1] = arguments[_key]; | ||
} | ||
var Component = _createComponent2.default.apply(undefined, [styledRule].concat(rest)); | ||
Component.propTypes = styledPropTypes; | ||
@@ -204,0 +317,0 @@ return Component; |
@@ -17,9 +17,13 @@ 'use strict'; | ||
// hocType can be either a string (such as 'div') or a React Component | ||
const hocDisplayName = exports.hocDisplayName = hocType => WrappedComponent => `${hocType}(${(0, _reactDisplayName2.default)(WrappedComponent)})`; | ||
var hocDisplayName = exports.hocDisplayName = function hocDisplayName(hocType) { | ||
return function (WrappedComponent) { | ||
return hocType + '(' + (0, _reactDisplayName2.default)(WrappedComponent) + ')'; | ||
}; | ||
}; | ||
// Add displayName to a Component | ||
// In addition adds setDisplayName function for setting proper display after HOC is created. | ||
const addDisplayName = exports.addDisplayName = (HOC, WrappedComponent, getDisplayName) => { | ||
var addDisplayName = exports.addDisplayName = function addDisplayName(HOC, WrappedComponent, getDisplayName) { | ||
HOC.displayName = getDisplayName(WrappedComponent); | ||
HOC.setDisplayName = displayName => { | ||
HOC.setDisplayName = function (displayName) { | ||
HOC.displayName = getDisplayName(displayName); | ||
@@ -26,0 +30,0 @@ }; |
@@ -6,5 +6,9 @@ 'use strict'; | ||
}); | ||
const mergeThemes = (baseTheme, ...themes) => { | ||
var mergeThemes = function mergeThemes(baseTheme) { | ||
for (var _len = arguments.length, themes = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
themes[_key - 1] = arguments[_key]; | ||
} | ||
if (themes) { | ||
return themes.reduce((acc, theme) => { | ||
return themes.reduce(function (acc, theme) { | ||
if (typeof theme === 'function') { | ||
@@ -11,0 +15,0 @@ theme = theme(baseTheme); |
@@ -8,4 +8,5 @@ 'use strict'; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /* eslint-disable behance/no-deprecated */ | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
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; }; }(); | ||
@@ -24,10 +25,31 @@ var _react = require('react'); | ||
const getDisplayName = exports.getDisplayName = (0, _displayName.hocDisplayName)('withRenderer'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
const withRenderer = ComponentToWrap => { | ||
class WithRendererComponent extends _react.Component { | ||
render() { | ||
return _react2.default.createElement(ComponentToWrap, _extends({ renderer: this.context.renderer }, this.props)); | ||
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; } | ||
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; } /* eslint-disable behance/no-deprecated */ | ||
var getDisplayName = exports.getDisplayName = (0, _displayName.hocDisplayName)('withRenderer'); | ||
var withRenderer = function withRenderer(ComponentToWrap) { | ||
var WithRendererComponent = function (_Component) { | ||
_inherits(WithRendererComponent, _Component); | ||
function WithRendererComponent() { | ||
_classCallCheck(this, WithRendererComponent); | ||
return _possibleConstructorReturn(this, (WithRendererComponent.__proto__ || Object.getPrototypeOf(WithRendererComponent)).apply(this, arguments)); | ||
} | ||
} | ||
_createClass(WithRendererComponent, [{ | ||
key: 'render', | ||
value: function render() { | ||
return _react2.default.createElement(ComponentToWrap, _extends({ renderer: this.context.renderer }, this.props)); | ||
} | ||
}]); | ||
return WithRendererComponent; | ||
}(_react.Component); | ||
WithRendererComponent.contextTypes = { renderer: _propTypes2.default.object }; | ||
@@ -34,0 +56,0 @@ (0, _displayName.addDisplayName)(WithRendererComponent, ComponentToWrap, getDisplayName); |
{ | ||
"name": "@cloudflare/style-container", | ||
"description": "Cloudflare Style Container", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"main": "lib/index.js", | ||
@@ -15,3 +15,3 @@ "module": "es/index.js", | ||
"dependencies": { | ||
"@cloudflare/style-const": "^1.0.5", | ||
"@cloudflare/style-const": "^1.0.6", | ||
"fela": "^6.0.5", | ||
@@ -18,0 +18,0 @@ "fela-utils": "^7.0.5", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94946
1469