Skip to content

Commit 7a3b86e

Browse files
committed
fix: add icon size warning
1 parent f1f15dc commit 7a3b86e

File tree

1,620 files changed

+33998
-13024
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,620 files changed

+33998
-13024
lines changed

README.md

Lines changed: 46 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
11
<div align="center">
22

3-
# react-zero-ui/icon-sprite
3+
# @react-zero-ui/icon-sprite
4+
5+
[![MIT](https://img.shields.io/badge/License-MIT-green.svg)](#) [![npm](https://img.shields.io/npm/v/@react-zero-ui/icon-sprite.svg)](#)
6+
47

58
</div>
69

710
> [!NOTE]
8-
> **Automatically generates an SVG sprite containing only the icons you used in development** - Lucide + custom SVGs.
11+
> **Generates one SVG sprite containing only the icons you used** - Lucide + custom SVGs.
12+
> DX with real `<Icon/>` in dev ➡️ zero-runtime `<use/>` in prod.
913
10-
> **Zero-runtime icon sprites for React.** using Lucide icons and custom SVGs - optimized for dev experience and production performance. Part of the [React Zero-UI](https://github.com/react-zero-ui) ecosystem.
14+
> Part of the [React Zero-UI](https://github.com/react-zero-ui) ecosystem.
1115
1216

1317
---
1418

1519
## 🧠 What This Library Does
1620

17-
This package gives you:
18-
1921
1. **Full Lucide-React DX in development**
20-
Easy Imports, Instant updates, hot-reloading, JSX props, no caching issues. Use Just like Lucid but import the icon from `@react-zero-ui/icon-sprite` instead of `lucide-react`.
22+
Easy imports, hot reload, JSX propsimport icons from `@react-zero-ui/icon-sprite` instead of `lucide-react`.
2123

22-
2. **Zero-runtime SVG sprite usage in production**
23-
Replaces every icon component with a `<use href="/icons.svg#id" />` element at build time.
24+
2. **Zero-runtime in production**
25+
Every icon becomes `<use href="/icons.svg#id" />` at build time.
2426

25-
3. **Tree-shaking via static analysis**
26-
Icons are only included in the final sprite if your app actually uses them.
27+
3. **Smallest possible sprite**
28+
Only icons actually used in your app are included.
2729

28-
## 🙏 Custom icon support
29-
Just drop SVGs into `app/zero-ui-icons/`, and use the `<CustomIcon/>` component. set the `name` prop to the name of the icon file want to use.
30+
## 🙏 Custom Icon Support
31+
Drop SVGs into **`/zero-ui-icons/`** at your project root, then use `<CustomIcon />` with the `name` prop set to the file name (without `.svg`).
3032

3133
> [!TIP]
3234
>```txt
33-
>📁/public/zero-ui-icons/
35+
>📁/zero-ui-icons/
3436
> └── dog.svg
35-
>```
36-
>```tsx
37+
> ```
38+
> ```tsx
3739
>import { CustomIcon } from "@react-zero-ui/icon-sprite";
38-
>//❗The name MUST match the name of the icon file - .svg extension is not needed.
40+
>//❗The name MUST match the name of the file name (no .svg extension).
3941
><CustomIcon name="dog" size={24} />
4042
>```
4143
@@ -52,18 +54,32 @@ npm install @react-zero-ui/icon-sprite
5254

5355
## ❗ Build Command
5456
> [!CAUTION]
55-
> You must run this command before building your app, for `zero-svg` to work properly.
57+
> Run this before your app build so the sprite exists.
5658
>```bash
57-
>npx zero-svg
59+
>npx zero-icons
5860
>```
5961
60-
<small>This command builds the icons sprite for production</small>
62+
This command builds the icons sprite for production.
6163
64+
Or add this to your `package.json` scripts:
65+
```json
66+
{
67+
"scripts": {
68+
"prebuild": "zero-icons",
69+
"build": "your build command"
70+
}
71+
}
72+
```
73+
That's it!
6274

6375
---
6476

6577
## 🔨 Usage
6678

79+
> [!WARNING]
80+
> **Pass `size`, or both `width` and `height`, to ensure identical dev/prod rendering.**
81+
> Dev defaults (Lucide 24×24) differ from sprite viewBoxes in production. Missing these props will **very likely** change the visual size in prod.
82+
6783
### For Lucide Icons:
6884

6985
```tsx
@@ -122,52 +138,25 @@ At build time:
122138
To generate everything:
123139

124140
```bash
125-
npx zero-svg
141+
npx zero-icons
126142
```
127143

128144
This runs the full pipeline:
129145

130-
| Script | Purpose |
131-
| ----------------- | ------------------------------------------------------------------------------------------------------------ |
132-
| `scan-icons.js` | Parse your codebase for used icons (`Icon` usage or named imports) |
133-
| `used-icons.js` | Collects a list of unique icon names |
146+
| Script | Purpose |
147+
| --- | --- |
148+
| `scan-icons.js` | Parse your codebase for used icons (`Icon` usage or named imports) |
149+
| `used-icons.js` | Collects a list of unique icon names |
134150
| `build-sprite.js` | Uses [`svgstore`](https://github.com/DIYgod/svgstore) to generate `icons.svg` from used Lucide + custom SVGs |
135-
| `gen-wrappers.js` | Writes individual `.tsx` wrappers per icon to `src/icons/` |
136-
| `gen-dist.js` | Emits d.ts/types/index.js for publishing |
137-
| `config.js` | Loads your `zero-ui.config.js` if present |
138-
139-
140-
---
141-
<!--
142-
## 📁 Directory Structure
143-
144-
```txt
145-
📂 icon-sprite/
146-
├── 📂 dist/
147-
│ ├── 📂 icons/ # Generated Lucide icon wrappers (TSX)
148-
│ ├── config.js # Final resolved config
149-
│ ├── index.js # Entrypoint (exports Icon components)
150-
├── 📂 scripts/
151-
│ ├── scan-icons.js # AST parser → finds used icons
152-
│ ├── used-icons.js # Stores collected icon names
153-
│ ├── build-sprite.js # Creates the sprite from Lucide + custom
154-
│ ├── gen-wrappers.js # Creates TSX files for icons
155-
│ ├── gen-dist.js # Prepares the package for publishing
156-
├── 📂 src/
157-
│ ├── 📂 icons/ # Same as dist, before compile
158-
│ ├── config.ts # Default + user config merge
159-
├── 📄 README.md
160-
├── 📄 package.json
161-
└── 📄 tsconfig.json
162-
```
151+
| `config.js` | Loads your `zero-ui.config.js` if present |
163152

164-
--- -->
165153

154+
---
166155
## ✨ Why This Is Better
167156

168157
* **DX-first**: No flicker. No sprite caching. Live updates.
169-
* **Runtime-free in production**: Sprites are native, fast, lightweight.
170-
* **Built for Next.js / Vite**: No plugin overhead.
158+
* **Runtime-free in production**: Sprites are native, fast, lightweight & highly Cached.
159+
* **Only ships the icons you actually use** — smallest possible sprite.
171160
* **Minimal install**: No runtime dependency tree. Just React + Lucide.
172161

173162
---
@@ -180,8 +169,8 @@ You can override defaults with a root config file:
180169
// zero-ui.config.js
181170
export default {
182171
ROOT_DIR: "src", // where to scan for custom icon usage (default: "")
183-
SPRITE_PATH: "icons.svg", // public output path
184-
CUSTOM_SVG_DIR: "zero-ui-icons", // folder for your custom SVGs
172+
SPRITE_PATH: "icons.svg", // emitted to /public/icons.svg
173+
CUSTOM_SVG_DIR: "zero-ui-icons", // folder for your custom SVGs at project root
185174
}
186175
```
187176

icon-sprite/README.md

Lines changed: 50 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,46 @@
11
<div align="center">
22

33
# @react-zero-ui/icon-sprite
4+
5+
[![MIT](https://img.shields.io/badge/License-MIT-green.svg)](#) [![npm](https://img.shields.io/npm/v/@react-zero-ui/icon-sprite.svg)](#)
6+
47

58
</div>
69

7-
> [!NOTE]
8-
> **Automatically generates an SVG sprite containing only the icons you used in development** - Lucide + custom SVGs.
10+
> ![Note](https://img.shields.io/badge/Note-blue)
11+
> **Generates one SVG sprite containing only the icons you used** - Lucide + custom SVGs.
12+
> DX with real `<Icon/>` in dev ➡️ zero-runtime `<use/>` in prod.
913
10-
> **Zero-runtime icon sprites for React.** using Lucide icons and custom SVGs - optimized for dev experience and production performance. Part of the [React Zero-UI](https://github.com/react-zero-ui) ecosystem.
14+
> Part of the [React Zero-UI](https://github.com/react-zero-ui) ecosystem.
1115
1216

1317
---
1418

1519
## 🧠 What This Library Does
1620

17-
This package gives you:
18-
1921
1. **Full Lucide-React DX in development**
20-
Easy Imports, Instant updates, hot-reloading, JSX props, no caching issues. Use Just like Lucid but import the icon from `@react-zero-ui/icon-sprite` instead of `lucide-react`.
22+
Easy imports, hot reload, JSX propsimport icons from `@react-zero-ui/icon-sprite` instead of `lucide-react`.
2123

22-
2. **Zero-runtime SVG sprite usage in production**
23-
Replaces every icon component with a `<use href="/icons.svg#id" />` element at build time.
24+
2. **Zero-runtime in production**
25+
Every icon becomes `<use href="/icons.svg#id" />` at build time.
2426

25-
3. **Tree-shaking via static analysis**
26-
Icons are only included in the final sprite if your app actually uses them.
27+
3. **Smallest possible sprite**
28+
Only icons actually used in your app are included.
2729

28-
## 🙏 Custom icon support
29-
Just drop SVGs into `app/zero-ui-icons/`, and use the `<CustomIcon/>` component. set the `name` prop to the name of the icon file want to use.
30+
## 🙏 Custom Icon Support
31+
Drop SVGs into **`/zero-ui-icons/`** at your project root, then use `<CustomIcon />` with the `name` prop set to the file name (without `.svg`).
3032

31-
> [!TIP]
33+
> ![Tip](https://img.shields.io/badge/Tip-green)
3234
>```txt
33-
>📁/public/zero-ui-icons/
35+
>📁/zero-ui-icons/
3436
> └── dog.svg
35-
>```
36-
>```tsx
37+
> ```
38+
> ```tsx
3739
>import { CustomIcon } from "@react-zero-ui/icon-sprite";
38-
>//❗The name MUST match the name of the icon file - .svg extension is not needed.
40+
>//❗The name MUST match the name of the file name (no .svg extension).
3941
><CustomIcon name="dog" size={24} />
4042
>```
4143
42-
<small>This command builds the icons sprite for production</small>
4344
4445
---
4546
@@ -52,16 +53,33 @@ npm install @react-zero-ui/icon-sprite
5253
---
5354

5455
## ❗ Build Command
55-
> [!CAUTION]
56-
> You must run this command before building your app, for `zero-svg` to work properly.
56+
> ![Caution](https://img.shields.io/badge/Caution-red)
57+
> Run this before your app build so the sprite exists.
5758
>```bash
58-
>npx zero-svg
59+
>npx zero-icons
5960
>```
6061
62+
This command builds the icons sprite for production.
63+
64+
Or add this to your `package.json` scripts:
65+
```json
66+
{
67+
"scripts": {
68+
"prebuild": "zero-icons",
69+
"build": "your build command"
70+
}
71+
}
72+
```
73+
That's it!
74+
6175
---
6276

6377
## 🔨 Usage
6478

79+
> ![Warning](https://img.shields.io/badge/Warning-orange)
80+
> **Pass `size`, or both `width` and `height`, to ensure identical dev/prod rendering.**
81+
> Dev defaults (Lucide 24×24) differ from sprite viewBoxes in production. Missing these props will **very likely** change the visual size in prod.
82+
6583
### For Lucide Icons:
6684

6785
```tsx
@@ -120,52 +138,25 @@ At build time:
120138
To generate everything:
121139

122140
```bash
123-
npx zero-svg
141+
npx zero-icons
124142
```
125143

126144
This runs the full pipeline:
127145

128-
| Script | Purpose |
129-
| ----------------- | ------------------------------------------------------------------------------------------------------------ |
130-
| `scan-icons.js` | Parse your codebase for used icons (`Icon` usage or named imports) |
131-
| `used-icons.js` | Collects a list of unique icon names |
146+
| Script | Purpose |
147+
| --- | --- |
148+
| `scan-icons.js` | Parse your codebase for used icons (`Icon` usage or named imports) |
149+
| `used-icons.js` | Collects a list of unique icon names |
132150
| `build-sprite.js` | Uses [`svgstore`](https://github.com/DIYgod/svgstore) to generate `icons.svg` from used Lucide + custom SVGs |
133-
| `gen-wrappers.js` | Writes individual `.tsx` wrappers per icon to `src/icons/` |
134-
| `gen-dist.js` | Emits d.ts/types/index.js for publishing |
135-
| `config.js` | Loads your `zero-ui.config.js` if present |
136-
137-
138-
---
139-
<!--
140-
## 📁 Directory Structure
141-
142-
```txt
143-
📂 icon-sprite/
144-
├── 📂 dist/
145-
│ ├── 📂 icons/ # Generated Lucide icon wrappers (TSX)
146-
│ ├── config.js # Final resolved config
147-
│ ├── index.js # Entrypoint (exports Icon components)
148-
├── 📂 scripts/
149-
│ ├── scan-icons.js # AST parser → finds used icons
150-
│ ├── used-icons.js # Stores collected icon names
151-
│ ├── build-sprite.js # Creates the sprite from Lucide + custom
152-
│ ├── gen-wrappers.js # Creates TSX files for icons
153-
│ ├── gen-dist.js # Prepares the package for publishing
154-
├── 📂 src/
155-
│ ├── 📂 icons/ # Same as dist, before compile
156-
│ ├── config.ts # Default + user config merge
157-
├── 📄 README.md
158-
├── 📄 package.json
159-
└── 📄 tsconfig.json
160-
```
151+
| `config.js` | Loads your `zero-ui.config.js` if present |
161152

162-
--- -->
163153

154+
---
164155
## ✨ Why This Is Better
165156

166157
* **DX-first**: No flicker. No sprite caching. Live updates.
167-
* **Runtime-free in production**: Sprites are native, fast, lightweight.
168-
* **Built for Next.js / Vite**: No plugin overhead.
158+
* **Runtime-free in production**: Sprites are native, fast, lightweight & highly Cached.
159+
* **Only ships the icons you actually use** — smallest possible sprite.
169160
* **Minimal install**: No runtime dependency tree. Just React + Lucide.
170161

171162
---
@@ -178,8 +169,8 @@ You can override defaults with a root config file:
178169
// zero-ui.config.js
179170
export default {
180171
ROOT_DIR: "src", // where to scan for custom icon usage (default: "")
181-
SPRITE_PATH: "icons.svg", // public output path
182-
CUSTOM_SVG_DIR: "zero-ui-icons", // folder for your custom SVGs
172+
SPRITE_PATH: "icons.svg", // emitted to /public/icons.svg
173+
CUSTOM_SVG_DIR: "zero-ui-icons", // folder for your custom SVGs at project root
183174
}
184175
```
185176

icon-sprite/package.json

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
{
22
"name": "@react-zero-ui/icon-sprite",
3-
"description": "Lucide-React DX + zero-runtime SVG sprite for Next/Vite/ frontends",
3+
"description": "Generate a single SVG sprite containing only the icons you used (Lucide + custom). Lucid to SVG sprite solution for React.",
4+
"keywords": [
5+
"react",
6+
"icons",
7+
"lucide",
8+
"svg",
9+
"sprite",
10+
"nextjs",
11+
"vite",
12+
"zero-runtime",
13+
"tree-shaking",
14+
"lucid-to-sprite",
15+
"svg-to-sprite"
16+
],
417
"repository": {
518
"type": "git",
619
"url": "git+https://github.com/react-zero-ui/icon-sprite.git",
@@ -28,7 +41,7 @@
2841
"type-check": "tsc --noEmit | tee type-errors.log"
2942
},
3043
"bin": {
31-
"zero-svg": "scripts/index.js"
44+
"zero-icons": "scripts/index.js"
3245
},
3346
"peerDependencies": {
3447
"react": ">=17"

icon-sprite/scripts/build-sprite.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ const store = svgstore({
2626
copyAttrs: ["viewBox", "fill", "stroke", "stroke-width", "stroke-linecap", "stroke-linejoin", "style", "size"],
2727
svgAttrs: {
2828
xmlns: "http://www.w3.org/2000/svg",
29-
"xmlns:xlink": "http://www.w3.org/1999/xlink",
29+
"aria-hidden": "true",
30+
focusable: "false",
3031
},
3132
});
3233
const found = new Set();

0 commit comments

Comments
 (0)