aleman 1.1.21 → 1.1.22
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/menu/rules/menu/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {operator
|
|
1
|
+
import {operator} from 'putout';
|
|
2
2
|
import {checkDataName} from '../check-data-name.js';
|
|
3
3
|
|
|
4
|
-
const {isJSXElement} = types;
|
|
5
|
-
|
|
6
4
|
const {setLiteralValue} = operator;
|
|
7
5
|
|
|
8
6
|
export const report = ({command}) => {
|
|
@@ -51,4 +49,3 @@ export const traverse = ({push, options}) => ({
|
|
|
51
49
|
}
|
|
52
50
|
},
|
|
53
51
|
});
|
|
54
|
-
|
|
@@ -11,8 +11,8 @@ const {setLiteralValue} = operator;
|
|
|
11
11
|
|
|
12
12
|
export const report = () => `Set position`;
|
|
13
13
|
|
|
14
|
-
export const fix = ({path, attr,
|
|
15
|
-
const style = `left: ${
|
|
14
|
+
export const fix = ({path, attr, x, y}) => {
|
|
15
|
+
const style = `left: ${x}px; top: ${y}px;`;
|
|
16
16
|
|
|
17
17
|
if (attr) {
|
|
18
18
|
setLiteralValue(attr.value, style);
|
|
@@ -30,7 +30,7 @@ export const fix = ({path, attr, left, top}) => {
|
|
|
30
30
|
export const traverse = ({options, push}) => ({
|
|
31
31
|
JSXOpeningElement(path) {
|
|
32
32
|
const {name = 'menu', position = {}} = options;
|
|
33
|
-
const {
|
|
33
|
+
const {x = 0, y = 20} = position;
|
|
34
34
|
|
|
35
35
|
if (!checkDataName(path.parentPath, name))
|
|
36
36
|
return;
|
|
@@ -39,24 +39,24 @@ export const traverse = ({options, push}) => ({
|
|
|
39
39
|
if (attr.name.name !== 'style')
|
|
40
40
|
continue;
|
|
41
41
|
|
|
42
|
-
const [
|
|
42
|
+
const [x1, y1] = parsePosition(attr.value.value);
|
|
43
43
|
|
|
44
|
-
if (x ===
|
|
44
|
+
if (x === x1 && y === y1)
|
|
45
45
|
return;
|
|
46
46
|
|
|
47
47
|
push({
|
|
48
48
|
path,
|
|
49
49
|
attr,
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
x,
|
|
51
|
+
y,
|
|
52
52
|
});
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
push({
|
|
57
57
|
path,
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
x,
|
|
59
|
+
y,
|
|
60
60
|
});
|
|
61
61
|
},
|
|
62
62
|
});
|
package/menu/state.js
CHANGED