@iconmu/react 0.0.2 → 0.0.4
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/README.md +194 -12
- package/dist/components/Iconmu.d.ts +1 -1
- package/dist/components/Iconmu.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @iconmu/react
|
|
2
2
|
|
|
3
|
-
React component for Iconmu icon library.
|
|
3
|
+
React component for the Iconmu icon library. This package provides a simple, flexible way to use Iconmu icons in your React applications with full TypeScript support.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -10,30 +10,212 @@ npm install @iconmu/react @iconmu/base-line
|
|
|
10
10
|
bun add @iconmu/react @iconmu/base-line
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
**Note:** You need both packages:
|
|
14
|
+
- `@iconmu/react` - The React component that renders icons
|
|
15
|
+
- `@iconmu/base-line` - The icon data package
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
Import the `Iconmu` component and an icon, then use it in your JSX:
|
|
16
20
|
|
|
17
21
|
```tsx
|
|
18
22
|
import { Iconmu } from "@iconmu/react";
|
|
19
|
-
import
|
|
23
|
+
import { HomeIcon } from "@iconmu/base-line";
|
|
20
24
|
|
|
21
25
|
function App() {
|
|
22
|
-
return <Iconmu icon={
|
|
26
|
+
return <Iconmu icon={HomeIcon} size={24} />;
|
|
23
27
|
}
|
|
24
28
|
```
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
**Important:** All icon names end with "Icon" (e.g., `HomeIcon`, `ActivityIcon`) to prevent naming conflicts with your own components.
|
|
31
|
+
|
|
32
|
+
## Usage Patterns
|
|
33
|
+
|
|
34
|
+
### Pattern 1: Named Import (Recommended)
|
|
35
|
+
|
|
36
|
+
Import individual icons for optimal tree-shaking. Only the icons you import will be included in your bundle.
|
|
37
|
+
|
|
27
38
|
```tsx
|
|
28
39
|
import { Iconmu } from "@iconmu/react";
|
|
29
|
-
import {
|
|
40
|
+
import { HomeIcon, ActivityIcon, SettingsIcon, UserIcon } from "@iconmu/base-line";
|
|
30
41
|
|
|
31
|
-
function
|
|
42
|
+
function Navigation() {
|
|
43
|
+
return (
|
|
44
|
+
<nav>
|
|
45
|
+
<a href="/"><Iconmu icon={HomeIcon} size={20} /> Home</a>
|
|
46
|
+
<a href="/activity"><Iconmu icon={ActivityIcon} size={20} /> Activity</a>
|
|
47
|
+
<a href="/settings"><Iconmu icon={SettingsIcon} size={20} /> Settings</a>
|
|
48
|
+
<a href="/profile"><Iconmu icon={UserIcon} size={20} /> Profile</a>
|
|
49
|
+
</nav>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**Benefits:**
|
|
55
|
+
- Only imported icons are bundled
|
|
56
|
+
- Clear dependencies in your code
|
|
57
|
+
- IDE autocomplete works best
|
|
58
|
+
|
|
59
|
+
### Pattern 2: Namespace Import
|
|
60
|
+
|
|
61
|
+
Import all icons from a package as a namespace. Useful when you need many icons or want dynamic access.
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { Iconmu } from "@iconmu/react";
|
|
65
|
+
import * as Icons from "@iconmu/base-line";
|
|
66
|
+
|
|
67
|
+
function IconGallery() {
|
|
68
|
+
return (
|
|
69
|
+
<div>
|
|
70
|
+
<Iconmu icon={Icons.HomeIcon} size={24} />
|
|
71
|
+
<Iconmu icon={Icons.ActivityIcon} size={24} />
|
|
72
|
+
<Iconmu icon={Icons.ArrowBigUpIcon} size={24} />
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Benefits:**
|
|
79
|
+
- Access any icon without additional imports
|
|
80
|
+
- Good for icon pickers or dynamic UIs
|
|
81
|
+
|
|
82
|
+
**Trade-off:** May include unused icons in bundle (depending on your bundler)
|
|
83
|
+
|
|
84
|
+
### Pattern 3: Dynamic Icon Access
|
|
85
|
+
|
|
86
|
+
Access icons dynamically using the namespace and string names:
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { Iconmu } from "@iconmu/react";
|
|
90
|
+
import * as LineIcons from "@iconmu/base-line";
|
|
91
|
+
|
|
92
|
+
type IconName = "HomeIcon" | "ActivityIcon" | "SettingsIcon";
|
|
93
|
+
|
|
94
|
+
function DynamicIcon({ name, size = 24 }: { name: IconName; size?: number }) {
|
|
95
|
+
const icon = LineIcons[name];
|
|
96
|
+
return <Iconmu icon={icon} size={size} />;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Usage
|
|
100
|
+
<DynamicIcon name="HomeIcon" size={32} />
|
|
101
|
+
<DynamicIcon name="ActivityIcon" />
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Use cases:**
|
|
105
|
+
- Icon configuration from CMS/database
|
|
106
|
+
- User-customizable UI elements
|
|
107
|
+
- Component libraries with icon props
|
|
108
|
+
|
|
109
|
+
### Pattern 4: Using Different Icon Styles
|
|
110
|
+
|
|
111
|
+
Iconmu provides 4 visual styles. Install and use multiple styles in the same project:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npm install @iconmu/base-line @iconmu/base-solid @iconmu/sharp-line @iconmu/sharp-solid
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
import { Iconmu } from "@iconmu/react";
|
|
119
|
+
import { HomeIcon as HomeBaseLine } from "@iconmu/base-line";
|
|
120
|
+
import { HomeIcon as HomeBaseSolid } from "@iconmu/base-solid";
|
|
121
|
+
import { HomeIcon as HomeSharpLine } from "@iconmu/sharp-line";
|
|
122
|
+
import { HomeIcon as HomeSharpSolid } from "@iconmu/sharp-solid";
|
|
123
|
+
|
|
124
|
+
function StyleComparison() {
|
|
125
|
+
return (
|
|
126
|
+
<div className="flex gap-4 p-4">
|
|
127
|
+
<div className="text-center">
|
|
128
|
+
<Iconmu icon={HomeBaseLine} size={32} className="fill-neutral-950" />
|
|
129
|
+
<p className="text-xs mt-1">Base Line</p>
|
|
130
|
+
</div>
|
|
131
|
+
<div className="text-center">
|
|
132
|
+
<Iconmu icon={HomeBaseSolid} size={32} className="fill-neutral-950" />
|
|
133
|
+
<p className="text-xs mt-1">Base Solid</p>
|
|
134
|
+
</div>
|
|
135
|
+
<div className="text-center">
|
|
136
|
+
<Iconmu icon={HomeSharpLine} size={32} className="fill-neutral-950" />
|
|
137
|
+
<p className="text-xs mt-1">Sharp Line</p>
|
|
138
|
+
</div>
|
|
139
|
+
<div className="text-center">
|
|
140
|
+
<Iconmu icon={HomeSharpSolid} size={32} className="fill-neutral-950" />
|
|
141
|
+
<p className="text-xs mt-1">Sharp Solid</p>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Pattern 5: Conditional Rendering
|
|
149
|
+
|
|
150
|
+
Use icons conditionally based on state:
|
|
151
|
+
|
|
152
|
+
```tsx
|
|
153
|
+
import { Iconmu } from "@iconmu/react";
|
|
154
|
+
import { EyeOnIcon, EyeOffIcon } from "@iconmu/base-line";
|
|
155
|
+
|
|
156
|
+
function PasswordInput() {
|
|
157
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<div className="relative">
|
|
161
|
+
<input type={showPassword ? "text" : "password"} />
|
|
162
|
+
<button onClick={() => setShowPassword(!showPassword)}>
|
|
163
|
+
<Iconmu
|
|
164
|
+
icon={showPassword ? EyeOnIcon : EyeOffIcon}
|
|
165
|
+
size={20}
|
|
166
|
+
/>
|
|
167
|
+
</button>
|
|
168
|
+
</div>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Pattern 6: With Custom Colors
|
|
174
|
+
|
|
175
|
+
Apply colors using the `color` prop or Tailwind classes:
|
|
176
|
+
|
|
177
|
+
```tsx
|
|
178
|
+
import { Iconmu } from "@iconmu/react";
|
|
179
|
+
import { HeartIcon, StarIcon } from "@iconmu/base-line";
|
|
180
|
+
|
|
181
|
+
function Rating() {
|
|
32
182
|
return (
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
size={
|
|
36
|
-
|
|
183
|
+
<div className="flex gap-2">
|
|
184
|
+
{/* Using color prop */}
|
|
185
|
+
<Iconmu icon={HeartIcon} size={24} color="#EF4444" />
|
|
186
|
+
|
|
187
|
+
{/* Using Tailwind classes */}
|
|
188
|
+
<Iconmu icon={StarIcon} size={24} className="text-yellow-400 fill-yellow-400" />
|
|
189
|
+
<Iconmu icon={StarIcon} size={24} className="text-yellow-400 fill-yellow-400" />
|
|
190
|
+
<Iconmu icon={StarIcon} size={24} className="text-gray-300" />
|
|
191
|
+
</div>
|
|
37
192
|
);
|
|
38
193
|
}
|
|
39
194
|
```
|
|
195
|
+
|
|
196
|
+
## Props
|
|
197
|
+
|
|
198
|
+
| Prop | Type | Default | Description |
|
|
199
|
+
|------|------|---------|-------------|
|
|
200
|
+
| `icon` | `{ content: string, viewBox: string }` | required | Icon object from icon packages |
|
|
201
|
+
| `size` | `number` | `24` | Icon size in pixels (width and height) |
|
|
202
|
+
| `color` | `string` | `"currentColor"` | Icon color (CSS color value) |
|
|
203
|
+
| `className` | `string` | `""` | Additional CSS classes |
|
|
204
|
+
|
|
205
|
+
## Icon Packages
|
|
206
|
+
|
|
207
|
+
Available icon style packages:
|
|
208
|
+
|
|
209
|
+
- `@iconmu/base-line` - Base line style icons
|
|
210
|
+
- `@iconmu/base-solid` - Base solid style icons
|
|
211
|
+
- `@iconmu/sharp-line` - Sharp line style icons
|
|
212
|
+
- `@iconmu/sharp-solid` - Sharp solid style icons
|
|
213
|
+
|
|
214
|
+
## Peer Dependencies
|
|
215
|
+
|
|
216
|
+
- `react` >=16.8.0
|
|
217
|
+
- `react-dom` >=16.8.0
|
|
218
|
+
|
|
219
|
+
## License
|
|
220
|
+
|
|
221
|
+
MIT
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Iconmu.d.ts","sourceRoot":"","sources":["../../src/components/Iconmu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,
|
|
1
|
+
{"version":3,"file":"Iconmu.d.ts","sourceRoot":"","sources":["../../src/components/Iconmu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,QAAQ,GAAG;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;AAElC,wBAAgB,MAAM,CAAC,EACrB,IAAI,EACJ,IAAI,EACJ,KAAsB,EACtB,SAAc,EACd,GAAG,KAAK,EACT,EAAE,SAAS,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAmBhC;AAED,eAAe,MAAM,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,qBAAqB,CAAC"}
|