naive-icons 1.2.0 → 1.5.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +96 -160
  3. package/README.zh-CN.md +222 -0
  4. package/dist/index.d.mts +216 -128
  5. package/dist/index.d.ts +216 -128
  6. package/dist/index.js +912 -30
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +878 -31
  9. package/dist/index.mjs.map +1 -1
  10. package/package.json +4 -2
  11. package/skills/README.md +119 -0
  12. package/skills/naive-icons/SKILL.md +167 -0
  13. package/skills/naive-icons/reference/catalog.md +221 -0
  14. package/skills/naive-icons/reference/design-spec.md +156 -0
  15. package/skills/naive-icons/reference/patterns.md +189 -0
  16. package/skills/naive-icons/scripts/emit.py +324 -0
  17. package/skills/naive-icons/scripts/icons.json +161 -0
  18. package/skills/naive-icons/scripts/search.py +485 -0
  19. package/svg/alert-circle.svg +5 -0
  20. package/svg/alert-triangle.svg +5 -0
  21. package/svg/arrow-up-right.svg +5 -0
  22. package/svg/badge-check.svg +5 -0
  23. package/svg/ban.svg +4 -0
  24. package/svg/bell-off.svg +6 -0
  25. package/svg/check-circle.svg +4 -0
  26. package/svg/check-square.svg +4 -0
  27. package/svg/check.svg +1 -1
  28. package/svg/external-link.svg +4 -5
  29. package/svg/eye-off.svg +6 -0
  30. package/svg/filter.svg +4 -0
  31. package/svg/grid.svg +6 -0
  32. package/svg/help-circle.svg +5 -0
  33. package/svg/inbox.svg +4 -0
  34. package/svg/info.svg +5 -0
  35. package/svg/list.svg +8 -0
  36. package/svg/lock-open.svg +6 -0
  37. package/svg/maximize.svg +7 -0
  38. package/svg/more-vertical.svg +5 -0
  39. package/svg/paperclip.svg +3 -0
  40. package/svg/redo.svg +4 -0
  41. package/svg/refresh.svg +4 -2
  42. package/svg/scooter.svg +15 -0
  43. package/svg/send.svg +4 -0
  44. package/svg/shield.svg +4 -0
  45. package/svg/sliders.svg +8 -0
  46. package/svg/sort.svg +6 -0
  47. package/svg/spinner.svg +4 -0
  48. package/svg/undo.svg +4 -0
  49. package/svg/user-plus.svg +8 -0
  50. package/svg/users.svg +9 -0
  51. package/svg/volume-x.svg +4 -0
  52. package/svg/volume.svg +5 -0
  53. package/svg/x-circle.svg +5 -0
  54. package/svg/zoom-in.svg +5 -0
  55. package/svg/zoom-out.svg +5 -0
  56. package/README.en.md +0 -290
package/CHANGELOG.md CHANGED
@@ -2,6 +2,74 @@
2
2
 
3
3
  本文件记录 Naive Icons 的每个版本变更。版本号遵循语义化版本规范(SemVer)。
4
4
 
