@alexgyver/component 1.2.10 → 1.3.1
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/Component.js +11 -17
- package/README.md +13 -1
- package/package.json +1 -1
package/Component.js
CHANGED
|
@@ -223,21 +223,15 @@ export class StyledComponent extends Component {
|
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
export
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
obs.disconnect();
|
|
238
|
-
if (cb) cb(elm);
|
|
239
|
-
res(elm);
|
|
240
|
-
});
|
|
241
|
-
obs.observe(ctx.document.body, { childList: true, subtree: true });
|
|
242
|
-
});
|
|
226
|
+
export class SVG {
|
|
227
|
+
static svg = (attrs = {}, props = {}) => SVG._make('svg', attrs, props);
|
|
228
|
+
static rect = (x, y, w, h, rx, ry, attrs = {}, props = {}) => SVG._make('rect', { ...attrs, x: x, y: y, width: w, height: h, rx: rx, ry: ry }, props);
|
|
229
|
+
static circle = (x, y, r, attrs = {}, props = {}) => SVG._make('circle', { ...attrs, cx: x, cy: y, r: r }, props);
|
|
230
|
+
static line = (x1, y1, x2, y2, attrs = {}, props = {}) => SVG._make('line', { ...attrs, x1: x1, y1: y1, x2: x2, y2: y2 }, props);
|
|
231
|
+
static polyline = (points, attrs = {}, props = {}) => SVG._make('polyline', { ...attrs, points: points }, props);
|
|
232
|
+
static polygon = (points, attrs = {}, props = {}) => SVG._make('polygon', { ...attrs, points: points }, props);
|
|
233
|
+
static path = (d, attrs = {}, props = {}) => SVG._make('path', { ...attrs, d: d }, props);
|
|
234
|
+
static text = (text, x, y, attrs = {}, props = {}) => SVG._make('text', { ...attrs, x: x, y: y }, { ...props, text: text });
|
|
235
|
+
|
|
236
|
+
static _make = (tag, attrs = {}, props = {}) => Component.makeSVG(tag, { attrs: { ...attrs }, ...props });
|
|
243
237
|
}
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Component.js
|
|
2
|
-
Библиотека для создания и настройки DOM элементов как JS объектов
|
|
2
|
+
Библиотека для создания и настройки DOM/SVG элементов как JS объектов
|
|
3
3
|
|
|
4
4
|
> npm i @alexgyver/component
|
|
5
5
|
|
|
@@ -66,6 +66,18 @@ Component.makeArray(arr);
|
|
|
66
66
|
Component.makeArraySVG(arr);
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
+
### SVG
|
|
70
|
+
```js
|
|
71
|
+
SVG.svg(attrs = {}, props = {});
|
|
72
|
+
SVG.rect(x, y, w, h, rx, ry, attrs = {}, props = {});
|
|
73
|
+
SVG.circle(x, y, r, attrs = {}, props = {});
|
|
74
|
+
SVG.line(x1, y1, x2, y2, attrs = {}, props = {});
|
|
75
|
+
SVG.polyline(points, attrs = {}, props = {});
|
|
76
|
+
SVG.polygon(points, attrs = {}, props = {});
|
|
77
|
+
SVG.path(d, attrs = {}, props = {});
|
|
78
|
+
SVG.text(text, x, y, attrs = {}, props = {});
|
|
79
|
+
```
|
|
80
|
+
|
|
69
81
|
### Sheet
|
|
70
82
|
```js
|
|
71
83
|
/**
|