@whydrf/nava-icon-vue 0.1.0 → 1.0.1

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 (2) hide show
  1. package/README.md +278 -0
  2. package/package.json +7 -7
package/README.md ADDED
@@ -0,0 +1,278 @@
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
+
5
+ <h1 align="center">@whydrf/nava-icon-vue</h1>
6
+
7
+ <p align="center">
8
+ 950+ beautiful, tree-shakeable SVG icons for Vue 3.
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://www.npmjs.com/package/@whydrf/nava-icon-vue"><img src="https://img.shields.io/npm/v/@whydrf/nava-icon-vue?style=flat-square&color=emerald" alt="npm version"></a>
13
+ <a href="https://github.com/whydrf/nava-icon/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@whydrf/nava-icon-vue?style=flat-square" alt="license"></a>
14
+ <a href="https://www.npmjs.com/package/@whydrf/nava-icon-vue"><img src="https://img.shields.io/npm/dm/@whydrf/nava-icon-vue?style=flat-square&color=emerald" alt="npm downloads"></a>
15
+ </p>
16
+
17
+ ---
18
+
19
+ ## What is this?
20
+
21
+ `@whydrf/nava-icon-vue` is the Vue 3 binding for [Nava Icons](https://github.com/whydrf/nava-icon) — a collection of 950+ handcrafted SVG icons. Each icon is a native Vue component using the Composition API, with full TypeScript support, tree shaking, and two visual variants (regular outlines and filled shapes).
22
+
23
+ Unlike icon fonts or SVG sprites, every icon here is a proper Vue component with props, events, and fallthrough attributes. You use it in your templates exactly like any other component.
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ npm install @whydrf/nava-icon-vue
29
+ ```
30
+
31
+ **Requirements:** Vue 3 or later. Works with Nuxt 3, Vite, Vue CLI, and any Vue 3 setup.
32
+
33
+ ## Getting Started
34
+
35
+ After installation, import the icons you need by name. Every icon follows the pattern `{IconName}Icon` in PascalCase:
36
+
37
+ ```vue
38
+ <script setup>
39
+ import { HomeIcon, SearchIcon, SettingsIcon } from '@whydrf/nava-icon-vue'
40
+ </script>
41
+
42
+ <template>
43
+ <nav>
44
+ <HomeIcon :size="24" />
45
+ <SearchIcon :size="24" color="gray" />
46
+ <SettingsIcon :size="24" />
47
+ </nav>
48
+ </template>
49
+ ```
50
+
51
+ That's it — no plugin to install, no global registration required. Just import and use in your `<script setup>`.
52
+
53
+ ## How Tree Shaking Works
54
+
55
+ This is the most important concept to understand. When you write:
56
+
57
+ ```vue
58
+ <script setup>
59
+ import { HomeIcon } from '@whydrf/nava-icon-vue'
60
+ </script>
61
+ ```
62
+
63
+ Your bundler (Vite, Rollup, webpack) traces this import and includes **only** the `HomeIcon` component in your production bundle. The other 949 icons are completely eliminated. This is why static imports are strongly recommended.
64
+
65
+ In contrast, this pattern imports everything:
66
+
67
+ ```vue
68
+ <!-- ❌ Don't do this in production — bundles all 950+ icons -->
69
+ <script setup>
70
+ import * as Icons from '@whydrf/nava-icon-vue'
71
+ </script>
72
+ ```
73
+
74
+ If you need to render icons dynamically (e.g., the icon name comes from an API or user input), use the `NavaIcon` component instead. It's designed for that specific use case.
75
+
76
+ ## Two Variants: Regular and Filled
77
+
78
+ Every icon ships in two visual styles:
79
+
80
+ - **Regular** — Stroke-based outlines. Clean, minimal, and ideal for most UI contexts like navigation, toolbars, and forms.
81
+ - **Filled** — Solid shapes with filled regions. Great for emphasis, active states, or when you want an icon to stand out.
82
+
83
+ You control which variant to show with the `mode` prop:
84
+
85
+ ```vue
86
+ <script setup>
87
+ import { CheckCircleIcon, HeartIcon } from '@whydrf/nava-icon-vue'
88
+
89
+ defineProps<{ isComplete: boolean; isLiked: boolean }>()
90
+ </script>
91
+
92
+ <template>
93
+ <div>
94
+ <!-- Show a filled heart when liked, outline when not -->
95
+ <HeartIcon
96
+ :size="24"
97
+ :mode="isLiked ? 'filled' : 'regular'"
98
+ :color="isLiked ? 'red' : 'gray'"
99
+ />
100
+
101
+ <!-- Always show filled for completed tasks -->
102
+ <CheckCircleIcon :size="24" mode="filled" color="green" />
103
+ </div>
104
+ </template>
105
+ ```
106
+
107
+ The mode switching is instant — no re-fetching, no lazy loading. Both variants are bundled together.
108
+
109
+ ## The Dynamic `NavaIcon` Component
110
+
111
+ Sometimes you can't use static imports. Maybe the icon name comes from an API, a database, or user configuration. For these cases, the package exports a `NavaIcon` component:
112
+
113
+ ```vue
114
+ <script setup>
115
+ import { NavaIcon } from '@whydrf/nava-icon-vue'
116
+
117
+ defineProps<{ iconName: string }>()
118
+ </script>
119
+
120
+ <template>
121
+ <!-- The name prop accepts kebab-case strings -->
122
+ <NavaIcon :name="iconName" :size="24" />
123
+ <NavaIcon name="check-circle" :size="24" mode="filled" color="green" />
124
+ <NavaIcon name="arrow-right" :size="16" />
125
+ </template>
126
+ ```
127
+
128
+ **Important:** The `NavaIcon` component imports all icons internally, so it cannot be tree-shaken. Your bundle will include all 950+ icons. Use it only when static imports aren't feasible.
129
+
130
+ ## Customizing Appearance
131
+
132
+ Since icons are standard SVG elements, you can customize them with CSS and standard Vue attributes. All attributes fall through to the underlying SVG element automatically:
133
+
134
+ ```vue
135
+ <script setup>
136
+ import { HomeIcon } from '@whydrf/nava-icon-vue'
137
+ </script>
138
+
139
+ <template>
140
+ <HomeIcon
141
+ :size="32"
142
+ color="#6366f1"
143
+ :stroke-width="1"
144
+ class="icon-hover"
145
+ :style="{ transition: 'transform 0.2s', cursor: 'pointer' }"
146
+ @click="navigate('/')"
147
+ />
148
+ </template>
149
+
150
+ <style scoped>
151
+ .icon-hover:hover {
152
+ transform: scale(1.1);
153
+ color: darkblue;
154
+ }
155
+ </style>
156
+ ```
157
+
158
+ ### Colors
159
+
160
+ You can pass colors in any format the browser understands — hex codes, RGB, HSL, named colors, or CSS variables:
161
+
162
+ ```vue
163
+ <HomeIcon color="#1a1a2e" /> <!-- Hex -->
164
+ <HomeIcon color="rgb(99, 102, 241)" /> <!-- RGB -->
165
+ <HomeIcon color="oklch(65% 0.27 264)" /> <!-- OKLCH -->
166
+ <HomeIcon color="var(--primary)" /> <!-- CSS variable -->
167
+ ```
168
+
169
+ With **Tailwind CSS**, the `color` prop defaults to `currentColor`, so Tailwind's `text-*` utilities work directly:
170
+
171
+ ```vue
172
+ <!-- Combine color, size, and hover effects -->
173
+ <HomeIcon class="text-emerald-400 w-8 h-8 hover:text-emerald-300 transition-colors" />
174
+
175
+ <!-- Dark mode support -->
176
+ <HomeIcon class="text-gray-900 dark:text-white" />
177
+ ```
178
+
179
+ ## Accessibility
180
+
181
+ Icons include built-in accessibility features:
182
+
183
+ - When you provide a `title` prop (use `:title` in templates), an invisible `<title>` element is added inside the SVG, which screen readers announce.
184
+ - Decorative icons (no `title`) are implicitly `aria-hidden` since SVGs without titles are ignored by assistive technology.
185
+
186
+ ```vue
187
+ <!-- Meaningful icon — screen reader announces "Go to homepage" -->
188
+ <HomeIcon title="Go to homepage" />
189
+
190
+ <!-- Decorative icon — screen reader ignores it -->
191
+ <HomeIcon />
192
+ ```
193
+
194
+ ## Server-Side Rendering
195
+
196
+ Nava Icons works with SSR out of the box. Icons are rendered as regular HTML/SVG elements — no client-side JavaScript required to display them.
197
+
198
+ ### Nuxt 3
199
+
200
+ ```vue
201
+ <!-- Works in any Nuxt component — no client-only wrapper needed -->
202
+ <script setup>
203
+ import { HomeIcon } from '@whydrf/nava-icon-vue'
204
+ </script>
205
+
206
+ <template>
207
+ <HomeIcon :size="24" />
208
+ </template>
209
+ ```
210
+
211
+ ### Vue SSR (Vite SSR / Custom Setup)
212
+
213
+ ```vue
214
+ <script setup>
215
+ import { HomeIcon } from '@whydrf/nava-icon-vue'
216
+ </script>
217
+
218
+ <template>
219
+ <!-- This renders identically on server and client -->
220
+ <HomeIcon :size="24" />
221
+ </template>
222
+ ```
223
+
224
+ ## TypeScript
225
+
226
+ The package includes full TypeScript definitions. You get autocompletion for icon names and type checking for all props:
227
+
228
+ ```vue
229
+ <script setup lang="ts">
230
+ import type { IconName, IconMode } from '@whydrf/nava-icon-vue'
231
+
232
+ // IconName gives you autocompletion for all 950+ icon names
233
+ const icon: IconName = 'home' // ✅ valid
234
+ const bad: IconName = 'invalid' // ❌ compile error
235
+
236
+ // IconMode constrains to 'regular' | 'filled'
237
+ const mode: IconMode = 'filled' // ✅
238
+ </script>
239
+ ```
240
+
241
+ ## Props Reference
242
+
243
+ | Prop | Type | Default | Description |
244
+ |------|------|---------|-------------|
245
+ | `size` | `number \| string` | `24` | Width and height in pixels |
246
+ | `color` | `string` | `currentColor` | SVG stroke/fill color. `currentColor` inherits from parent CSS |
247
+ | `strokeWidth` | `number \| string` | `0.5` | Controls line thickness for stroke-based icons |
248
+ | `mode` | `"regular" \| "filled"` | `"regular"` | Toggles between outline and solid variants |
249
+
250
+ All standard SVG attributes (`@click`, `@mouseenter`, `class`, `style`, `data-*`, `aria-*`, etc.) fall through to the SVG element automatically.
251
+
252
+ ## Popular Icons
253
+
254
+ | Category | Icons |
255
+ |----------|-------|
256
+ | **Arrows** | `arrow-back`, `arrow-right`, `arrow-from-left`, `arrow-to-top`, `refresh`, `redo`, `undo` |
257
+ | **Interface** | `home`, `search`, `settings`, `menu`, `check-circle`, `x-circle`, `copy`, `trash` |
258
+ | **Communication** | `bell`, `mail`, `phone`, `message-square`, `send`, `at` |
259
+ | **Files** | `file`, `folder`, `download`, `upload`, `archive`, `clipboard` |
260
+ | **Media** | `camera`, `image`, `music`, `video`, `play`, `pause` |
261
+ | **Objects** | `star`, `bookmark`, `lock`, `key`, `award`, `gift` |
262
+ | **Weather** | `sun`, `moon`, `cloud`, `droplet`, `wind`, `umbrella` |
263
+ | **Shopping** | `cart`, `credit-card`, `bag`, `tag`, `badge`, `diamond` |
264
+
265
+ Browse all 950+ icons with live preview at [**nava-icons.dev**](https://nava-icons.dev).
266
+
267
+ ## When to Use What
268
+
269
+ | Scenario | Use |
270
+ |----------|-----|
271
+ | Icon name is known at build time | Static import: `import { HomeIcon } from '...'` |
272
+ | Icon name comes from API/user input | Dynamic: `<NavaIcon :name="..." />` |
273
+ | Icon toggles between outline/filled | `mode` prop: `<HomeIcon :mode="..." />` |
274
+ | Icon needs click handler | `@click` event: `<HomeIcon @click="..." />` |
275
+
276
+ ## License
277
+
278
+ [MIT](https://github.com/whydrf/nava-icon/blob/main/LICENSE) &copy; [whydrf](https://github.com/whydrf)
package/package.json CHANGED
@@ -1,31 +1,31 @@
1
1
  {
2
2
  "name": "@whydrf/nava-icon-vue",
3
- "version": "0.1.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "Vue components for Nava Icons",
7
7
  "main": "./dist/index.cjs",
8
- "module": "./dist/index.mjs",
8
+ "module": "./dist/index.js",
9
9
  "types": "./dist/index.d.ts",
10
10
  "exports": {
11
11
  ".": {
12
12
  "types": "./dist/index.d.ts",
13
- "import": "./dist/index.mjs",
13
+ "import": "./dist/index.js",
14
14
  "require": "./dist/index.cjs"
15
15
  },
16
16
  "./*": {
17
17
  "types": "./dist/icons/*.d.ts",
18
- "import": "./dist/icons/*.mjs",
18
+ "import": "./dist/icons/*.js",
19
19
  "require": "./dist/icons/*.cjs"
20
20
  },
21
21
  "./Icon": {
22
22
  "types": "./dist/Icon.d.ts",
23
- "import": "./dist/Icon.mjs",
23
+ "import": "./dist/Icon.js",
24
24
  "require": "./dist/Icon.cjs"
25
25
  },
26
26
  "./types": {
27
27
  "types": "./dist/types.d.ts",
28
- "import": "./dist/types.mjs",
28
+ "import": "./dist/types.js",
29
29
  "require": "./dist/types.cjs"
30
30
  },
31
31
  "./package.json": "./package.json"
@@ -62,4 +62,4 @@
62
62
  "url": "https://github.com/vahidGhadiri/Nava-icon",
63
63
  "directory": "packages/vue"
64
64
  }
65
- }
65
+ }