export-svg-typescript 0.1.5 → 0.1.6

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/demo/index.ts CHANGED
@@ -1,9 +1,7 @@
1
- // Do a Barrel Roll index of SVG icons as JS exports, enabling tree shaking to only the icons you import.
2
-
1
+ // Do a Barrel Roll (auto-generated) index of SVG icons as JS exports, tree shaking to only the icons used.
3
2
 
4
3
  /**
5
- * Returns a customized SVG string for loading icon bouncy-ball
6
- *
4
+ * Returns a customized SVG string for icon loading-bouncy-ball
7
5
  * ![loading-bouncy-ball](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCIgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiIHN0eWxlPSJzaGFwZS1yZW5kZXJpbmc6IGF1dG87IGRpc3BsYXk6IGJsb2NrOyAiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj48Zz48Y2lyY2xlIGZpbGw9IiNlMTViNjQiIHI9IjEzIiBjeT0iMjMiIGN4PSI1MCI+CiAgPGFuaW1hdGUgdmFsdWVzPSIyMzs3NzsyMyIga2V5VGltZXM9IjA7MC41OzEiIGtleVNwbGluZXM9IjAuNDUgMCAwLjkgMC41NTswIDAuNDUgMC41NSAwLjkiIGNhbGNNb2RlPSJzcGxpbmUiIHJlcGVhdENvdW50PSJpbmRlZmluaXRlIiBkdXI9IjFzIiBhdHRyaWJ1dGVOYW1lPSJjeSI+PC9hbmltYXRlPgo8L2NpcmNsZT48Zz48L2c+PC9nPjwvc3ZnPg==)
8
6
  * @param {Object} options - Configuration options
9
7
  * @param {string[]} [options.colors] - Array of hex colors to replace existing colors
@@ -16,10 +14,8 @@
16
14
  export const loadingBouncyBall = (options: LoadingOptions = {}) => customSVG(options,
17
15
  `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid" width="200" height="200" style="shape-rendering: auto; display: block; "><g><circle fill="#e15b64" r="13" cy="23" cx="50"><animate values="23;77;23" keyTimes="0;0.5;1" keySplines="0.45 0 0.9 0.55;0 0.45 0.55 0.9" calcMode="spline" repeatCount="indefinite" dur="1s" attributeName="cy"></animate></circle><g></g></g></svg>`);
18
16
 
19
-
20
17
  /**
21
- * Returns a customized SVG string for loading icon double-ring
22
- *
18
+ * Returns a customized SVG string for icon loading-double-ring
23
19
  * ![loading-double-ring](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCIgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiIHN0eWxlPSJzaGFwZS1yZW5kZXJpbmc6IGF1dG87IGRpc3BsYXk6IGJsb2NrOyAiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj48Zz48Y2lyY2xlIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgZmlsbD0ibm9uZSIgc3Ryb2tlLWRhc2hhcnJheT0iNTAuMjY1NDgyNDU3NDM2NjkgNTAuMjY1NDgyNDU3NDM2NjkiIHN0cm9rZT0iIzAwOTllNSIgc3Ryb2tlLXdpZHRoPSI4IiByPSIzMiIgY3k9IjUwIiBjeD0iNTAiPgogIDxhbmltYXRlVHJhbnNmb3JtIHZhbHVlcz0iMCA1MCA1MDszNjAgNTAgNTAiIGtleVRpbWVzPSIwOzEiIHJlcGVhdENvdW50PSJpbmRlZmluaXRlIiBkdXI9IjFzIiB0eXBlPSJyb3RhdGUiIGF0dHJpYnV0ZU5hbWU9InRyYW5zZm9ybSI+PC9hbmltYXRlVHJhbnNmb3JtPgo8L2NpcmNsZT4KPGNpcmNsZSBzdHJva2UtbGluZWNhcD0icm91bmQiIGZpbGw9Im5vbmUiIHN0cm9rZS1kYXNob2Zmc2V0PSIzNi4xMjgzMTU1MTYyODI2MiIgc3Ryb2tlLWRhc2hhcnJheT0iMzYuMTI4MzE1NTE2MjgyNjIgMzYuMTI4MzE1NTE2MjgyNjIiIHN0cm9rZT0iI2ZmNGM0YyIgc3Ryb2tlLXdpZHRoPSI4IiByPSIyMyIgY3k9IjUwIiBjeD0iNTAiPgogIDxhbmltYXRlVHJhbnNmb3JtIHZhbHVlcz0iMCA1MCA1MDstMzYwIDUwIDUwIiBrZXlUaW1lcz0iMDsxIiByZXBlYXRDb3VudD0iaW5kZWZpbml0ZSIgZHVyPSIxcyIgdHlwZT0icm90YXRlIiBhdHRyaWJ1dGVOYW1lPSJ0cmFuc2Zvcm0iPjwvYW5pbWF0ZVRyYW5zZm9ybT4KPC9jaXJjbGU+PGc+PC9nPjwvZz48L3N2Zz4=)
24
20
  * @param {Object} options - Configuration options
25
21
  * @param {string[]} [options.colors] - Array of hex colors to replace existing colors
@@ -32,10 +28,8 @@ export const loadingBouncyBall = (options: LoadingOptions = {}) => customSVG(op
32
28
  export const loadingDoubleRing = (options: LoadingOptions = {}) => customSVG(options,
33
29
  `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid" width="200" height="200" style="shape-rendering: auto; display: block; "><g><circle stroke-linecap="round" fill="none" stroke-dasharray="50.26548245743669 50.26548245743669" stroke="#0099e5" stroke-width="8" r="32" cy="50" cx="50"><animateTransform values="0 50 50;360 50 50" keyTimes="0;1" repeatCount="indefinite" dur="1s" type="rotate" attributeName="transform"></animateTransform></circle><circle stroke-linecap="round" fill="none" stroke-dashoffset="36.12831551628262" stroke-dasharray="36.12831551628262 36.12831551628262" stroke="#ff4c4c" stroke-width="8" r="23" cy="50" cx="50"><animateTransform values="0 50 50;-360 50 50" keyTimes="0;1" repeatCount="indefinite" dur="1s" type="rotate" attributeName="transform"></animateTransform></circle><g></g></g></svg>`);
34
30
 
35
-
36
31
  /**
37
- * Returns a customized SVG string for loading icon eclipse
38
- *
32
+ * Returns a customized SVG string for icon loading-eclipse
39
33
  * ![loading-eclipse](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCIgd2lkdGg9IjIwMCIgaGVpZ2h0PSIyMDAiIHN0eWxlPSJzaGFwZS1yZW5kZXJpbmc6IGF1dG87IGRpc3BsYXk6IGJsb2NrOyI+PGc+PHBhdGggc3Ryb2tlPSJub25lIiBmaWxsPSIjZmZiOTAwIiBkPSJNMTAgNTBBNDAgNDAgMCAwIDAgOTAgNTBBNDAgNDIgMCAwIDEgMTAgNTAiPgogIDxhbmltYXRlVHJhbnNmb3JtIHZhbHVlcz0iMCA1MCA1MTszNjAgNTAgNTEiIGtleVRpbWVzPSIwOzEiIHJlcGVhdENvdW50PSJpbmRlZmluaXRlIiBkdXI9IjFzIiB0eXBlPSJyb3RhdGUiIGF0dHJpYnV0ZU5hbWU9InRyYW5zZm9ybSI+PC9hbmltYXRlVHJhbnNmb3JtPgo8L3BhdGg+PGc+PC9nPjwvZz48L3N2Zz4=)
40
34
  * @param {Object} options - Configuration options
41
35
  * @param {string[]} [options.colors] - Array of hex colors to replace existing colors
@@ -85,7 +79,7 @@ function customSVG( options: LoadingOptions, svgString: string) {
85
79
  });
86
80
  }
87
81
  if (!raw)
88
- svgString = `<img alt="loading-icon" src="data:image/svg+xml;utf8,${encodeURIComponent(svgString)}" />`
82
+ svgString = `<img alt="icon" src="data:image/svg+xml;utf8,${encodeURIComponent(svgString)}" />`
89
83
 
90
84
  return svgString;
91
85
  }
@@ -7,7 +7,6 @@ import path from "path";
7
7
  * Script to process SVG files from input folder and generates JS export index,
8
8
  * Barrel Roll for the icons js files, enabling tree shaking to only the icons the
9
9
  * user imports, enables customizing colors and size, and shows tooltip preview.
10
- * usage: node convert-svg-to-js.js -i ./src/icons-svg -o ./dist/icons
11
10
  * @param {string} inputFolder - Path to folder containing SVG files
12
11
  * @param {string} outputFolder - Path to folder where JS files will be generated
13
12
  */
