UNPKG

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