@whydrf/nava-icon-react 1.1.2 → 1.4.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.
- package/README.md +36 -4
- package/dist/Icon.cjs +16 -7
- package/dist/Icon.js +121 -120
- package/dist/NavaIconProvider.cjs +42 -0
- package/dist/NavaIconProvider.d.cts +12 -0
- package/dist/NavaIconProvider.d.ts +12 -0
- package/dist/NavaIconProvider.js +11 -0
- package/dist/chunk-DHINNPOD.js +16 -0
- package/dist/{chunk-3KRACJKY.js → chunk-O3YGDEMS.js} +247 -243
- package/dist/index.cjs +25 -9
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +247 -241
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img src="https://raw.githubusercontent.com/whydrf/nava-icon/main/docs/public/favicon.svg" width="60" alt="Nava Icons">
|
|
3
|
-
</p>
|
|
4
1
|
|
|
5
2
|
<h1 align="center">@whydrf/nava-icon-react</h1>
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://vahidghadiri.github.io/Nava-icon/">
|
|
5
|
+
Live Documentation
|
|
6
|
+
</a>
|
|
7
|
+
</p>
|
|
6
8
|
|
|
7
9
|
<p align="center">
|
|
8
10
|
950+ beautiful, tree-shakeable SVG icons for React applications.
|
|
@@ -48,7 +50,7 @@ export function Navigation() {
|
|
|
48
50
|
}
|
|
49
51
|
```
|
|
50
52
|
|
|
51
|
-
That's it — no
|
|
53
|
+
That's it — no setup required. Just import and use. For setting default props across your app, see [Global Configuration](#global-configuration).
|
|
52
54
|
|
|
53
55
|
## How Tree Shaking Works
|
|
54
56
|
|
|
@@ -157,6 +159,36 @@ With **Tailwind CSS**, wrap the icon in a utility class and use `currentColor`:
|
|
|
157
159
|
<HomeIcon className="text-gray-900 dark:text-white" />
|
|
158
160
|
```
|
|
159
161
|
|
|
162
|
+
## Global Configuration
|
|
163
|
+
|
|
164
|
+
Instead of passing the same props to every icon, wrap your app with `NavaIconProvider` to set defaults once. All `Icon` components and static icon imports within the provider will inherit these values.
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
import { NavaIconProvider, HomeIcon, SearchIcon } from '@whydrf/nava-icon-react'
|
|
168
|
+
|
|
169
|
+
function App() {
|
|
170
|
+
return (
|
|
171
|
+
<NavaIconProvider size={20} color="gray" strokeWidth={1.5}>
|
|
172
|
+
<HomeIcon /> {/* size=20, color="gray", strokeWidth=1.5 */}
|
|
173
|
+
<SearchIcon size={24} /> {/* size=24 overrides provider — color and strokeWidth inherited */}
|
|
174
|
+
</NavaIconProvider>
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Props always override provider values.** If you pass `size={32}` to an icon, that takes priority over the provider's `size`.
|
|
180
|
+
|
|
181
|
+
You can also use the `useNavaIconConfig` hook to read the current configuration:
|
|
182
|
+
|
|
183
|
+
```tsx
|
|
184
|
+
import { useNavaIconConfig } from '@whydrf/nava-icon-react'
|
|
185
|
+
|
|
186
|
+
function DebugConfig() {
|
|
187
|
+
const config = useNavaIconConfig()
|
|
188
|
+
return <pre>{JSON.stringify(config)}</pre>
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
160
192
|
## Accessibility
|
|
161
193
|
|
|
162
194
|
Icons include built-in accessibility features:
|
package/dist/Icon.cjs
CHANGED
|
@@ -23,7 +23,7 @@ __export(Icon_exports, {
|
|
|
23
23
|
Icon: () => Icon
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(Icon_exports);
|
|
26
|
-
var
|
|
26
|
+
var import_react2 = require("react");
|
|
27
27
|
|
|
28
28
|
// src/icons/index.ts
|
|
29
29
|
var icons_exports = {};
|
|
@@ -39854,14 +39854,23 @@ function ZoomOutIcon(props) {
|
|
|
39854
39854
|
);
|
|
39855
39855
|
}
|
|
39856
39856
|
|
|
39857
|
+
// src/NavaIconProvider.tsx
|
|
39858
|
+
var import_react = require("react");
|
|
39859
|
+
var import_jsx_runtime953 = require("react/jsx-runtime");
|
|
39860
|
+
var NavaIconContext = (0, import_react.createContext)(null);
|
|
39861
|
+
function useNavaIconConfig() {
|
|
39862
|
+
return (0, import_react.useContext)(NavaIconContext) ?? {};
|
|
39863
|
+
}
|
|
39864
|
+
|
|
39857
39865
|
// src/Icon.tsx
|
|
39858
39866
|
var iconRecord = icons_exports;
|
|
39859
39867
|
function normalizeIconName(name) {
|
|
39860
39868
|
if (name.endsWith("Icon")) return name;
|
|
39861
39869
|
return name.split(/[-_\s]+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("") + "Icon";
|
|
39862
39870
|
}
|
|
39863
|
-
var Icon = (0,
|
|
39871
|
+
var Icon = (0, import_react2.forwardRef)(
|
|
39864
39872
|
({ name, size, color, strokeWidth, className, title, style, mode, ...props }, ref) => {
|
|
39873
|
+
const config = useNavaIconConfig();
|
|
39865
39874
|
const iconName = normalizeIconName(name);
|
|
39866
39875
|
const Component = iconRecord[iconName];
|
|
39867
39876
|
if (!Component) {
|
|
@@ -39870,12 +39879,12 @@ var Icon = (0, import_react.forwardRef)(
|
|
|
39870
39879
|
}
|
|
39871
39880
|
return null;
|
|
39872
39881
|
}
|
|
39873
|
-
return (0,
|
|
39882
|
+
return (0, import_react2.createElement)(Component, {
|
|
39874
39883
|
ref,
|
|
39875
|
-
size,
|
|
39876
|
-
color,
|
|
39877
|
-
strokeWidth,
|
|
39878
|
-
className,
|
|
39884
|
+
size: size ?? config.size,
|
|
39885
|
+
color: color ?? config.color,
|
|
39886
|
+
strokeWidth: strokeWidth ?? config.strokeWidth,
|
|
39887
|
+
className: className ?? config.className,
|
|
39879
39888
|
title,
|
|
39880
39889
|
style,
|
|
39881
39890
|
mode,
|