@@ -41,10 +40,8 @@ export function convertSVGFolderToExportIndex(inputFolder, indexPath) {
41
40
  unescape(encodeURIComponent(svgContent))
42
41
  )}`;
43
42
 
44
- const jsContent = `
45
- /**
46
- * Returns a customized SVG string for loading icon ${baseName.replace(/loading-/g, "" )}
47
- *
43
+ const jsContent = `/**
44
+ * Returns a customized SVG string for icon ${baseName.replace(/icon-/g, "" )}
48
45
  * ![${baseName}](${svgBase64})
49
46
  * @param {Object} options - Configuration options
50
47
  * @param {string[]} [options.colors] - Array of hex colors to replace existing colors
@@ -117,7 +114,7 @@ function customSVG( options: LoadingOptions, svgString: string) {
117
114
  });
118
115
  }
119
116
  if (!raw)
120
- svgString = \`<img alt="loading-icon" src="data:image/svg+xml;utf8,\${encodeURIComponent(svgString)}" />\`
117
+ svgString = \`<img alt="icon" src="data:image/svg+xml;utf8,\${encodeURIComponent(svgString)}" />\`
121
118
 
122
119
  return svgString;
123
120
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "module": "export-svg-typescript.js",
4
4
  "author": "vtempest",
5
5
  "license": "MIT",
6
- "version": "0.1.5",
6
+ "version": "0.1.6",
7
7
  "description": "Export SVG to TypeScript",
8
8
  "type": "module",
9
9
  "scripts": {
package/readme.md CHANGED
@@ -11,13 +11,14 @@ Convert a folder of SVG icons into a color-customizable, tree-shakable TypeScrip
11
11
  Global install:
12
12
  ```
13
13
  npm install -g export-svg-typescript
14
+ ```
14
15
  Or add to package.json:
15
16
  ```
16
17
  "icons": "npx export-svg-typescript -i ./src/icons",
17
18
  ```
18
19
  Or use npx without installing globally with index output file set
19
20
  ```
20
- "icons": "npx export-svg-typescript ./src/icons",
21
+ npx export-svg-typescript -i ./src/icons -o ./src/icons/index.ts
21
22
  ```
22
23
 
23
24
  ### Example
@@ -26,7 +27,7 @@ Clone this repo and run `npm run demo` to see icons in demo folder.
26
27
 
27
28
  ```javascript
28
29
  import { loadingDoubleRing } from './demo';
29
-
30
+
30
31
  loadingDoubleRing({size: 200, colors: ["#5345bb"] })
31
32
  ```
32
33
  ![screenshot](https://i.imgur.com/aXczCC2.png)