@viewfly/scoped-css 0.0.1-alpha.7 → 0.0.1-alpha.9
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/bundles/index.esm.js +16 -5
- package/bundles/index.js +16 -5
- package/package.json +3 -3
- package/src/css-modules.ts +15 -5
package/bundles/index.esm.js
CHANGED
|
@@ -2,16 +2,27 @@ import { JSXElement, Props } from '@viewfly/core';
|
|
|
2
2
|
|
|
3
3
|
function replaceCSSClass(template, css) {
|
|
4
4
|
if (template instanceof JSXElement) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
let { attrs, classes, children } = template.props;
|
|
6
|
+
const cssNames = attrs.get('css');
|
|
7
|
+
attrs.delete('css');
|
|
8
|
+
const scopedClasses = [];
|
|
8
9
|
Props.classToArray(cssNames).forEach(i => {
|
|
9
10
|
const klass = css[i];
|
|
10
11
|
if (klass) {
|
|
11
|
-
|
|
12
|
+
scopedClasses.push(klass);
|
|
12
13
|
}
|
|
13
14
|
});
|
|
14
|
-
|
|
15
|
+
const c = scopedClasses.join(' ');
|
|
16
|
+
if (c) {
|
|
17
|
+
if (classes) {
|
|
18
|
+
classes += ' ' + c;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
classes = c;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
template.props.classes = classes;
|
|
25
|
+
children.forEach(child => {
|
|
15
26
|
replaceCSSClass(child, css);
|
|
16
27
|
});
|
|
17
28
|
}
|
package/bundles/index.js
CHANGED
|
@@ -4,16 +4,27 @@ var core = require('@viewfly/core');
|
|
|
4
4
|
|
|
5
5
|
function replaceCSSClass(template, css) {
|
|
6
6
|
if (template instanceof core.JSXElement) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
let { attrs, classes, children } = template.props;
|
|
8
|
+
const cssNames = attrs.get('css');
|
|
9
|
+
attrs.delete('css');
|
|
10
|
+
const scopedClasses = [];
|
|
10
11
|
core.Props.classToArray(cssNames).forEach(i => {
|
|
11
12
|
const klass = css[i];
|
|
12
13
|
if (klass) {
|
|
13
|
-
|
|
14
|
+
scopedClasses.push(klass);
|
|
14
15
|
}
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
+
const c = scopedClasses.join(' ');
|
|
18
|
+
if (c) {
|
|
19
|
+
if (classes) {
|
|
20
|
+
classes += ' ' + c;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
classes = c;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
template.props.classes = classes;
|
|
27
|
+
children.forEach(child => {
|
|
17
28
|
replaceCSSClass(child, css);
|
|
18
29
|
});
|
|
19
30
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viewfly/scoped-css",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.9",
|
|
4
4
|
"description": "Viewfly is a simple and easy-to-use JavaScript framework with an intuitive development experience",
|
|
5
5
|
"main": "./bundles/index.js",
|
|
6
6
|
"module": "./bundles/index.esm.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"keywords": [],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@viewfly/core": "^0.0.1-alpha.
|
|
18
|
+
"@viewfly/core": "^0.0.1-alpha.9"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@rollup/plugin-commonjs": "^23.0.2",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"bugs": {
|
|
36
36
|
"url": "https://github.com/viewfly/viewfly.git/issues"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "c1ea5cf0163aac7b73beee2868f4ea5caa94bb3f"
|
|
39
39
|
}
|
package/src/css-modules.ts
CHANGED
|
@@ -2,16 +2,26 @@ import { JSXElement, ComponentSetup, Props } from '@viewfly/core'
|
|
|
2
2
|
|
|
3
3
|
function replaceCSSClass(template, css: Record<string, string>) {
|
|
4
4
|
if (template instanceof JSXElement) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
let { attrs, classes, children } = template.props
|
|
6
|
+
const cssNames = attrs.get('css')
|
|
7
|
+
attrs.delete('css')
|
|
8
|
+
const scopedClasses: string[] = []
|
|
8
9
|
Props.classToArray(cssNames).forEach(i => {
|
|
9
10
|
const klass = css[i]
|
|
10
11
|
if (klass) {
|
|
11
|
-
|
|
12
|
+
scopedClasses.push(klass)
|
|
12
13
|
}
|
|
13
14
|
})
|
|
14
|
-
|
|
15
|
+
const c = scopedClasses.join(' ')
|
|
16
|
+
if (c) {
|
|
17
|
+
if (classes) {
|
|
18
|
+
classes += ' ' + c
|
|
19
|
+
} else {
|
|
20
|
+
classes = c
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
template.props.classes = classes
|
|
24
|
+
children.forEach(child => {
|
|
15
25
|
replaceCSSClass(child, css)
|
|
16
26
|
})
|
|
17
27
|
}
|