mirror of
https://github.com/Rushilwiz/spaceout.git
synced 2025-04-22 04:19:49 -04:00
35 lines
915 B
JavaScript
35 lines
915 B
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
import PropTypes from 'prop-types';
|
|
import merge from './merge';
|
|
|
|
function omit(input, fields) {
|
|
const output = {};
|
|
Object.keys(input).forEach(prop => {
|
|
if (fields.indexOf(prop) === -1) {
|
|
output[prop] = input[prop];
|
|
}
|
|
});
|
|
return output;
|
|
}
|
|
|
|
function css(styleFunction) {
|
|
const newStyleFunction = props => {
|
|
const output = styleFunction(props);
|
|
|
|
if (props.css) {
|
|
return _extends({}, merge(output, styleFunction(_extends({
|
|
theme: props.theme
|
|
}, props.css))), omit(props.css, [styleFunction.filterProps]));
|
|
}
|
|
|
|
return output;
|
|
};
|
|
|
|
newStyleFunction.propTypes = process.env.NODE_ENV !== 'production' ? _extends({}, styleFunction.propTypes, {
|
|
css: PropTypes.object
|
|
}) : {};
|
|
newStyleFunction.filterProps = ['css', ...styleFunction.filterProps];
|
|
return newStyleFunction;
|
|
}
|
|
|
|
export default css; |