5
+ ## 1.5.0
6
+
7
+ 新增
8
+
9
+ - 官方 Agent Skill:让 AI 编码助手能按语义检索图标、输出可直接粘贴的代码,并知道这套图标的设计规范
10
+ - 一条命令装好,不用先装本库、不用挑 agent:
11
+
12
+ ```bash
13
+ npx skills add guokaigdg/naive-icons
14
+ ```
15
+
16
+ 会先展示要装的内容再确认,并自动识别本机已装的 agent。
17
+ 可选 Project(跟着仓库走,团队共享)或 Global(装到用户目录),加 `-g` 可跳过该选择。
18
+ - Skill 自带全部 SVG 源码(收在 `scripts/icons.json` 一个文件里),装到哪都能出码,
19
+ 不依赖项目里是否装了本库
20
+ - 脚本只用 Python 标准库,skill 被装到任何位置都能跑
21
+ - 新增 `scripts/build_skill_assets.py`,从 `svg/` 生成 skill 的 `catalog.md` 与
22
+ `icons.json`,并校验 `svg/`、`ICON_CATEGORY`、`ZH_NAMES` 三者一致
23
+
24
+ 修复
25
+
26
+ - 补上 `index.ts` 对类型与色板的转发,`NAIVE_PALETTE`、`IconProps`、`IconName`、
27
+ `IconComponent`、`PaletteColor` 从包入口真正可用了。此前 `src/types.ts` 里都有定义,
28
+ 但入口只导出 159 个图标组件,导致 README 里的
29
+ `import { NAIVE_PALETTE } from 'naive-icons'` 报运行时 `SyntaxError`、
30
+ `import type { IconProps } from 'naive-icons'` 报 `TS2305` / `TS2459`。
31
+ 该问题自 1.0.0 起就存在
32
+ - 两个生成器(`generate_icons.py` / `generate_icons_add.py`)的 `index.ts` 模板同步补上
33
+ 转发,否则下次新增图标时会被全量重建冲掉
34
+
35
+ ## 1.4.0
36
+
37
+ 新增
38
+
39
+ - 新增 25 个图标,图标总数增至 159
40
+ - 界面基础 +11:users、user-plus、more-vertical、check-square、shield、bell-off、sliders、grid、list、ban、badge-check
41
+ - 操作 +7:filter、sort、undo、redo、maximize、zoom-in、zoom-out
42
+ - 文件与媒体 +3:volume、volume-x、paperclip
43
+ - 通信 +2:send、inbox
44
+ - 导航方位 +1:arrow-up-right
45
+ - 交通工具 +1:scooter
46
+ - 撤销 / 重做改为墨色长弧搭配橙色实心箭头的形态,两枚互为镜像,箭头水平朝外
47
+ - 放大 / 缩小改用青色线框镜片加橙色大符号,与 search 的实心镜片彻底区分开
48
+
49
+ 改进
50
+
51
+ - 重绘 refresh 为上下双弧的循环箭头,两段弧各占 120°,上下各留 100° 缺口,弧段与留白接近 1:2
52
+ - external-link 的橙色箭头描边由 3.5 加粗到 4.0,小尺寸下更清晰
53
+ - cart 从「交通工具」重新归入「日常物品」
54
+ - 官网取色器与主题换色改为只替换墨色描边。图标自带的彩色描边(橙色箭头、黄色勾等)本来就是 naive 风格的一部分,此前会被一并刷成单色
55
+
56
+ 修复
57
+
58
+ - 官网深色模式下首次加载时,hero 贴纸改用奶油色描边,不会因墨色与深色底糊在一起而看不见
59
+ - hero 贴纸切换主题时只替换上一个主题色并在颜色未变时跳过,不再逐个重写 DOM
60
+ - 移除图标详情弹窗的左右切换按钮与键盘 ← → 导航,连带删除 step / indexOfCurrent 等死代码
61
+ - 扩充脚本重新生成 package.json 时会剥掉文件末尾的换行,导致凭空多出一行 diff,现已修复
62
+
63
+ ## 1.3.0
64
+
65
+ 新增
66
+
67
+ - 新增 9 个状态 / 反馈图标(alert-circle、alert-triangle、check-circle、eye-off、help-circle、info、lock-open、spinner、x-circle),图标总数增至 134
68
+
69
+ 改进
70
+
71
+ - 微调 check 图标勾形几何,提升小尺寸下的清晰度
72
+
5
73
  ## 1.2.0
6
74
 
7
75
  新增
package/README.md CHANGED
@@ -1,16 +1,14 @@
1
-
2
1
  <h1>Naive Icons</h1>
3
2
 
4
3
  <p align="right">
5
- <a href="./README.md">中文</a> | <a href="./README.en.md">English</a>
4
+ English | <a href="./README.zh-CN.md">中文</a>
6
5
  </p>
7
6
 
8
7
  <p align="center">
9
8
  <img src="assets/logo.svg" alt="Naive Icons" width="132" height="132">
10
9
  </p>
11
10
 
12
-
13
- <p align="center">手绘 naive folk art 风格的 SVG 图标库,为 React 与 TypeScript 打造</p>
11
+ <p align="center">Hand-drawn "naive folk art" style SVG icon library, built for React and TypeScript</p>
14
12
 
15
13
  <p align="center">
16
14
  <a href="https://github.com/guokaigdg/naive-icons/stargazers"><img src="https://img.shields.io/github/stars/guokaigdg/naive-icons?style=flat-square&color=E9C46A" alt="GitHub stars"></a>
@@ -23,42 +21,46 @@
23
21
  <img src="https://img.shields.io/badge/SVG-FFB13B?style=flat-square&logoColor=black" alt="SVG">
24
22
  </p>
25
23
 
26
- Naive Icons 是一套手绘 naive folk art 风格的 SVG 图标库,为 React 与 TypeScript 打造。全部 125 个图标由 AI 生成,均为原创作品。
24
+ <p align="center">
25
+ <b>🤖 AI Agent Skill</b> — install it into Claude Code, Cursor, Codex and friends,<br/>
26
+ and they can pick icons by meaning, emit ready-to-paste code, and know the design rules.<br/>
27
+ <code>npx skills add guokaigdg/naive-icons</code> &nbsp;·&nbsp; <a href="#ai-agent-skill">See details &rarr;</a>
28
+ </p>
29
+
30
+ Each icon is drawn on a 48x48 grid with a 3.5 stroke, rounded line caps, and a retro palette — keeping the charming clumsiness and warmth of hand-drawn illustration. Some icons even feature a pair of dot eyes and a little smile, adding a touch of humanity to your interface.
27
31
 
28
- 每一个图标都建立在 48x48 的网格上,使用 3.5 的粗描边、圆角线帽与统一的复古调色板,并保留了手绘插画特有的笨拙感与温度——部分图标还带有一对小圆点眼睛和微笑,让界面多一点点人情味。
32
+ ## Features
29
33
 
