Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
view-container / dist / constructors / constructWithOptions.js
Size: Mime:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = (css) => {
    const constructWithOptions = (componentConstructor, tag, options = {}) => {
        // @todo
        // if (!isValidElementType(tag)) {
        //   throw new Error(
        //     process.env.NODE_ENV !== 'production'
        //       ? `Cannot create styled-component for component: ${String(tag)}`
        //       : ''
        //   )
        // }
        /* This is callable directly as a template function */
        // $FlowFixMe: Not typed to avoid destructuring arguments
        const templateFunction = (...args) => componentConstructor(tag, options, css(...args));
        /* If config methods are called, wrap up a new template function and merge options */
        templateFunction.withConfig = config => constructWithOptions(componentConstructor, tag, Object.assign({}, options, config));
        templateFunction.attrs = attrs => constructWithOptions(componentConstructor, tag, Object.assign({}, options, { attrs: Object.assign({}, (options.attrs || {}), attrs) }));
        return templateFunction;
    };
    return constructWithOptions;
};
//# sourceMappingURL=constructWithOptions.js.map