react-color
Version:
A Collection of Color Pickers from Sketch, Photoshop, Chrome & more
125 lines (104 loc) • 4.39 kB
JavaScript
/* jshint node: true, esnext: true */
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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 _reactcss = require('reactcss');
var _reactcss2 = _interopRequireDefault(_reactcss);
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"); } }
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; }
var Raised = function (_React$Component) {
_inherits(Raised, _React$Component);
function Raised() {
_classCallCheck(this, Raised);
return _possibleConstructorReturn(this, Object.getPrototypeOf(Raised).apply(this, arguments));
}
_createClass(Raised, [{
key: 'render',
value: function render() {
var styles = (0, _reactcss2.default)({
'default': {
wrap: {
position: 'relative'
},
content: {
position: 'relative'
},
bg: {
absolute: '0px 0px 0px 0px',
boxShadow: '0 ${ this.props.zDepth }px ${ this.props.zDepth * 4 }px rgba(0,0,0,.24)',
borderRadius: this.props.radius,
background: this.props.background
}
},
'zDepth-0': {
bg: {
boxShadow: 'none'
}
},
'zDepth-1': {
bg: {
boxShadow: '0 2px 10px rgba(0,0,0,.12), 0 2px 5px rgba(0,0,0,.16)'
}
},
'zDepth-2': {
bg: {
boxShadow: '0 6px 20px rgba(0,0,0,.19), 0 8px 17px rgba(0,0,0,.2)'
}
},
'zDepth-3': {
bg: {
boxShadow: '0 17px 50px rgba(0,0,0,.19), 0 12px 15px rgba(0,0,0,.24)'
}
},
'zDepth-4': {
bg: {
boxShadow: '0 25px 55px rgba(0,0,0,.21), 0 16px 28px rgba(0,0,0,.22)'
}
},
'zDepth-5': {
bg: {
boxShadow: '0 40px 77px rgba(0,0,0,.22), 0 27px 24px rgba(0,0,0,.2)'
}
},
'square': {
bg: {
borderRadius: '0'
}
},
'circle': {
bg: {
borderRadius: '50%'
}
}
}, this.props);
return _react2.default.createElement(
'div',
{ style: styles.wrap },
_react2.default.createElement('div', { style: styles.bg }),
_react2.default.createElement(
'div',
{ style: styles.content },
this.props.children
)
);
}
}]);
return Raised;
}(_react2.default.Component);
Raised.propTypes = {
background: _react2.default.PropTypes.string,
zDepth: _react2.default.PropTypes.oneOf(['0', '1', '2', '3', '4', '5', 0, 1, 2, 3, 4, 5]),
radius: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.number])
};
Raised.defaultProps = {
background: '#fff',
zDepth: '1',
radius: '2px'
};
exports.default = Raised;