UNPKG

1.22 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = flushToReact;
7exports.flushToHTML = flushToHTML;
8
9var _react = _interopRequireDefault(require("react"));
10
11var _style = require("./style");
12
13function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15function flushToReact() {
16 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
17 return (0, _style.flush)().map(function (args) {
18 var id = args[0];
19 var css = args[1];
20 return _react.default.createElement('style', {
21 id: "__".concat(id),
22 // Avoid warnings upon render with a key
23 key: "__".concat(id),
24 nonce: options.nonce ? options.nonce : undefined,
25 dangerouslySetInnerHTML: {
26 __html: css
27 }
28 });
29 });
30}
31
32function flushToHTML() {
33 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
34 return (0, _style.flush)().reduce(function (html, args) {
35 var id = args[0];
36 var css = args[1];
37 html += "<style id=\"__".concat(id, "\"").concat(options.nonce ? " nonce=\"".concat(options.nonce, "\"") : '', ">").concat(css, "</style>");
38 return html;
39 }, '');
40}
\No newline at end of file