@whydrf/nava-icon-web-components 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 +32 -3
- package/dist/chunk-6PLL5KGQ.js +13 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.js +8 -0
- package/dist/icons/index.js +119 -119
- package/dist/index.d.ts +2 -0
- package/dist/index.js +126 -120
- package/package.json +4 -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-web-components</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 as native Web Components.
|
|
@@ -52,6 +54,33 @@ Once imported, every icon becomes available as a custom element. Icons follow th
|
|
|
52
54
|
|
|
53
55
|
That's it — no framework, no components to import, no configuration. Just HTML.
|
|
54
56
|
|
|
57
|
+
## Global Configuration
|
|
58
|
+
|
|
59
|
+
You can set default icon properties globally using `setNavaIconConfig`. All icons will use these defaults unless overridden by individual attributes.
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<script type="module">
|
|
63
|
+
import '@whydrf/nava-icon-web-components'
|
|
64
|
+
import { setNavaIconConfig } from '@whydrf/nava-icon-web-components'
|
|
65
|
+
|
|
66
|
+
// Set global defaults
|
|
67
|
+
setNavaIconConfig({ size: 20, color: 'gray', strokeWidth: 1.5 })
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<!-- All icons inherit global defaults -->
|
|
71
|
+
<nava-icon-home></nava-icon-home> <!-- size=20, color="gray" -->
|
|
72
|
+
<nava-icon-search size="24"></nava-icon-search> <!-- size=24 overrides — rest inherited -->
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Attributes always override global configuration.** If you pass `size="32"` on an element, that takes priority over the global `size`.
|
|
76
|
+
|
|
77
|
+
You can read the current configuration at any time:
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
import { getNavaIconConfig } from '@whydrf/nava-icon-web-components'
|
|
81
|
+
console.log(getNavaIconConfig()) // { size: 20, color: 'gray', strokeWidth: 1.5 }
|
|
82
|
+
```
|
|
83
|
+
|
|
55
84
|
## How Tree Shaking Works
|
|
56
85
|
|
|
57
86
|
When you import the package in a `<script type="module">`, only the icons actually used in your HTML are included in the final bundle. The build tool (Vite, Rollup, webpack, esbuild) traces which custom elements are referenced and eliminates the rest.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/config.ts
|
|
2
|
+
var globalConfig = {};
|
|
3
|
+
function setNavaIconConfig(config) {
|
|
4
|
+
globalConfig = { ...globalConfig, ...config };
|
|
5
|
+
}
|
|
6
|
+
function getNavaIconConfig() {
|
|
7
|
+
return { ...globalConfig };
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
setNavaIconConfig,
|
|
12
|
+
getNavaIconConfig
|
|
13
|
+
};
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NavaIconConfig } from '@whydrf/nava-icon-core';
|
|
2
|
+
export { NavaIconConfig } from '@whydrf/nava-icon-core';
|
|
3
|
+
|
|
4
|
+
declare function setNavaIconConfig(config: NavaIconConfig): void;
|
|
5
|
+
declare function getNavaIconConfig(): NavaIconConfig;
|
|
6
|
+
|
|
7
|
+
export { getNavaIconConfig, setNavaIconConfig };
|