30
- - 图标数量:125
31
- - 单个体积:约 400 至 700 字节
32
- - 依赖:零运行时依赖,仅 peer 依赖 React
33
- - 许可证:MIT
34
+ - Icons spanning 11 categories: interface, actions, media, navigation, animals, food, and more
35
+ - Every icon ships as both an SVG source file and a React TSX component
36
+ - Full TypeScript types: IconProps, IconName, IconComponent, NAIVE_PALETTE
37
+ - Supports `currentColor` to follow the surrounding text color
38
+ - Official Agent Skill: one command installs it into your AI coding agent, which can then pick icons by meaning and emit ready-to-paste code
39
+
40
+ ## AI Agent Skill
41
+
42
+ Install it into your AI coding agent (Claude Code, Cursor, Codex, …) and it can pick icons by
43
+ meaning, emit ready-to-paste code, and know this library's design rules.
44
+
45
+ ```bash
46
+ npx skills add guokaigdg/naive-icons
47
+ ```
34
48
 
35
- ## 目录
49
+ You do not need to install the package first. **Start a new session** afterwards,
50
+ then just ask:
36
51
 
37
- - [特性](#特性)
38
- - [安装](#安装)
39
- - [快速开始](#快速开始)
40
- - [组件属性](#组件属性)
41
- - [直接使用 SVG](#直接使用-svg)
42
- - [调色板](#调色板)
43
- - [图标清单](#图标清单)
44
- - [设计原则](#设计原则)
45
- - [目录结构](#目录结构)
46
- - [本地开发](#本地开发)
47
- - [浏览器支持](#浏览器支持)
48
- - [许可证](#许可证)
52
+ - "Give this login page a set of naive icons"
53
+ - "Find an icon that means 'already read'"
49
54
 
50
- ## 特性
55
+ The skill bundles the full icon catalog, the design spec, usage patterns and every SVG source
56
+ file, so the agent can generate code even when the package isn't installed in your project.
57
+ Re-run the same command after upgrading the library to update it.
51
58
 
52
- - 125 个手绘风格的原创 SVG 图标,覆盖界面、操作、媒体、导航、动物、食物等 11 个分类
53
- - 统一规格:48x48 viewBox、3.5 描边宽度、round 线帽与线角
54
- - 统一调色板:9 色复古配色,可作为设计令牌直接引用
55
- - 部分图标带有圆点眼睛与微笑表情,风格辨识度高
56
- - 每个图标同时提供 SVG 源文件与 React TSX 组件
57
- - 完整 TypeScript 类型:IconProps、IconName、IconCategory、NAIVE_PALETTE
58
- - 透明背景、无渐变、无外部字体依赖
59
- - 支持 currentColor,可跟随文字颜色自动变化
59
+ > Installing the skill and using the components are separate things. You only need
60
+ > `npm install naive-icons` from the Installation section below when you actually want to
61
+ > `import { HomeIcon } from 'naive-icons'` in your own code.
60
62
 
61
- ## 安装
63
+ ## Installation
62
64
 
63
65
  ```bash
64
66
  npm install naive-icons
@@ -72,9 +74,9 @@ yarn add naive-icons
72
74
  pnpm add naive-icons
73
75
  ```
74
76
 
75
- Naive Icons 只依赖 React,支持 React 16.8 及以上版本(含 React 18 与 19)。
77
+ Naive Icons only depends on React and supports React 16.8 and above (including React 18 and 19).
76
78
 
77
- ## 快速开始
79
+ ## Quick Start
78
80
 
79
81
  ```tsx
80
82
  import { HomeIcon, HeartIcon, PenguinIcon } from 'naive-icons';
@@ -90,39 +92,41 @@ export function Example() {
90
92
  }
91
93
  ```
92
94
 
93
- 按需引入可以进一步减小打包体积:
95
+ Tree-shaking works out of the box: the package is ESM and sets `sideEffects: false`, so a
96
+ named import is all you need.
94
97
 
95
98
  ```tsx
96
- import HomeIcon from 'naive-icons/src/HomeIcon';
99
+ import { HomeIcon, SearchIcon } from 'naive-icons';
97
100
  ```
98
101
 
99
- 配合 currentColor 使用,图标会自动继承父级文字颜色:
102
+ To follow the parent text color, pass `currentColor` explicitly — the default is ink `#2A2A2A`
103
+ and is **not** inherited automatically:
100
104
 
101
105
  ```tsx
102
106
  <span style={{ color: '#264653' }}>
103
- <HomeIcon size={20} />
104
- 首页
107
+ <HomeIcon size={20} color="currentColor" />
108
+ Home
105
109
  </span>
106
110
  ```
107
111
 
108
- 添加无障碍标题:
112
+ Add an accessibility title:
109
113
 
110
114
  ```tsx
111
- <HomeIcon size={24} title="返回首页" />
115
+ <HomeIcon size={24} title="Back to home" />
112
116
  ```
113
117
 
114
- ## 组件属性
118
+ ## Component Props
115
119
 
116
- Naive Icons 的每个组件都继承原生 `SVGProps<SVGSVGElement>`,可以直接传入 `className`、`onClick`、`style` 等任意 SVG 属性。
120
+ Every Naive Icon component extends the native `SVGProps<SVGSVGElement>`, so you can pass any SVG attribute directly, such as `className`, `onClick`, or `style`.
117
121
 
118
- | 属性 | 类型 | 默认值 | 说明 |
122
+ | Prop | Type | Default | Description |
119
123
  | --- | --- | --- | --- |
120
- | size | number \| string | 24 | 图标尺寸,宽高相等。传入后覆盖 width 与 height |
121
- | color | string | currentColor | 描边颜色 |
122
- | strokeWidth | number \| string | 3.5 | 描边宽度,按 48x48 画布比例缩放 |
123
- | fill | string | none | 填充色 |
124
- | title | string | — | 无障碍标题,渲染为 SVG title 节点 |
125
- | width / height | number \| string | 跟随 size | 单独指定宽或高 |
124
+ | size | number \| string | 24 | Icon size, equal width and height. Overrides width and height when set |
125
+ | color | string | `#2A2A2A` | Stroke color. Pass `currentColor` to follow the surrounding text color |
126
+ | strokeWidth | number \| string | 3.5 | Stroke width, scaled to the 48x48 canvas |
127
+ | fill | string | none | Fill color |
128
+ | title | string | — | Accessibility title, rendered as an SVG title node |
129
+ | width / height | number \| string | follows size | Set width or height individually |
126
130
 
127
131
  ```typescript
128
132
  import type { IconProps } from 'naive-icons';
@@ -136,110 +140,54 @@ interface IconProps extends SVGProps<SVGSVGElement> {
136
140
  }
137
141
  ```
138
142
 
139
- ## 直接使用 SVG
143
+ ## Using the SVG Directly
140
144
 
141
- 如果项目不是 React,可以直接使用 `svg/` 目录下的源文件。所有 SVG 都是自包含的,没有外部引用。
145
+ If your project isn't React, you can use the source files in the `svg/` directory. Every SVG is self-contained with no external references.
142
146
 
143
147
  ```html
144
- <img src="naive-icons/svg/home.svg" width="24" height="24" alt="首页" />
148
+ <img src="naive-icons/svg/home.svg" width="24" height="24" alt="Home" />
145
149
  ```
146
150
 
147
- 内联使用时,把 `stroke="#2A2A2A"` 替换为 `stroke="currentColor"` 即可跟随文字颜色:
151
+ To follow the surrounding text color when inlining, replace `stroke="#2A2A2A"` with `stroke="currentColor"`:
148
152
 
149
153
  ```html
150
154
  <svg viewBox="0 0 48 48" width="24" height="24" fill="none"
151
155
  stroke="currentColor" stroke-width="3.5"
152
156
  stroke-linecap="round" stroke-linejoin="round">
153
- <!-- 复制 svg/home.svg 中的 path 内容 -->
157
+ <!-- Copy the path content from svg/home.svg -->
154
158
  </svg>
155
159
  ```
156
160
 
157
- 也可以做成 SVG sprite 或 Icon Font,源文件结构足够简单,便于二次加工。
161
+ You can also build an SVG sprite or icon font — the source files are simple enough to work with.
158
162
 
159
- ## 调色板
163
+ ## Palette
160
164
 
161
165
  ```typescript
162
166
  import { NAIVE_PALETTE } from 'naive-icons';
163
167
  ```
164
168
 
165
- | 名称 | 色值 | 用途 |
169
+ | Name | Value | Usage |
166
170
  | --- | --- | --- |
167
- | ink | #2A2A2A | 主描边色 |
168
- | navy | #264653 | 深色主体 |
169
- | orange | #E76F51 | 强调色 |
170
- | yellow | #E9C46A | 暖色填充 |
171
- | pink | #F4A6A4 | 柔和填充 |
172
- | green | #588157 | 自然元素 |
173
- | teal | #2A9D8F | 辅助色 |
174
- | brown | #8B5E3C | 木质与土地 |
175
- | cream | #FAEDCD | 浅色底 |
176
-
177
- ## 图标清单
178
-
179
- **界面基础**(18)
180
- home, user, settings, search, heart, star, bell, calendar, clock, eye, bulb, tag, bookmark, menu, ellipsis, external-link, link, unlink
181
-
182
- **操作**(15)
183
- edit, trash, download, upload, save, plus, close, check, refresh, share, play, pause, stop, copy, minus
184
-
185
- **文件与媒体**(10)
186
- file, folder, image, camera, video, mic, music, code, book, headphones
187
-
188
- **导航方位**(14)
189
- location, compass, map, flag, anchor, magnet, arrow-up, arrow-down, arrow-left, arrow-right, chevron-down, chevron-up, chevron-left, chevron-right
190
-
191
- **通信**(4)
192
- mail, chat, phone, wifi
193
-
194
- **自然天气**(14)
195
- sun, moon, cloud, umbrella, tree, mountain, tent, flower, leaf, rainbow, mushroom, cactus, snowflake, flame
196
-
197
- **动物**(14)
198
- cat, dog, bird, fish, penguin, rabbit, bear, fox, owl, frog, bee, butterfly, snail, ladybug
171
+ | ink | #2A2A2A | Primary stroke |
172
+ | navy | #264653 | Dark main body |
173
+ | orange | #E76F51 | Accent |
174
+ | yellow | #E9C46A | Warm fill |
175
+ | pink | #F4A6A4 | Soft fill |
176
+ | green | #588157 | Natural elements |
177
+ | teal | #2A9D8F | Secondary |
178
+ | brown | #8B5E3C | Wood and earth |
179
+ | cream | #FAEDCD | Light background |
199
180
 
200
- **食物饮品**(11)
201
- apple, strawberry, watermelon, cherry, lemon, cake, icecream, donut, coffee, coffee-cup, water-cup
181
+ ## Design Principles
202
182
 
203
- **日常物品**(16)
204
- balloon, basketball, dumbbell, lamp, candle, pencil, paintbrush, globe, google-chrome, trophy, shopping-bag, credit-card, gift, thermometer, lock, key
183
+ Naive Icons follows four fixed rules. They should be respected when adding new icons.
205
184
 
206
- **交通工具**(7)
207
- car, airplane, rocket, cart, bicycle, sailboat, train
185
+ 1. **Grid & bleed**: All graphics are drawn on a 48x48 canvas, keeping at least 3 units between the main body and the canvas edge.
186
+ 2. **Stroke**: A unified 3.5 width with round caps and joins, and no dashed lines.
187
+ 3. **Color**: The 9 palette colors set the default tone; other solid colors are allowed when genuinely needed (e.g. brand colors) — no gradients, shadows, or semi-transparent overlays.
188
+ 4. **Personality**: Slight asymmetry is welcome; encourage dot eyes and a smile on living subjects to keep the hand-drawn clumsiness.
208
189
 
209
- **表情**(2)
210
- smile, thumbs-up
211
-
212
- 图标文件名使用 kebab-case(如 `shopping-bag.svg`、`thumbs-up.svg`),React 组件名使用 PascalCase 并带 Icon 后缀(如 `ShoppingBagIcon`、`ThumbsUpIcon`)。
213
-
214
- ## 设计原则
215
-
216
- Naive Icons 遵循四条固定规则,新增图标时也应保持一致。
217
-
218
- 1. **网格与出血**:全部图形绘制在 48x48 画布内,主体距离画布边缘至少保留 3 个单位。
219
- 2. **描边**:统一 3.5 宽度,端点与转角均为 round,不使用虚线。
220
- 3. **配色**:只使用调色板中的 9 个颜色,不使用渐变、阴影与半透明叠加。
221
- 4. **性格**:允许线条轻微不对称,鼓励给有生命的图形加上圆点眼睛与微笑,保留手绘的笨拙感。
222
-
223
- ## 目录结构
224
-
225
- ```
226
- naive-icons/
227
- ├── svg/ 125 个 SVG 源文件
228
- ├── src/ 125 个 React TSX 组件 + index.ts + types.ts
229
- ├── assets/ 品牌资源(logo)
230
- ├── scripts/ 图标生成与预览构建脚本
231
- ├── website/ 官方文档站点
232
- ├── dist/ 构建产物(ESM + CJS + 类型声明,不纳入版本控制)
233
- ├── tsup.config.ts 构建配置
234
- ├── tsconfig.json
235
- ├── LICENSE
236
- ├── README.md
237
- ├── CHANGELOG.md
238
- ├── CONTRIBUTING.md
239
- └── package.json
240
- ```
241
-
242
- ## 本地开发
190
+ ## Local Development
243
191
 
244
192
  ```bash
245
193
  git clone https://github.com/guokaigdg/naive-icons.git
@@ -247,45 +195,33 @@ cd naive-icons
247
195
  npm install
248
196
  ```
249
197
 
250
- 常用脚本:
198
+ Common scripts:
251
199
 
252
200
  ```bash
253
- npm run build # 用 tsup 构建 dist(ESM + CJS + 类型声明)
254
- npm run dev # 监听模式构建
255
- npm run typecheck # 类型检查
256
- npm run website # 本地预览官网(Python 静态服务器,端口 8080)
257
- npm run icons:build # 依据 scripts 中的定义重新生成 SVG 与 TSX
258
- npm run icons:add # 增量新增图标,不覆盖已有文件
201
+ npm run build # Build dist with tsup (ESM + CJS + type declarations)
202
+ npm run dev # Watch mode build
203
+ npm run typecheck # Type check
204
+ npm run website # Preview the site locally (Python static server, port 8080)
205
+ npm run icons:build # Regenerate SVG and TSX from script definitions
206
+ npm run icons:add # Incrementally add icons without overwriting existing files
259
207
  ```
260
208
 
261
- 发布时 `prepublishOnly` 会自动执行构建,无需手动运行 `npm run build`。
209
+ `prepublishOnly` runs the build automatically on publish, so there is no need to run `npm run build` manually.
262
210
 
263
- 构建产物为 `dist/index.mjs`(ESM)、`dist/index.js`(CJS)与 `dist/index.d.ts` / `dist/index.d.mts`(类型声明),`package.json` 的 `exports` 已按 `import` / `require` 条件分别指向对应文件。React 被声明为 external,不会被打进产物。
211
+ The build output is `dist/index.mjs` (ESM), `dist/index.js` (CJS), and `dist/index.d.ts` / `dist/index.d.mts` (type declarations). The `exports` field in `package.json` points to the correct file for each `import` / `require` condition. React is declared as external and is not bundled.
264
212
 
265
- 官网是纯静态站点(无构建、无依赖),直接打开 `website/index.html` 也能用:浏览全部图标、按分类筛选、搜索、实时调整尺寸与描边颜色、切换浅色/深色/网格预览底,点击任意图标可查看 React 用法、复制代码或下载 SVG。支持浅色 / 深色主题(跟随系统、可手动切换并记忆),弹窗内可用方向键连续切换图标。
213
+ The website is a fully static site (no build step, no dependencies). You can open `website/index.html` directly: browse all icons, filter by category, search, adjust size and stroke color live, switch between light/dark/grid preview backgrounds, and click any icon to view React usage, copy code, or download the SVG. It supports light/dark themes (follows the system, with manual toggle remembered) and lets you navigate between icons with arrow keys in the modal.
266
214
 
267
- ## 字体
215
+ ## Browser Support
268
216
 
269
- 图标库本体(SVG 与 React 组件)不依赖任何字体。官网额外引入一款手写感字体用于标题与正文:[LXGW 悠哉字体](https://github.com/lxgw/yozai-font)(SIL Open Font License 1.1,可自由商用)。
270
-
271
- 官网自托管方式:仅打包站内实际用到的字符(约 715 个,常规字重约 170 KB),完全离线可用,文件位于 `website/assets/fonts/`。如需自行重新生成子集,运行:
272
-
273
- ```bash
274
- python3 scripts/subset_fonts.py
275
- ```
276
-
277
- 依赖 `fonttools` 与 `brotli`:
278
-
279
- ```bash
280
- pip install fonttools brotli
281
- ```
217
+ Naive Icons outputs standard SVG 1.1 and supports all modern browsers (the last two major versions of Chrome, Firefox, Safari, and Edge). The React components contain no browser-specific APIs and can be safely used in server-side rendering environments.
282
218
 
283
- ## 浏览器支持
219
+ ## License
284
220
 
285
- Naive Icons 输出的是标准 SVG 1.1,支持所有现代浏览器(Chrome、Firefox、Safari、Edge 最近两个大版本)。React 组件不含任何浏览器专有 API,可在服务端渲染环境中安全使用。
221
+ MIT License. See [LICENSE](./LICENSE).
286
222
 
287
- ## 许可证
223
+ All icons are original works, free to use in personal and commercial projects without attribution.
288
224
 
289
- MIT License。详见 [LICENSE](./LICENSE)。
225
+ ## Sponsor
290
226
 
291
- 全部图标均为原创作品,可自由用于个人与商业项目,无需署名。
227
+ If this project has been helpful, consider treating the developer's cat to a can of food — after all, there's a cat supervising the code behind every icon. <a href="https://guokaigdg.github.io/home/payment.html">Feed the cat a can</a>
@@ -0,0 +1,222 @@
1
+ <h1>Naive Icons</h1>
2
+
3
+ <p align="right">
4
+ <a href="./README.md">English</a> | 中文
5
+ </p>
6
+
7
+ <p align="center">
8
+ <img src="assets/logo.svg" alt="Naive Icons" width="132" height="132">
9
+ </p>
10
+
11
+ <p align="center">手绘 naive folk art 风格的 SVG 图标库,为 React 与 TypeScript 打造</p>
12
+
13
+ <p align="center">
14
+ <a href="https://github.com/guokaigdg/naive-icons/stargazers"><img src="https://img.shields.io/github/stars/guokaigdg/naive-icons?style=flat-square&color=E9C46A" alt="GitHub stars"></a>
15
+ <a href="https://www.npmjs.com/package/naive-icons"><img src="https://img.shields.io/npm/v/naive-icons?style=flat-square&color=E76F51" alt="npm version"></a>
16
+ <a href="https://www.npmjs.com/package/naive-icons"><img src="https://img.shields.io/npm/dm/naive-icons?style=flat-square&color=2A9D8F" alt="npm downloads"></a>
17
+ <a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-264653?style=flat-square" alt="license: MIT"></a>
18
+ <br/>
19
+ <img src="https://img.shields.io/badge/React-61DAFB?style=flat-square&logo=react&logoColor=black" alt="React">
20
+ <img src="https://img.shields.io/badge/TypeScript-3178C6?style=flat-square&logo=typescript&logoColor=white" alt="TypeScript">
21
+ <img src="https://img.shields.io/badge/SVG-FFB13B?style=flat-square&logoColor=black" alt="SVG">
22
+ </p>
23
+
24
+ <p align="center">
25
+ <b>🤖 AI Agent Skill</b> — 给 Claude Code / Cursor / Codex 等 AI 编码助手装一份,<br/>
26
+ 它就能按语义帮你挑图标、生成可直接粘贴的代码,并且知道这套图标的设计规范。<br/>
27
+ <code>npx skills add guokaigdg/naive-icons</code> &nbsp;·&nbsp; <a href="#ai-agent-skill">看详情 &rarr;</a>
28
+ </p>
29
+
30
+ 每一个图标都建立在 48x48 的网格上,使用 3.5 的粗描边、圆角线帽与复古调色板,并保留了手绘插画特有的笨拙感与温度——部分图标还带有一对小圆点眼睛和微笑,让界面多一点点人情味。
31
+
32
+ ## 特性
33
+
34
+ - 图标覆盖界面、操作、媒体、导航、动物、食物等 11 个分类
35
+ - 每个图标同时提供 SVG 源文件与 React TSX 组件
36
+ - 完整 TypeScript 类型:IconProps、IconName、IconComponent、NAIVE_PALETTE
37
+ - 支持 currentColor,传入后图标跟随文字颜色
38
+ - 官方 Agent Skill:一条命令装到 AI 编码助手,按语义帮你挑图标并生成代码
39
+
40
+ ## AI Agent Skill
41
+
42
+ 给 AI 编码助手(Claude Code、Cursor、Codex 等)装一份,它就能按语义帮你挑图标、
43
+ 生成可直接粘贴的代码,并且知道这套图标的设计规范。
44
+
45
+ ```bash
46
+ npx skills add guokaigdg/naive-icons
47
+ ```
48
+
49
+ 不用先装本库。装完**新开会话**,然后直接说:
50
+
51
+ - 「用 naive 图标给这个登录页配一套图标」
52
+ - 「找个表示『已读』的图标」
53
+
54
+ Skill 自带完整图标目录、设计规范和用法,以及全部 SVG 源码,助手生成代码不依赖项目里
55
+ 是否装了本库。库升级后重跑同一条命令即可更新。
56
+
57
+ > 装 skill 和用组件是两件事。要在代码里 `import { HomeIcon } from 'naive-icons'`,
58
+ > 才需要下面「安装」里的 `npm install naive-icons`。
59
+
60
+ ## 安装
61
+
62
+ ```bash
63
+ npm install naive-icons
64
+ ```
65
+
66
+ ```bash
67
+ yarn add naive-icons
68
+ ```
69
+
70
+ ```bash
71
+ pnpm add naive-icons
72
+ ```
73
+
74
+ Naive Icons 只依赖 React,支持 React 16.8 及以上版本(含 React 18 与 19)。
75
+
76
+ ## 快速开始
77
+
78
+ ```tsx
79
+ import { HomeIcon, HeartIcon, PenguinIcon } from 'naive-icons';
80
+
81
+ export function Example() {
82
+ return (
83
+ <nav>
84
+ <HomeIcon size={24} />
85
+ <HeartIcon size={24} color="#E76F51" />
86
+ <PenguinIcon size={48} strokeWidth={4} />
87
+ </nav>
88
+ );
89
+ }
90
+ ```
91
+
92
+ 按需引入:包是 ESM 且标记了 `sideEffects: false`,用具名导入即可,打包器会自动 tree-shaking:
93
+
94
+ ```tsx
95
+ import { HomeIcon, SearchIcon } from 'naive-icons';
96
+ ```
97
+
98
+ 想跟随父级文字颜色,显式传 `currentColor`(默认是墨色 `#2A2A2A`,不会自动继承):
99
+
100
+ ```tsx
101
+ <span style={{ color: '#264653' }}>
102
+ <HomeIcon size={20} color="currentColor" />
103
+ 首页
104
+ </span>
105
+ ```
106
+
107
+ 添加无障碍标题:
108
+
109
+ ```tsx
110
+ <HomeIcon size={24} title="返回首页" />
111
+ ```
112
+
113
+ ## 组件属性
114
+
115
+ Naive Icons 的每个组件都继承原生 `SVGProps<SVGSVGElement>`,可以直接传入 `className`、`onClick`、`style` 等任意 SVG 属性。
116
+
117
+ | 属性 | 类型 | 默认值 | 说明 |
118
+ | --- | --- | --- | --- |
119
+ | size | number \| string | 24 | 图标尺寸,宽高相等。传入后覆盖 width 与 height |
120
+ | color | string | `#2A2A2A` | 描边颜色。传 `currentColor` 可跟随父级文字颜色 |
121
+ | strokeWidth | number \| string | 3.5 | 描边宽度,按 48x48 画布比例缩放 |
122
+ | fill | string | none | 填充色 |
123
+ | title | string | — | 无障碍标题,渲染为 SVG title 节点 |
124
+ | width / height | number \| string | 跟随 size | 单独指定宽或高 |
125
+
126
+ ```typescript
127
+ import type { IconProps } from 'naive-icons';
128
+
129
+ interface IconProps extends SVGProps<SVGSVGElement> {
130
+ size?: number | string;
131
+ color?: string;
132
+ strokeWidth?: number | string;
133
+ fill?: string;
134
+ title?: string;
135
+ }
136
+ ```
137
+
138
+ ## 直接使用 SVG
139
+
140
+ 如果项目不是 React,可以直接使用 `svg/` 目录下的源文件。所有 SVG 都是自包含的,没有外部引用。
141
+
142
+ ```html
143
+ <img src="naive-icons/svg/home.svg" width="24" height="24" alt="首页" />
144
+ ```
145
+
146
+ 内联使用时,把 `stroke="#2A2A2A"` 替换为 `stroke="currentColor"` 即可跟随文字颜色:
147
+
148
+ ```html
149
+ <svg viewBox="0 0 48 48" width="24" height="24" fill="none"
150
+ stroke="currentColor" stroke-width="3.5"
151
+ stroke-linecap="round" stroke-linejoin="round">
152
+ <!-- 复制 svg/home.svg 中的 path 内容 -->
153
+ </svg>
154
+ ```
155
+
156
+ 也可以做成 SVG sprite 或 Icon Font,源文件结构足够简单,便于二次加工。
157
+
158
+ ## 调色板
159
+
160
+ ```typescript
161
+ import { NAIVE_PALETTE } from 'naive-icons';
162
+ ```
163
+
164
+ | 名称 | 色值 | 用途 |
165
+ | --- | --- | --- |
166
+ | ink | #2A2A2A | 主描边色 |
167
+ | navy | #264653 | 深色主体 |
168
+ | orange | #E76F51 | 强调色 |
169
+ | yellow | #E9C46A | 暖色填充 |
170
+ | pink | #F4A6A4 | 柔和填充 |
171
+ | green | #588157 | 自然元素 |
172
+ | teal | #2A9D8F | 辅助色 |
173
+ | brown | #8B5E3C | 木质与土地 |
174
+ | cream | #FAEDCD | 浅色底 |
175
+
176
+ ## 设计原则
177
+
178
+ Naive Icons 遵循四条固定规则,新增图标时也应保持一致。
179
+
180
+ 1. **网格与出血**:全部图形绘制在 48x48 画布内,主体距离画布边缘至少保留 3 个单位。
181
+ 2. **描边**:统一 3.5 宽度,端点与转角均为 round,不使用虚线。
182
+ 3. **配色**:以调色板的 9 色为默认基调,确有必要时可用其他实色(如品牌色),不使用渐变、阴影与半透明叠加。
183
+ 4. **性格**:允许线条轻微不对称,鼓励给有生命的图形加上圆点眼睛与微笑,保留手绘的笨拙感。
184
+
185
+ ## 本地开发
186
+
187
+ ```bash
188
+ git clone https://github.com/guokaigdg/naive-icons.git
189
+ cd naive-icons
190
+ npm install
191
+ ```
192
+
193
+ 常用脚本:
194
+
195
+ ```bash
196
+ npm run build # 用 tsup 构建 dist(ESM + CJS + 类型声明)
197
+ npm run dev # 监听模式构建
198
+ npm run typecheck # 类型检查
199
+ npm run website # 本地预览官网(Python 静态服务器,端口 8080)
200
+ npm run icons:build # 依据 scripts 中的定义重新生成 SVG 与 TSX
201
+ npm run icons:add # 增量新增图标,不覆盖已有文件
202
+ ```
203
+
204
+ 发布时 `prepublishOnly` 会自动执行构建,无需手动运行 `npm run build`。
205
+
206
+ 构建产物为 `dist/index.mjs`(ESM)、`dist/index.js`(CJS)与 `dist/index.d.ts` / `dist/index.d.mts`(类型声明),`package.json` 的 `exports` 已按 `import` / `require` 条件分别指向对应文件。React 被声明为 external,不会被打进产物。
207
+
208
+ 官网是纯静态站点(无构建、无依赖),直接打开 `website/index.html` 也能用:浏览全部图标、按分类筛选、搜索、实时调整尺寸与描边颜色、切换浅色/深色/网格预览底,点击任意图标可查看 React 用法、复制代码或下载 SVG。支持浅色 / 深色主题(跟随系统、可手动切换并记忆),弹窗内可用方向键连续切换图标。
209
+
210
+ ## 浏览器支持
211
+
212
+ Naive Icons 输出的是标准 SVG 1.1,支持所有现代浏览器(Chrome、Firefox、Safari、Edge 最近两个大版本)。React 组件不含任何浏览器专有 API,可在服务端渲染环境中安全使用。
213
+
214
+ ## 许可证
215
+
216
+ MIT License。详见 [LICENSE](./LICENSE)。
217
+
218
+ 全部图标均为原创作品,可自由用于个人与商业项目,无需署名。
219
+
220
+ ## 赞助
221
+
222
+ 如果这个项目对你有帮助,不妨请开发者的猫吃个罐罐——毕竟每个图标背后都有一只猫在监督代码。<a href="https://guokaigdg.github.io/home/payment.html">请猫吃个罐罐</a>