main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[d565449] | 1 | "use strict";
|
---|
| 2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 3 | var tslib_1 = require("tslib");
|
---|
| 4 | var nano_css_1 = require("nano-css");
|
---|
| 5 | var cssom_1 = require("nano-css/addon/cssom");
|
---|
| 6 | var vcssom_1 = require("nano-css/addon/vcssom");
|
---|
| 7 | var cssToTree_1 = require("nano-css/addon/vcssom/cssToTree");
|
---|
| 8 | var react_1 = require("react");
|
---|
| 9 | var useIsomorphicLayoutEffect_1 = tslib_1.__importDefault(require("./useIsomorphicLayoutEffect"));
|
---|
| 10 | var nano = nano_css_1.create();
|
---|
| 11 | cssom_1.addon(nano);
|
---|
| 12 | vcssom_1.addon(nano);
|
---|
| 13 | var counter = 0;
|
---|
| 14 | var useCss = function (css) {
|
---|
| 15 | var className = react_1.useMemo(function () { return 'react-use-css-' + (counter++).toString(36); }, []);
|
---|
| 16 | var sheet = react_1.useMemo(function () { return new nano.VSheet(); }, []);
|
---|
| 17 | useIsomorphicLayoutEffect_1.default(function () {
|
---|
| 18 | var tree = {};
|
---|
| 19 | cssToTree_1.cssToTree(tree, css, '.' + className, '');
|
---|
| 20 | sheet.diff(tree);
|
---|
| 21 | return function () {
|
---|
| 22 | sheet.diff({});
|
---|
| 23 | };
|
---|
| 24 | });
|
---|
| 25 | return className;
|
---|
| 26 | };
|
---|
| 27 | exports.default = useCss;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.