svg-dynamic-icon 1.0.1 → 1.0.3

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/README.md +15 -3
  2. package/dist/index.js +1 -101
  3. package/package.json +3 -2
package/README.md CHANGED
@@ -3,12 +3,16 @@
3
3
  - A lightweight React component for rendering **custom-made SVG icons** with **TailwindCSS** support.
4
4
  - Perfect for projects with a custom icon set, and you want dynamic usage without hardcoding imports.
5
5
 
6
+ #
7
+
6
8
  ## 📦 Installation
7
9
 
8
10
  ```bash
9
11
  npm install svg-dynamic-icon
10
12
  ```
11
13
 
14
+ #
15
+
12
16
  ## 🚀 Usage
13
17
 
14
18
  ```bash
@@ -18,19 +22,23 @@ function Example() {
18
22
  return (
19
23
  <DynamicIcon
20
24
  iconName="Checkmark" // refers to: assets/icons/Checkmark.svg
21
- size=32 // icon will be 32px by 32px
25
+ size={32} // icon will be 32px by 32px
22
26
  color="text-blue-500" // tailwind class for icon color
23
27
  />
24
28
  );
25
29
  }
26
30
  ```
27
31
 
32
+ #
33
+
28
34
  ## 📁 Icon Setup
29
35
 
30
36
  - Place your SVG icons in the /assets/icons/ folder.
31
37
  - File names must match the iconName prop exactly (MyIcon.svg → iconName="MyIcon").
32
38
  - Upload square-shaped icons for best rendering (e.g., 24x24 or 64x64).
33
39
 
40
+ #
41
+
34
42
  ## ⚙️ Props
35
43
 
36
44
  | **Prop** | **Type** | **Required** | **Description** |
@@ -39,12 +47,16 @@ function Example() {
39
47
  | size | number | no | Icon size in pixels (width & height). Default: 25 |
40
48
  | color | string | no | TailwindCSS text color class (e.g., text-white, text-gray-500) |
41
49
 
50
+ #
51
+
42
52
  ## 🧩 Built With
43
53
 
44
54
  - React
45
55
  - react-svg
46
- - tailwind-merge
56
+ - tailwindcss
57
+
58
+ #
47
59
 
48
- 📝 License
60
+ ## 📝 License
49
61
 
50
62
  MIT
package/dist/index.js CHANGED
@@ -1,101 +1 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __glob = (map) => (path) => {
9
- var fn = map[path];
10
- if (fn) return fn();
11
- throw new Error("Module not found in bundle: " + path);
12
- };
13
- var __commonJS = (cb, mod) => function __require() {
14
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
- };
16
- var __export = (target, all) => {
17
- for (var name in all)
18
- __defProp(target, name, { get: all[name], enumerable: true });
19
- };
20
- var __copyProps = (to, from, except, desc) => {
21
- if (from && typeof from === "object" || typeof from === "function") {
22
- for (let key of __getOwnPropNames(from))
23
- if (!__hasOwnProp.call(to, key) && key !== except)
24
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
- }
26
- return to;
27
- };
28
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
- // If the importer is in node compatibility mode or this is not an ESM
30
- // file that has been converted to a CommonJS file using a Babel-
31
- // compatible transform (i.e. "__esModule" has not been set), then set
32
- // "default" to the CommonJS "module.exports" for node compatibility.
33
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
- mod
35
- ));
36
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
-
38
- // assets/icons/Fallback.svg
39
- var require_Fallback = __commonJS({
40
- "assets/icons/Fallback.svg"(exports2, module2) {
41
- module2.exports = "./assets/Fallback-R62GNTAJ.svg";
42
- }
43
- });
44
-
45
- // index.ts
46
- var index_exports = {};
47
- __export(index_exports, {
48
- DynamicIcon: () => DynamicIcon_default
49
- });
50
- module.exports = __toCommonJS(index_exports);
51
-
52
- // src/DynamicIcon.tsx
53
- var import_react = require("react");
54
- var import_react_svg = require("react-svg");
55
- var import_jsx_runtime = require("react/jsx-runtime");
56
-
57
- // import("../assets/icons/**/*.svg") in src/DynamicIcon.tsx
58
- var globImport_assets_icons_svg = __glob({
59
- "../assets/icons/Fallback.svg": () => Promise.resolve().then(() => __toESM(require_Fallback()))
60
- });
61
-
62
- // src/DynamicIcon.tsx
63
- var DynamicIcon = ({
64
- iconName = "Fallback",
65
- size = "25",
66
- color = "black"
67
- }) => {
68
- const [iconUrl, setIconUrl] = (0, import_react.useState)(null);
69
- (0, import_react.useEffect)(() => {
70
- const importIcon = async () => {
71
- try {
72
- const icon = await globImport_assets_icons_svg(`../assets/icons/${iconName}.svg`);
73
- setIconUrl(icon.default);
74
- } catch (error) {
75
- console.error(`Icon ${iconName} not found`);
76
- setIconUrl(null);
77
- }
78
- };
79
- importIcon();
80
- }, [iconName]);
81
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
82
- import_react_svg.ReactSVG,
83
- {
84
- src: iconUrl || "",
85
- className: color,
86
- beforeInjection: (svg) => {
87
- svg.setAttribute("style", `width: ${size}px; height: ${size}px;`);
88
- svg.setAttribute("fill", "currentColor");
89
- svg.querySelectorAll("path").forEach((path) => {
90
- path.setAttribute("fill", "currentColor");
91
- });
92
- }
93
- }
94
- );
95
- };
96
- var DynamicIcon_default = DynamicIcon;
97
- // Annotate the CommonJS export names for ESM import in node:
98
- 0 && (module.exports = {
99
- DynamicIcon
100
- });
101
- //# sourceMappingURL=index.js.map
1
+ export { default as DynamicIcon } from "./src/DynamicIcon";
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "svg-dynamic-icon",
3
- "version": "1.0.1",
4
- "main": "index.js",
3
+ "version": "1.0.3",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
5
6
  "scripts": {
6
7
  "build": "node build.js"
7
8
  },