@slimr/css 2.1.10 → 2.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -15
- package/cjs/createClass.d.ts +21 -93
- package/cjs/createClass.js +88 -132
- package/cjs/createClass.js.map +1 -1
- package/cjs/createClass.ts +92 -211
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +1 -0
- package/cjs/index.js.map +1 -1
- package/cjs/index.ts +1 -0
- package/cjs/shorthandProps.d.ts +75 -0
- package/cjs/shorthandProps.js +51 -0
- package/cjs/shorthandProps.js.map +1 -0
- package/cjs/shorthandProps.ts +118 -0
- package/esm/createClass.d.ts +21 -93
- package/esm/createClass.js +85 -128
- package/esm/createClass.js.map +1 -1
- package/esm/createClass.ts +92 -211
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/index.ts +1 -0
- package/esm/shorthandProps.d.ts +75 -0
- package/esm/shorthandProps.js +47 -0
- package/esm/shorthandProps.js.map +1 -0
- package/esm/shorthandProps.ts +118 -0
- package/package.json +4 -1
- package/src/createClass.ts +92 -211
- package/src/index.ts +1 -0
- package/src/shorthandProps.ts +118 -0
- package/tsconfig.json +4 -1
package/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
# @slimr/css
|
|
1
|
+
# @slimr/css
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Demos: See `./examples/css-and-styled` or [CodeSandbox](https://codesandbox.io/s/64r9px?file=/src/App.tsx)
|
|
3
|
+
tiny css-in-js features, inspired by the popular emotion library
|
|
6
4
|
|
|
7
5
|
`@slimr` is a set of slim React (hence '@slimr') libs:
|
|
8
6
|
|
|
@@ -18,9 +16,9 @@ Demos: See `./examples/css-and-styled` or [CodeSandbox](https://codesandbox.io/s
|
|
|
18
16
|
|
|
19
17
|
Pros:
|
|
20
18
|
|
|
21
|
-
- Much less bundle size
|
|
19
|
+
- Much smaller (less bundle size)
|
|
22
20
|
- Less is more: faster, less bugs, no breaking changes
|
|
23
|
-
- Is progressive -- lazy loads styles
|
|
21
|
+
- Is progressive -- lazy loads styles
|
|
24
22
|
- Css shorthand props like [chakra-ui](https://chakra-ui.com/docs/styled-system/style-props):
|
|
25
23
|
- `m` --> `margin`
|
|
26
24
|
- `mx` --> `margin-left` and bottom
|
|
@@ -37,11 +35,7 @@ Pros:
|
|
|
37
35
|
}
|
|
38
36
|
```
|
|
39
37
|
|
|
40
|
-
- Breakpoints are `[30em, 48em, 62em, 80em, 96em]`
|
|
41
|
-
|
|
42
|
-
Cons:
|
|
43
|
-
|
|
44
|
-
- No SSR support
|
|
38
|
+
- Breakpoints are `[30em, 48em, 62em, 80em, 96em]` and can be overridden by setting `css.breakpoints`
|
|
45
39
|
|
|
46
40
|
## Setup/Install
|
|
47
41
|
|
|
@@ -49,6 +43,30 @@ Cons:
|
|
|
49
43
|
npm i @slimr/css
|
|
50
44
|
```
|
|
51
45
|
|
|
46
|
+
## addCss
|
|
47
|
+
|
|
48
|
+
Injects css to the page head
|
|
49
|
+
|
|
50
|
+
- Lazy: Will not be added until the component mounts, if called from within a component
|
|
51
|
+
- Batches dom changes for better performance
|
|
52
|
+
- Has local cache to recall prior adds, to reduce duplicates and dom changes
|
|
53
|
+
|
|
54
|
+
@param css - css to be injected
|
|
55
|
+
@returns void
|
|
56
|
+
|
|
57
|
+
## `css` (alias for `createClass`)
|
|
58
|
+
|
|
59
|
+
## `classJoin`
|
|
60
|
+
|
|
61
|
+
Joins class names and omits falsey props
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
classJoin('a', 'b', 'c') // 'a b c'
|
|
65
|
+
classJoin('a', 0, 'b', null, 'c') // 'a b c'
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Shorthang Props (`shorthandPropsMap` and `ShorthandProps`)
|
|
69
|
+
|
|
52
70
|
## Usage
|
|
53
71
|
|
|
54
72
|
```tsx
|
|
@@ -58,10 +76,6 @@ addCss`
|
|
|
58
76
|
color: lightgray;
|
|
59
77
|
}
|
|
60
78
|
`
|
|
61
|
-
|
|
62
|
-
export function App() {
|
|
63
|
-
const on = useOn()
|
|
64
|
-
|
|
65
79
|
return (
|
|
66
80
|
<div
|
|
67
81
|
className={css`
|
package/cjs/createClass.d.ts
CHANGED
|
@@ -1,95 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const breakPoints: string[];
|
|
3
|
-
type allowableAny = any;
|
|
4
|
-
/** Joins class names and filters out blanks */
|
|
5
|
-
export declare function classJoin(...classes: allowableAny[]): string;
|
|
6
|
-
export interface ShorthandProps {
|
|
7
|
-
/** shorthand for css:align-items */
|
|
8
|
-
ai?: string;
|
|
9
|
-
/** shorthand for css:border */
|
|
10
|
-
b?: string | number;
|
|
11
|
-
/** shorthand for css:border-radius */
|
|
12
|
-
br?: string | number;
|
|
13
|
-
/** shorthand for css:background */
|
|
14
|
-
bg?: string;
|
|
15
|
-
/** shorthand for css:color */
|
|
16
|
-
c?: string;
|
|
17
|
-
/** shorthand for css:display */
|
|
18
|
-
d?: string;
|
|
19
|
-
/** shorthand for css:flex */
|
|
20
|
-
f?: string;
|
|
21
|
-
/** shorthand for css:flex-direction */
|
|
22
|
-
fd?: string;
|
|
23
|
-
/** shorthand for css:height */
|
|
24
|
-
h?: number | string;
|
|
25
|
-
/** shorthand for css:inset */
|
|
26
|
-
i?: number | string;
|
|
27
|
-
/** shorthand for css:justify-content */
|
|
28
|
-
jc?: string;
|
|
29
|
-
/** shorthand for css:margin */
|
|
30
|
-
m?: number | string;
|
|
31
|
-
/** shorthand for css:margin-left */
|
|
32
|
-
ml?: number | string;
|
|
33
|
-
/** shorthand for css:margin-right */
|
|
34
|
-
mr?: number | string;
|
|
35
|
-
/** shorthand for css:margin-top */
|
|
36
|
-
mt?: number | string;
|
|
37
|
-
/** shorthand for css:margin-bottom */
|
|
38
|
-
mb?: number | string;
|
|
39
|
-
/** shorthand for css:margin-top & margin-bottom */
|
|
40
|
-
my?: number | string;
|
|
41
|
-
/** shorthand for css:margin-left & margin-right */
|
|
42
|
-
mx?: number | string;
|
|
43
|
-
/** shorthand for css:max-width */
|
|
44
|
-
maxW?: number | string;
|
|
45
|
-
/** shorthand for css:min-width */
|
|
46
|
-
minW?: number | string;
|
|
47
|
-
/** shorthand for css:padding */
|
|
48
|
-
p?: number | string;
|
|
49
|
-
/** shorthand for css:padding-left */
|
|
50
|
-
pl?: number | string;
|
|
51
|
-
/** shorthand for css:padding-right */
|
|
52
|
-
pr?: number | string;
|
|
53
|
-
/** shorthand for css:padding-top */
|
|
54
|
-
pt?: number | string;
|
|
55
|
-
/** shorthand for css:padding-bottom */
|
|
56
|
-
pb?: number | string;
|
|
57
|
-
/** shorthand for css:padding-top & padding-bottom */
|
|
58
|
-
py?: number | string;
|
|
59
|
-
/** shorthand for css:padding-left & padding-right */
|
|
60
|
-
px?: number | string;
|
|
61
|
-
/** shorthand for css:position */
|
|
62
|
-
pos?: number | string;
|
|
63
|
-
/** shorthand for css:text-align */
|
|
64
|
-
ta?: string;
|
|
65
|
-
/** shorthand for css:width */
|
|
66
|
-
w?: number | string;
|
|
67
|
-
/** shorthand for css:z-index */
|
|
68
|
-
z?: number | string;
|
|
69
|
-
}
|
|
70
|
-
export declare const shorthandPropsMap: Record<keyof Omit<ShorthandProps, 'mx' | 'my' | 'px' | 'py'>, string>;
|
|
71
|
-
export declare const shorthandProps: string[];
|
|
72
|
-
/**
|
|
73
|
-
* Assemble a string from a template string array and a list of placeholders.
|
|
74
|
-
*
|
|
75
|
-
* - If the first argument is a string, it is returned as is.
|
|
76
|
-
*
|
|
77
|
-
* i.e.
|
|
78
|
-
* myFoo(...props: TemplateStringProps) => {
|
|
79
|
-
* const inputStr = t2s(...props);
|
|
80
|
-
* }
|
|
81
|
-
* myFoo`hello ${name}` => 'hello world'
|
|
82
|
-
* myFoo(`hello ${name}`) => 'hello world'
|
|
83
|
-
*/
|
|
84
|
-
export declare function t2s(...tsp: TemplateStringProps): string;
|
|
85
|
-
export type TemplateStringProps = [
|
|
86
|
-
strings: TemplateStringsArray | string,
|
|
87
|
-
...placeHolders: string[]
|
|
88
|
-
];
|
|
1
|
+
import { T2SProps } from '@slimr/util';
|
|
89
2
|
/**
|
|
90
|
-
* Injects css to the page
|
|
3
|
+
* Injects css to the page head
|
|
91
4
|
*
|
|
92
|
-
* -
|
|
5
|
+
* - Lazy: Will not be added until the component mounts, if called from within a component
|
|
6
|
+
* - Batches dom changes for better performance
|
|
7
|
+
* - Has local cache to recall prior adds, to reduce duplicates and dom changes
|
|
93
8
|
*
|
|
94
9
|
* @param css - css to be injected
|
|
95
10
|
* @returns void
|
|
@@ -99,17 +14,30 @@ export declare namespace addCss {
|
|
|
99
14
|
var que: Set<string>;
|
|
100
15
|
var count: number;
|
|
101
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Joins class names and omits falsey props
|
|
19
|
+
*
|
|
20
|
+
* @param classes - class names to be joined
|
|
21
|
+
* @returns a string of joined class names
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* classJoin('a', 'b', 'c') // 'a b c'
|
|
26
|
+
* classJoin('a', 0, 'b', null, 'c') // 'a b c'
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function classJoin(...classes: (string | 0 | null | undefined)[]): string;
|
|
102
30
|
/**
|
|
103
31
|
* Injects css and creates unique class names
|
|
104
32
|
*
|
|
105
33
|
* - Skips if already added
|
|
106
34
|
*
|
|
107
|
-
* @param
|
|
35
|
+
* @param cssString - string or template string, to be injected
|
|
108
36
|
* @returns a unique class name
|
|
109
37
|
*/
|
|
110
|
-
export declare function createClass(...p:
|
|
38
|
+
export declare function createClass(...p: T2SProps): string;
|
|
111
39
|
export declare namespace createClass {
|
|
40
|
+
var breakPoints: string[];
|
|
112
41
|
var count: number;
|
|
113
42
|
var history: Map<string, string>;
|
|
114
43
|
}
|
|
115
|
-
export {};
|
package/cjs/createClass.js
CHANGED
|
@@ -1,13 +1,95 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createClass = exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
3
|
+
exports.createClass = exports.classJoin = exports.addCss = void 0;
|
|
4
|
+
const util_1 = require("@slimr/util");
|
|
5
|
+
const shorthandProps_js_1 = require("./shorthandProps.js");
|
|
6
|
+
/**
|
|
7
|
+
* Injects css to the page head
|
|
8
|
+
*
|
|
9
|
+
* - Lazy: Will not be added until the component mounts, if called from within a component
|
|
10
|
+
* - Batches dom changes for better performance
|
|
11
|
+
* - Has local cache to recall prior adds, to reduce duplicates and dom changes
|
|
12
|
+
*
|
|
13
|
+
* @param css - css to be injected
|
|
14
|
+
* @returns void
|
|
15
|
+
*/
|
|
16
|
+
function addCss(css) {
|
|
17
|
+
addCss.que.add(css);
|
|
18
|
+
setTimeout(() => {
|
|
19
|
+
const css = [...addCss.que].join('\n');
|
|
20
|
+
if (css) {
|
|
21
|
+
addCss.que.clear();
|
|
22
|
+
const s = document.createElement('style');
|
|
23
|
+
s.id = `u${addCss.count++}`;
|
|
24
|
+
s.innerHTML = css;
|
|
25
|
+
document.head.appendChild(s);
|
|
26
|
+
}
|
|
27
|
+
}, 0);
|
|
28
|
+
}
|
|
29
|
+
exports.addCss = addCss;
|
|
30
|
+
addCss.que = new Set();
|
|
31
|
+
addCss.count = 0;
|
|
32
|
+
/**
|
|
33
|
+
* Joins class names and omits falsey props
|
|
34
|
+
*
|
|
35
|
+
* @param classes - class names to be joined
|
|
36
|
+
* @returns a string of joined class names
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* classJoin('a', 'b', 'c') // 'a b c'
|
|
41
|
+
* classJoin('a', 0, 'b', null, 'c') // 'a b c'
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
7
44
|
function classJoin(...classes) {
|
|
8
45
|
return classes.filter(c => c && typeof c === 'string').join(' ');
|
|
9
46
|
}
|
|
10
47
|
exports.classJoin = classJoin;
|
|
48
|
+
/**
|
|
49
|
+
* Injects css and creates unique class names
|
|
50
|
+
*
|
|
51
|
+
* - Skips if already added
|
|
52
|
+
*
|
|
53
|
+
* @param cssString - string or template string, to be injected
|
|
54
|
+
* @returns a unique class name
|
|
55
|
+
*/
|
|
56
|
+
function createClass(...p) {
|
|
57
|
+
let css = (0, util_1.t2s)(...p);
|
|
58
|
+
if (!css)
|
|
59
|
+
return '';
|
|
60
|
+
let className = createClass.history.get(css);
|
|
61
|
+
if (!className) {
|
|
62
|
+
className = 's' + createClass.count++;
|
|
63
|
+
createClass.history.set(css, className);
|
|
64
|
+
css = deleteComments(css);
|
|
65
|
+
css = (0, shorthandProps_js_1.expandShorthands)(css);
|
|
66
|
+
css = expandArrayValues(css);
|
|
67
|
+
const qs = findQueries(css);
|
|
68
|
+
for (const q of qs.reverse()) {
|
|
69
|
+
css = css.slice(0, q.start) + css.slice(q.end);
|
|
70
|
+
}
|
|
71
|
+
css = `.${className}{\n${css}\n}\n`;
|
|
72
|
+
css += qs
|
|
73
|
+
.map(q => {
|
|
74
|
+
if (q.query.startsWith('&')) {
|
|
75
|
+
return `.${className}${q.query.slice(1)}{\n${q.innerBody}\n}`;
|
|
76
|
+
}
|
|
77
|
+
if (q.query.startsWith('@keyframes')) {
|
|
78
|
+
return q.outerBody;
|
|
79
|
+
}
|
|
80
|
+
return `${q.query}{\n.${className}{${q.innerBody}\n}\n}`;
|
|
81
|
+
})
|
|
82
|
+
.join('\n');
|
|
83
|
+
css = trimByLine(css) + '\n\n';
|
|
84
|
+
addCss(css);
|
|
85
|
+
}
|
|
86
|
+
return className;
|
|
87
|
+
}
|
|
88
|
+
exports.createClass = createClass;
|
|
89
|
+
/** Breakpoints like chakra */
|
|
90
|
+
createClass.breakPoints = ['30em', '48em', '62em', '80em', '96em'];
|
|
91
|
+
createClass.count = 0;
|
|
92
|
+
createClass.history = new Map();
|
|
11
93
|
/** delete css comments **/
|
|
12
94
|
function deleteComments(css) {
|
|
13
95
|
return css.replace(/{\/\*[\s\S]*?(?=\*\/})\*\/}/gm, '');
|
|
@@ -35,7 +117,7 @@ function expandArrayValues(css) {
|
|
|
35
117
|
if (i === 0) {
|
|
36
118
|
return `${prop}: ${val};`;
|
|
37
119
|
}
|
|
38
|
-
return `@media (min-width: ${
|
|
120
|
+
return `@media (min-width: ${createClass.breakPoints[i - 1]}) { ${prop}: ${val}; }`;
|
|
39
121
|
})
|
|
40
122
|
.join('\n');
|
|
41
123
|
}
|
|
@@ -43,48 +125,6 @@ function expandArrayValues(css) {
|
|
|
43
125
|
})
|
|
44
126
|
.join('\n');
|
|
45
127
|
}
|
|
46
|
-
exports.shorthandPropsMap = {
|
|
47
|
-
ai: 'align-items',
|
|
48
|
-
b: 'border',
|
|
49
|
-
br: 'border-radius',
|
|
50
|
-
bg: 'background',
|
|
51
|
-
c: 'color',
|
|
52
|
-
d: 'display',
|
|
53
|
-
f: 'flex',
|
|
54
|
-
fd: 'flex-direction',
|
|
55
|
-
i: 'inset',
|
|
56
|
-
h: 'height',
|
|
57
|
-
jc: 'justify-content',
|
|
58
|
-
m: 'margin',
|
|
59
|
-
ml: 'margin-left',
|
|
60
|
-
mr: 'margin-right',
|
|
61
|
-
mt: 'margin-top',
|
|
62
|
-
mb: 'margin-bottom',
|
|
63
|
-
maxW: 'max-width',
|
|
64
|
-
minW: 'min-width',
|
|
65
|
-
p: 'padding',
|
|
66
|
-
pl: 'padding-left',
|
|
67
|
-
pr: 'padding-right',
|
|
68
|
-
pt: 'padding-top',
|
|
69
|
-
pb: 'padding-bottom',
|
|
70
|
-
pos: 'position',
|
|
71
|
-
ta: 'text-align',
|
|
72
|
-
w: 'width',
|
|
73
|
-
z: 'z-index',
|
|
74
|
-
};
|
|
75
|
-
exports.shorthandProps = [...Object.keys(exports.shorthandPropsMap), 'mx', 'my', 'px', 'py'];
|
|
76
|
-
/** Expand short-hand css props to full */
|
|
77
|
-
function expandProps(css) {
|
|
78
|
-
css = '\n' + css; // inject a newline to make the regex easier
|
|
79
|
-
// Handle 'mx', 'my', 'px', 'py'
|
|
80
|
-
css = css
|
|
81
|
-
.replace(/([mp])x:([^;]*)/g, '$1l:$2;\n$1r:$2')
|
|
82
|
-
.replace(/([mp])y:([^;]*);/g, '$1t:$2;\n$1b:$2');
|
|
83
|
-
Object.entries(exports.shorthandPropsMap).forEach(([k, v]) => {
|
|
84
|
-
css = css.replace(new RegExp(`([ \n\t;])${k}:`, 'g'), `$1${v}:`);
|
|
85
|
-
});
|
|
86
|
-
return css.trim();
|
|
87
|
-
}
|
|
88
128
|
/** Find @keyframes, @media, @container queries in css **/
|
|
89
129
|
function findQueries(css) {
|
|
90
130
|
const queries = [];
|
|
@@ -120,95 +160,11 @@ function findQueries(css) {
|
|
|
120
160
|
return queries;
|
|
121
161
|
}
|
|
122
162
|
/** Trims whitespace for every line */
|
|
123
|
-
function
|
|
163
|
+
function trimByLine(css) {
|
|
124
164
|
return css
|
|
125
165
|
.split('\n')
|
|
126
166
|
.map(l => l.trim())
|
|
127
167
|
.filter(l => l)
|
|
128
168
|
.join('\n');
|
|
129
169
|
}
|
|
130
|
-
/**
|
|
131
|
-
* Assemble a string from a template string array and a list of placeholders.
|
|
132
|
-
*
|
|
133
|
-
* - If the first argument is a string, it is returned as is.
|
|
134
|
-
*
|
|
135
|
-
* i.e.
|
|
136
|
-
* myFoo(...props: TemplateStringProps) => {
|
|
137
|
-
* const inputStr = t2s(...props);
|
|
138
|
-
* }
|
|
139
|
-
* myFoo`hello ${name}` => 'hello world'
|
|
140
|
-
* myFoo(`hello ${name}`) => 'hello world'
|
|
141
|
-
*/
|
|
142
|
-
function t2s(...tsp) {
|
|
143
|
-
const [s, ...p] = tsp;
|
|
144
|
-
return typeof s === 'string' ? s : s.map((s, i) => s + (p?.[i] ?? '')).join('');
|
|
145
|
-
}
|
|
146
|
-
exports.t2s = t2s;
|
|
147
|
-
/**
|
|
148
|
-
* Injects css to the page
|
|
149
|
-
*
|
|
150
|
-
* - Batches adds for performance
|
|
151
|
-
*
|
|
152
|
-
* @param css - css to be injected
|
|
153
|
-
* @returns void
|
|
154
|
-
*/
|
|
155
|
-
function addCss(css) {
|
|
156
|
-
addCss.que.add(css);
|
|
157
|
-
setTimeout(() => {
|
|
158
|
-
const css = [...addCss.que].join('\n');
|
|
159
|
-
if (css) {
|
|
160
|
-
addCss.que.clear();
|
|
161
|
-
const s = document.createElement('style');
|
|
162
|
-
s.id = `u${addCss.count++}`;
|
|
163
|
-
s.innerHTML = css;
|
|
164
|
-
document.head.appendChild(s);
|
|
165
|
-
}
|
|
166
|
-
}, 0);
|
|
167
|
-
}
|
|
168
|
-
exports.addCss = addCss;
|
|
169
|
-
addCss.que = new Set();
|
|
170
|
-
addCss.count = 0;
|
|
171
|
-
/**
|
|
172
|
-
* Injects css and creates unique class names
|
|
173
|
-
*
|
|
174
|
-
* - Skips if already added
|
|
175
|
-
*
|
|
176
|
-
* @param css - string or template string, to be injected
|
|
177
|
-
* @returns a unique class name
|
|
178
|
-
*/
|
|
179
|
-
function createClass(...p) {
|
|
180
|
-
let css = t2s(...p);
|
|
181
|
-
if (!css)
|
|
182
|
-
return '';
|
|
183
|
-
let className = createClass.history.get(css);
|
|
184
|
-
if (!className) {
|
|
185
|
-
className = 's' + createClass.count++;
|
|
186
|
-
createClass.history.set(css, className);
|
|
187
|
-
css = deleteComments(css);
|
|
188
|
-
css = expandProps(css);
|
|
189
|
-
css = expandArrayValues(css);
|
|
190
|
-
const qs = findQueries(css);
|
|
191
|
-
for (const q of qs.reverse()) {
|
|
192
|
-
css = css.slice(0, q.start) + css.slice(q.end);
|
|
193
|
-
}
|
|
194
|
-
css = `.${className}{\n${css}\n}\n`;
|
|
195
|
-
css += qs
|
|
196
|
-
.map(q => {
|
|
197
|
-
if (q.query.startsWith('&')) {
|
|
198
|
-
return `.${className}${q.query.slice(1)}{\n${q.innerBody}\n}`;
|
|
199
|
-
}
|
|
200
|
-
if (q.query.startsWith('@keyframes')) {
|
|
201
|
-
return q.outerBody;
|
|
202
|
-
}
|
|
203
|
-
return `${q.query}{\n.${className}{${q.innerBody}\n}\n}`;
|
|
204
|
-
})
|
|
205
|
-
.join('\n');
|
|
206
|
-
css = trim(css) + '\n\n';
|
|
207
|
-
addCss(css);
|
|
208
|
-
}
|
|
209
|
-
return className;
|
|
210
|
-
}
|
|
211
|
-
exports.createClass = createClass;
|
|
212
|
-
createClass.count = 0;
|
|
213
|
-
createClass.history = new Map();
|
|
214
170
|
//# sourceMappingURL=createClass.js.map
|
package/cjs/createClass.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClass.js","sourceRoot":"","sources":["../src/createClass.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"createClass.js","sourceRoot":"","sources":["../src/createClass.ts"],"names":[],"mappings":";;;AAAA,sCAAyC;AAEzC,2DAAoD;AAEpD;;;;;;;;;GASG;AACH,SAAgB,MAAM,CAAC,GAAW;IAChC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACnB,UAAU,CAAC,GAAG,EAAE;QACd,MAAM,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACtC,IAAI,GAAG,EAAE;YACP,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,CAAA;YAClB,MAAM,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;YACzC,CAAC,CAAC,EAAE,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,EAAE,CAAA;YAC3B,CAAC,CAAC,SAAS,GAAG,GAAG,CAAA;YACjB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAA;SAC7B;IACH,CAAC,EAAE,CAAC,CAAC,CAAA;AACP,CAAC;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