@alexgyver/component 1.2.10 → 1.3.0

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.
Files changed (3) hide show
  1. package/Component.js +13 -0
  2. package/README.md +13 -1
  3. package/package.json +1 -1
package/Component.js CHANGED
@@ -223,6 +223,19 @@ export class StyledComponent extends Component {
223
223
  }
224
224
  }
225
225
 
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 });
237
+ }
238
+
226
239
  export async function waitRender(elm, cb = null, ctx = window) {
227
240
  return new Promise(res => {
228
241
  let e = elm;
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
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexgyver/component",
3
- "version": "1.2.10",
3
+ "version": "1.3.0",
4
4
  "description": "Simple HTML element builder",
5
5
  "main": "./Component.js",
6
6
  "module": "./Component.js",