@kerf-js/veneer-icons 0.0.0-stage → 0.1.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/LICENSE +16 -0
- package/README.md +431 -2
- package/compile.mjs +392 -0
- package/package.json +50 -3
- package/plugin.mjs +59 -0
- package/src/action.tsx +18 -0
- package/src/all.tsx +12 -0
- package/src/compile-catalog.mjs +96 -0
- package/src/compile-closest.mjs +19 -0
- package/src/compile-names.mjs +33 -0
- package/src/compile-pascal.mjs +4 -0
- package/src/compile-read.mjs +227 -0
- package/src/compile-resolver.mjs +169 -0
- package/src/compile-rewrite-pack.mjs +39 -0
- package/src/compile-unwrap.mjs +19 -0
- package/src/gen/actions/bell.css +9 -0
- package/src/gen/actions/bell.tsx +6 -0
- package/src/gen/actions/check.css +10 -0
- package/src/gen/actions/check.tsx +6 -0
- package/src/gen/actions/copy.css +9 -0
- package/src/gen/actions/copy.tsx +6 -0
- package/src/gen/actions/refresh.css +11 -0
- package/src/gen/actions/refresh.tsx +6 -0
- package/src/gen/actions/trash.css +9 -0
- package/src/gen/actions/trash.tsx +6 -0
- package/src/gen/all-accessibility-bus.tsx +274 -0
- package/src/gen/all-cake-cursor.tsx +284 -0
- package/src/gen/all-database-funnel.tsx +276 -0
- package/src/gen/all-gallery-logout.tsx +252 -0
- package/src/gen/all-magnet-puzzle.tsx +285 -0
- package/src/gen/all-qr-syringe.tsx +328 -0
- package/src/gen/all-tab-zoom.tsx +280 -0
- package/src/gen/all.tsx +15 -0
- package/src/gen/index.tsx +5 -0
- package/src/gen/names.ts +6 -0
- package/src/icon.tsx +31 -0
- package/src/icons.css +42 -0
- package/src/late.tsx +70 -0
- package/src/lookup.tsx +10 -0
- package/src/names.tsx +12 -0
- package/src/set.tsx +16 -0
- package/src/svg.tsx +50 -0
- package/src/tiers.css +16 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ravonus
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
6
|
+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
|
7
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
8
|
+
persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
|
11
|
+
Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
|
14
|
+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
15
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
16
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,432 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://github.com/Ravonus/kerf">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/Ravonus/kerf/main/site/public/logo.svg" width="88" height="88" alt="Kerf">
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
<h1 align="center">@kerf-js/veneer-icons</h1>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<strong>651 original icons for Kerf, in Veneer's three expression tiers, each with a hollow and a solid form.</strong><br>
|
|
11
|
+
The build ships only the icons your code names, and a misspelt name fails the build with the closest match.
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="https://www.npmjs.com/package/@kerf-js/veneer-icons"><img src="https://img.shields.io/npm/v/@kerf-js/veneer-icons?color=145c3c&label=npm" alt="npm version"></a>
|
|
16
|
+
<a href="https://github.com/Ravonus/kerf/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-145c3c" alt="MIT license"></a>
|
|
17
|
+
<a href="https://github.com/Ravonus/kerf/actions"><img src="https://img.shields.io/github/actions/workflow/status/Ravonus/kerf/quality.yml?branch=main&label=checks" alt="checks"></a>
|
|
18
|
+
<img src="https://img.shields.io/badge/icons-651-145c3c" alt="651 icons">
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
<a href="#quick-start">Quick start</a> ·
|
|
23
|
+
<a href="https://github.com/Ravonus/kerf/tree/main/docs">Docs</a> ·
|
|
24
|
+
<a href="https://github.com/Ravonus/kerf/tree/main/examples">Examples</a> ·
|
|
25
|
+
<a href="https://github.com/Ravonus/kerf/blob/main/CHANGELOG.md">Changelog</a> ·
|
|
26
|
+
<a href="https://github.com/Ravonus/kerf">GitHub</a>
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
> [!IMPORTANT]
|
|
30
|
+
> **Early release (0.1.x).** APIs can change between minor versions. Pin the version and read the
|
|
31
|
+
> [changelog](https://github.com/Ravonus/kerf/blob/main/CHANGELOG.md) before you upgrade.
|
|
32
|
+
|
|
33
|
+
veneer-icons is Kerf's own icon set. Every icon is drawn three times, once per Veneer expression tier: a thin outline at
|
|
34
|
+
`quiet`, a heavier outline with dither shading at `balanced`, and pixel art on a 16×16 grid at `vivid`. Each tier has a
|
|
35
|
+
hollow and a solid form, drawn apart rather than one filled from the other. CSS shows the tier that matches the page,
|
|
36
|
+
with no script.
|
|
37
|
+
|
|
38
|
+
[`@kerf-js/veneer`](https://www.npmjs.com/package/@kerf-js/veneer) <sup>[source](https://github.com/Ravonus/kerf/tree/main/packages/veneer)</sup> depends on it, so an app with Veneer already
|
|
39
|
+
has it. It also works on its own in any Kerf app.
|
|
40
|
+
|
|
41
|
+
## Highlights
|
|
42
|
+
|
|
43
|
+
- **Original art, MIT licensed.** Nothing is copied, traced or adapted from another set, and nothing carries another
|
|
44
|
+
set's licence. The source art is in this repo.
|
|
45
|
+
- **Pay per icon.** An icon you don't import costs nothing; one you do adds about 164 B of brotli with all three tiers.
|
|
46
|
+
- **Typed names, checked at build.** `<Icon name>` is typed. In untyped code the build and `kerf check` report a wrong
|
|
47
|
+
name as I001 with the closest real one.
|
|
48
|
+
- **Dynamic names still work.** A name only known at run time loads the pack as its own lazy chunk, or single SVG
|
|
49
|
+
files from a URL you choose.
|
|
50
|
+
- **Accessible by default.** Icons are decorative (`aria-hidden`) until you give one a `label`, which makes it
|
|
51
|
+
`role="img"` with that name.
|
|
52
|
+
- **Five icons that move.** `trash`, `bell`, `check`, `refresh` and `copy` have CSS-only animations that respect reduced
|
|
53
|
+
motion.
|
|
54
|
+
|
|
55
|
+
## Contents
|
|
56
|
+
|
|
57
|
+
- [Install](#install)
|
|
58
|
+
- [Quick start](#quick-start)
|
|
59
|
+
- [Guide](#guide)
|
|
60
|
+
- [Three ways to import](#three-ways-to-import)
|
|
61
|
+
- [Props](#props)
|
|
62
|
+
- [Names and variants](#names-and-variants)
|
|
63
|
+
- [How names are resolved](#how-names-are-resolved)
|
|
64
|
+
- [Names from data](#names-from-data)
|
|
65
|
+
- [Tiers](#tiers)
|
|
66
|
+
- [Action icons](#action-icons)
|
|
67
|
+
- [Styling](#styling)
|
|
68
|
+
- [The set](#the-set)
|
|
69
|
+
- [How the icons are made](#how-the-icons-are-made)
|
|
70
|
+
- [API reference](#api-reference)
|
|
71
|
+
- [Troubleshooting](#troubleshooting)
|
|
72
|
+
- [Related packages](#related-packages)
|
|
73
|
+
- [Contributing](#contributing)
|
|
74
|
+
- [License](#license)
|
|
75
|
+
|
|
76
|
+
## Install
|
|
77
|
+
|
|
78
|
+
In a Kerf app, let the CLI install it and add `icons()` to your config:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npx kerf add icons
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Or install it yourself:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npm install @kerf-js/veneer-icons
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
pnpm add @kerf-js/veneer-icons
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
bun add @kerf-js/veneer-icons
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
The plugin is optional. Without it every icon carries its three tiers and follows the page's `data-expression`.
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
// kerf.config.ts
|
|
102
|
+
import { defineConfig } from '@kerf-js/core/config'
|
|
103
|
+
import { icons } from '@kerf-js/veneer-icons/plugin'
|
|
104
|
+
|
|
105
|
+
export default defineConfig({ plugins: [icons()] })
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`@kerf-js/core` and `vite` are peer dependencies: icons are Kerf components, and the name pass runs in Kerf's Vite
|
|
109
|
+
plugin. Node 24 or later is required.
|
|
110
|
+
|
|
111
|
+
## Quick start
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
import { CheckIcon } from '@kerf-js/veneer-icons'
|
|
115
|
+
|
|
116
|
+
export function Saved() {
|
|
117
|
+
return (
|
|
118
|
+
<p>
|
|
119
|
+
<CheckIcon label="Saved" /> Your changes are saved.
|
|
120
|
+
</p>
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Guide
|
|
126
|
+
|
|
127
|
+
### Three ways to import
|
|
128
|
+
|
|
129
|
+
All three build to the same bytes:
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
// A named export: the plainest form.
|
|
133
|
+
import { CheckIcon } from '@kerf-js/veneer-icons'
|
|
134
|
+
<CheckIcon />
|
|
135
|
+
|
|
136
|
+
// The pack, as a namespace.
|
|
137
|
+
import Icons from '@kerf-js/veneer-icons'
|
|
138
|
+
<Icons.Check />
|
|
139
|
+
|
|
140
|
+
// By name. Also exported from @kerf-js/veneer-icons/icon.
|
|
141
|
+
import { Icon } from '@kerf-js/veneer'
|
|
142
|
+
<Icon name="check" />
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
`sideEffects` lists only CSS, so a named import ships that icon and nothing else.
|
|
146
|
+
|
|
147
|
+
### Props
|
|
148
|
+
|
|
149
|
+
Every icon takes the same props. Anything else lands on the `<svg>`.
|
|
150
|
+
|
|
151
|
+
| Prop | Type | Default | What it does |
|
|
152
|
+
|---|---|---|---|
|
|
153
|
+
| `label` | `string` | | An accessible name: the icon becomes `role="img"`. Without one it is `aria-hidden="true"` and `focusable="false"` |
|
|
154
|
+
| `size` | `number \| string` | Veneer's icon sizes | Width and height, in px or any CSS length |
|
|
155
|
+
| `tier` | `'quiet' \| 'balanced' \| 'vivid'` | the page's `data-expression` | Shows this tier whatever the page's expression is |
|
|
156
|
+
| `style` | `string` | | Inline CSS; `size` goes in front of it |
|
|
157
|
+
|
|
158
|
+
`<Icon>` adds `name` (an icon name or the icon component itself), `solid`, and `action` for the five action icons.
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
<CheckIcon /> // decorative
|
|
162
|
+
<CheckIcon label="Saved" /> // role="img" with that name
|
|
163
|
+
<CheckIcon size={24} /> // otherwise Veneer's icon sizes apply
|
|
164
|
+
<CheckIcon tier="vivid" /> // this tier regardless of the page
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Names and variants
|
|
168
|
+
|
|
169
|
+
One naming scheme, generated from the art together with its types:
|
|
170
|
+
|
|
171
|
+
| Export | Pack | `<Icon>` | What it is |
|
|
172
|
+
|---|---|---|---|
|
|
173
|
+
| `BellIcon` | `Icons.Bell` | `name="bell"` | Hollow, the default |
|
|
174
|
+
| `BellIconHollow` | `Icons.BellHollow` | | The same, by name |
|
|
175
|
+
| `BellIconSolid` | `Icons.BellSolid` | `solid` | The solid form |
|
|
176
|
+
| `BellIconAction` | `Icons.BellAction` | `action` | The animated form (action icons only) |
|
|
177
|
+
|
|
178
|
+
The tier is a prop, never a name. Hollow and solid describe the object: an icon with a body, such as a cart, is that
|
|
179
|
+
body drawn round or filled; an open mark, such as an arrow, is its strokes thickened into a shape, outlined in hollow and
|
|
180
|
+
filled in solid.
|
|
181
|
+
|
|
182
|
+
### How names are resolved
|
|
183
|
+
|
|
184
|
+
Kerf's Vite plugin runs this package's name pass (`@kerf-js/veneer-icons/compile`) over your sources at build time. It
|
|
185
|
+
parses each file and follows every icon name to the literals it can be: through variables, conditionals, static lists
|
|
186
|
+
and maps, imports, and props handed down through components.
|
|
187
|
+
|
|
188
|
+
- **A literal name** compiles to the icon itself. `<Icon name="check" />` ships `CheckIcon` and nothing more.
|
|
189
|
+
- **An unknown literal name** fails the build:
|
|
190
|
+
|
|
191
|
+
```text
|
|
192
|
+
I001 no icon 'chekc', did you mean 'check'?
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
So does a variant an icon doesn't have, such as `action` on an icon that doesn't move.
|
|
196
|
+
- **A name it can't follow**, such as one from an API, is legal. `kerf check` reports it as I002 with the file and the
|
|
197
|
+
cost, or I003 if the pack itself is passed around. See [Names from data](#names-from-data).
|
|
198
|
+
|
|
199
|
+
The same pass runs in `vite build` and `kerf check`. In development and tests, `@kerf-js/veneer-icons/names` holds every
|
|
200
|
+
icon; a build swaps it for a module holding only the names your app uses.
|
|
201
|
+
|
|
202
|
+
### Names from data
|
|
203
|
+
|
|
204
|
+
A use whose name the build can't bound gets one of two things.
|
|
205
|
+
|
|
206
|
+
**The pack, as its own chunk.** The default. It is about 111 KB of brotli for all 651 icons with every tier, loaded only
|
|
207
|
+
by a page that reaches it. A page with a dynamic name stays about 1.6 KB bigger than one without.
|
|
208
|
+
|
|
209
|
+
**Single icons from a URL.** Point `icons()` at a host of static files. Nothing of the pack is built; each icon is
|
|
210
|
+
fetched the first time it is drawn.
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
import { icons } from '@kerf-js/veneer-icons/plugin'
|
|
214
|
+
|
|
215
|
+
export default {
|
|
216
|
+
plugins: [icons({ source: 'https://cdn.example.com/icons/' })],
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
`kerf icons publish <dir>` writes every icon and variant as a static `.svg` file with a `manifest.json`, ready for that
|
|
221
|
+
host. It writes files and uploads nothing. Action icons aren't published.
|
|
222
|
+
|
|
223
|
+
A remote icon renders an empty `<svg data-icon data-loading>` of the right size until it arrives, then swaps in with no
|
|
224
|
+
layout shift. If the fetch fails it carries `data-failed` and the page carries on. On the server it stays empty, so SSR
|
|
225
|
+
needs no network. Only `<path>` elements with their `d`, `data-*` and `translate()` attributes are kept from the
|
|
226
|
+
response, so what a host sends is data, never markup that can run. A Content-Security-Policy needs the host in
|
|
227
|
+
`connect-src`.
|
|
228
|
+
|
|
229
|
+
For a fixed list of names that come from data, `iconSet` keeps names typed and everything else tree-shakeable:
|
|
230
|
+
|
|
231
|
+
```tsx
|
|
232
|
+
import { CheckIcon, XIcon, iconSet } from '@kerf-js/veneer-icons'
|
|
233
|
+
|
|
234
|
+
const StatusIcon = iconSet({ ok: CheckIcon, failed: XIcon })
|
|
235
|
+
|
|
236
|
+
<StatusIcon name={job.status} label={job.status} />
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
`@kerf-js/veneer-icons/all` is the same over every icon (`icons`, `lookup`, `names`, `Icon`), for an app that takes any
|
|
240
|
+
name from data and accepts the whole set.
|
|
241
|
+
|
|
242
|
+
### Tiers
|
|
243
|
+
|
|
244
|
+
| Tier | Drawing |
|
|
245
|
+
|---|---|
|
|
246
|
+
| `quiet` | A thin outline, restrained, no shading. Solid is a flat mass with a fine cut |
|
|
247
|
+
| `balanced` | A heavier outline with the kerf stroke plain to see and dither depth on the shadow side. Solid is lit, with an offset shade |
|
|
248
|
+
| `vivid` | Pixels on the 16 grid, shaded with dither, with Veneer's notch |
|
|
249
|
+
|
|
250
|
+
With no options each icon carries its tiers and CSS shows the one for the nearest `data-expression`. Switching needs no
|
|
251
|
+
script, doesn't flash and doesn't change the box. A nested `data-expression` is honoured, and a page without Veneer shows
|
|
252
|
+
`balanced`. The build keeps only the tiers your config and `data-expression` attributes name.
|
|
253
|
+
|
|
254
|
+
To compile one tier in with no switch, name it:
|
|
255
|
+
|
|
256
|
+
```ts
|
|
257
|
+
import { icons } from '@kerf-js/veneer-icons/plugin'
|
|
258
|
+
|
|
259
|
+
export default { plugins: [icons({ tier: 'vivid' })] }
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
`@kerf-js/veneer-icons` then resolves to that tier alone, and Veneer's own icons follow it too. After that a page's
|
|
263
|
+
`data-expression` no longer changes icons; run `kerf plugins sync` if you change the tier.
|
|
264
|
+
|
|
265
|
+
The pixel tier is exact at 16, 32 and 48 px. At 20 and 24 px a 1× screen rounds cells unevenly; a 2× screen draws 24
|
|
266
|
+
evenly. Prefer 16 or 32 at `vivid`.
|
|
267
|
+
|
|
268
|
+
### Action icons
|
|
269
|
+
|
|
270
|
+
Five icons have a built-in animation: `trash` (the lid lifts), `bell` (it rings), `check` (it draws on), `refresh` (it
|
|
271
|
+
spins) and `copy` (the sheet stacks).
|
|
272
|
+
|
|
273
|
+
```tsx
|
|
274
|
+
import { Icon } from '@kerf-js/veneer'
|
|
275
|
+
import { TrashIconAction } from '@kerf-js/veneer-icons'
|
|
276
|
+
|
|
277
|
+
// Animates on hover, focus and press of the icon or its parent
|
|
278
|
+
<Icon name="trash" action />
|
|
279
|
+
<Icon name="refresh" action="on" /> // now; refresh keeps spinning
|
|
280
|
+
// action: 'hover' | 'focus' | 'press' | 'on'
|
|
281
|
+
<TrashIconAction action="press" />
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
It is CSS alone, and each one's stylesheet ships only if that icon is used: about 230 B of CSS and 50 B of JS, brotli.
|
|
285
|
+
Outlines ease; pixels move in whole cells, in frames. Veneer's motion dial and `prefers-reduced-motion` turn it off. An
|
|
286
|
+
action on any other icon is I001.
|
|
287
|
+
|
|
288
|
+
### Styling
|
|
289
|
+
|
|
290
|
+
Icons draw in `currentColor`. The kerf stroke, the one that says what the icon means, is `[data-w]`, so you can colour it
|
|
291
|
+
apart:
|
|
292
|
+
|
|
293
|
+
```css
|
|
294
|
+
svg [data-w] { stroke: var(--veneer-color-accent-text); }
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
| Custom property | What it does |
|
|
298
|
+
|---|---|
|
|
299
|
+
| `--veneer-icon-kerf` | The weight of the kerf stroke |
|
|
300
|
+
| `--veneer-icon-knock` | The colour a solid cuts its marks with. Defaults to `Canvas`; on a coloured surface such as a solid button, set it to that surface's colour |
|
|
301
|
+
|
|
302
|
+
## The set
|
|
303
|
+
|
|
304
|
+
651 icons, in twelve groups of source art:
|
|
305
|
+
|
|
306
|
+
| Group | Icons | Group | Icons |
|
|
307
|
+
|---|---|---|---|
|
|
308
|
+
| Marks | 32 | Navigation | 68 |
|
|
309
|
+
| Status | 20 | Actions | 80 |
|
|
310
|
+
| People | 34 | Files and media | 73 |
|
|
311
|
+
| Files | 35 | Comms and commerce | 80 |
|
|
312
|
+
| Things | 33 | Data and dev | 92 |
|
|
313
|
+
| Agent | 6 | World | 98 |
|
|
314
|
+
|
|
315
|
+
Browse them all on the contact sheet: `pnpm run sheet` in this package writes `contact-sheet.html`, one static file with
|
|
316
|
+
controls for tier, form, size, theme and accent, and a search. `kerf docs icons` prints the reference in your terminal;
|
|
317
|
+
its source is [packages/cli/docs/icons.md](https://github.com/Ravonus/kerf/blob/main/packages/cli/docs/icons.md).
|
|
318
|
+
|
|
319
|
+
**Licence.** The icons are MIT licensed, like the rest of Kerf. They are original work: the rules in
|
|
320
|
+
[docs/design/veneer/10-icons.md](https://github.com/Ravonus/kerf/blob/main/docs/design/veneer/10-icons.md) state that nothing
|
|
321
|
+
is copied, traced or adapted from another set.
|
|
322
|
+
|
|
323
|
+
## How the icons are made
|
|
324
|
+
|
|
325
|
+
The icons are generated, not hand-exported. One source produces every tier, form, export and type, so they can't drift.
|
|
326
|
+
|
|
327
|
+
```text
|
|
328
|
+
art/*.mjs ──scripts/build.mjs──▶ src/gen/*.tsx
|
|
329
|
+
one component per icon and variant
|
|
330
|
+
src/gen/names.ts
|
|
331
|
+
IconName, IconVariant, the actions
|
|
332
|
+
per-action CSS
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
- **Source art** is in [`art/`](https://github.com/Ravonus/kerf/tree/main/packages/veneer-icons/art). Each entry is a pair:
|
|
336
|
+
an outline in a small drawing language, and a 16×16 pixel grid drawn as text.
|
|
337
|
+
|
|
338
|
+
```js
|
|
339
|
+
'arrow-up': [
|
|
340
|
+
'/ ln 7,13 7,1; ln 2,6 7,1 12,6',
|
|
341
|
+
`
|
|
342
|
+
.
|
|
343
|
+
......##
|
|
344
|
+
.....####
|
|
345
|
+
....######
|
|
346
|
+
...
|
|
347
|
+
`,
|
|
348
|
+
],
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
- **The drawing language** (`scripts/draw.mjs`) uses 16-unit coordinates, where `u` is the centre of pixel `u` at 16 px,
|
|
352
|
+
so every straight stroke lands on one pixel row at Veneer's default size. An outline reads `body / kerf`: the strokes
|
|
353
|
+
before the slash draw the object, the ones after it the kerf stroke (`[data-w]`). Commands are separated by `;`. The
|
|
354
|
+
operations are `ln` (a line), `pl` (a polyline with rounded corners), `pg` (a closed polygon), `sg` (a sharp closed
|
|
355
|
+
mark), `rect`, `box` (a rectangle with Veneer's notch), `ring`, `circ`, `dot` and `p` (a raw path).
|
|
356
|
+
- **Forms** (`scripts/forms.mjs`) build hollow and solid for each tier. Hand-drawn pixel masters in `art/style/` cover the
|
|
357
|
+
icons a derived grid can't shade well, and `art/style/solid.mjs` places the highlight cut into each solid outline.
|
|
358
|
+
- **Actions** are in `art/actions/`, each with its own keyframes and pixel frames.
|
|
359
|
+
- **Checks.** `pnpm test` runs `scripts/build.mjs --check`, which fails if `src/gen` is stale, then the tests: the art
|
|
360
|
+
holds to its rules, generated modules stay complete and match their art, and the name pass ships what it should.
|
|
361
|
+
`scripts/distinct.mjs` renders each icon in Chromium at 16 and 24 px and checks that forms and tiers actually look
|
|
362
|
+
different.
|
|
363
|
+
|
|
364
|
+
## API reference
|
|
365
|
+
|
|
366
|
+
| Import | What it has |
|
|
367
|
+
|---|---|
|
|
368
|
+
| `@kerf-js/veneer-icons` | Every icon as `XIcon`, `XIconHollow`, `XIconSolid`, and `XIconAction` for the five action icons; the pack as the default export; `iconSet`; the `IconComponent`, `IconProps`, `ActionIconProps` and `IconTrigger` types |
|
|
369
|
+
| `@kerf-js/veneer-icons/icon` | `Icon`: an icon by name; the `IconName`, `IconVariant` and `IconRef` types |
|
|
370
|
+
| `@kerf-js/veneer-icons/all` | `icons` (every icon by name), `lookup`, `names`, `actions`, `Icon`. Costs the whole set |
|
|
371
|
+
| `@kerf-js/veneer-icons/names` | `resolve(name, variant?)` and `pack(id)`. A build replaces this module with one that knows only your app's names |
|
|
372
|
+
| `@kerf-js/veneer-icons/late` | `late` and `remote`: the lazy-pack and remote-URL loaders the build wires in for dynamic names |
|
|
373
|
+
| `@kerf-js/veneer-icons/quiet`, `/balanced`, `/vivid` | What `@kerf-js/veneer-icons` resolves to when `icons({ tier })` pins a tier |
|
|
374
|
+
| `@kerf-js/veneer-icons/plugin` | `icons({ tier?, source? })` for `kerf.config.ts` (also the default export) |
|
|
375
|
+
| `@kerf-js/veneer-icons/compile` | The build's name pass: `pass`, `analyze`, `rewrite`, `findings`, `unknownMessage`, `publish`, `packCost`, `trimTiers`, `list`, `STOPS` |
|
|
376
|
+
| `@kerf-js/veneer-icons/icons.css` | The base rule for every icon, so the set works without Veneer |
|
|
377
|
+
| `@kerf-js/veneer-icons/tiers.css` | The runtime tier switch keyed on `data-expression` |
|
|
378
|
+
|
|
379
|
+
`icons()` options:
|
|
380
|
+
|
|
381
|
+
| Option | Values | Default | What it does |
|
|
382
|
+
|---|---|---|---|
|
|
383
|
+
| `tier` | `quiet` · `balanced` · `vivid` | every tier, switched by CSS | Compiles one tier in |
|
|
384
|
+
| `source` | an `http(s)` URL ending in `/` | | Dynamic names load single SVG files from here instead of the pack |
|
|
385
|
+
|
|
386
|
+
Any other key is rejected with `unknown option`.
|
|
387
|
+
|
|
388
|
+
## Troubleshooting
|
|
389
|
+
|
|
390
|
+
**`I001 no icon '…', did you mean '…'?`** The name isn't in the set. Use the suggestion, or browse the contact sheet.
|
|
391
|
+
|
|
392
|
+
**`I001 no action for icon '…'`.** Only `trash`, `bell`, `check`, `refresh` and `copy` take `action`.
|
|
393
|
+
|
|
394
|
+
**I002 in `kerf check`.** A name the build can't follow. It works, but that page loads the pack chunk (about 111 KB
|
|
395
|
+
brotli) or, with `icons({ source })`, single files. Make the name a literal, or narrow it with `iconSet`, to ship only the
|
|
396
|
+
icons you use.
|
|
397
|
+
|
|
398
|
+
**Icons don't change with `data-expression`.** A pinned `icons({ tier })` compiles one tier in. Remove it, or run
|
|
399
|
+
`kerf plugins sync` after changing it.
|
|
400
|
+
|
|
401
|
+
**Remote icons stay empty.** Check the host serves `<name>.svg` (and `<name>.solid.svg`) under the `source` URL, and that
|
|
402
|
+
your Content-Security-Policy lists it in `connect-src`. A failed fetch marks the icon `data-failed`.
|
|
403
|
+
|
|
404
|
+
**Solid icons look wrong on a coloured button.** Set `--veneer-icon-knock` to the button's fill.
|
|
405
|
+
|
|
406
|
+
**Pixel icons look uneven at 20 or 24 px.** The vivid tier is exact at 16, 32 and 48 px.
|
|
407
|
+
|
|
408
|
+
## Related packages
|
|
409
|
+
|
|
410
|
+
| Package | What it is |
|
|
411
|
+
|---|---|
|
|
412
|
+
| [`@kerf-js/veneer`](https://www.npmjs.com/package/@kerf-js/veneer) <sup>[source](https://github.com/Ravonus/kerf/tree/main/packages/veneer)</sup> | Veneer's components; its `Icon` and every icon inside a component come from here |
|
|
413
|
+
| [`@kerf-js/veneer-core`](https://www.npmjs.com/package/@kerf-js/veneer-core) <sup>[source](https://github.com/Ravonus/kerf/tree/main/packages/veneer-core)</sup> | Veneer's behaviour, tokens and CSS, with no framework |
|
|
414
|
+
| [`@kerf-js/core`](https://www.npmjs.com/package/@kerf-js/core) <sup>[source](https://github.com/Ravonus/kerf/tree/main/packages/core)</sup> | The Kerf runtime and Vite plugin that runs the name pass |
|
|
415
|
+
| [`@kerf-js/cli`](https://www.npmjs.com/package/@kerf-js/cli) <sup>[source](https://github.com/Ravonus/kerf/tree/main/packages/cli)</sup> | `kerf add icons`, `kerf check`, `kerf icons publish`, `kerf docs icons` |
|
|
416
|
+
|
|
417
|
+
## Contributing
|
|
418
|
+
|
|
419
|
+
See [CONTRIBUTING.md](https://github.com/Ravonus/kerf/blob/main/CONTRIBUTING.md). In `packages/veneer-icons`:
|
|
420
|
+
|
|
421
|
+
```bash
|
|
422
|
+
pnpm run build # art/*.mjs → src/gen
|
|
423
|
+
pnpm test # fails if src/gen is stale, then vitest
|
|
424
|
+
pnpm run sheet # writes contact-sheet.html
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
New art follows [docs/design/veneer/10-icons.md](https://github.com/Ravonus/kerf/blob/main/docs/design/veneer/10-icons.md).
|
|
428
|
+
Never edit `src/gen` by hand.
|
|
429
|
+
|
|
430
|
+
## License
|
|
431
|
+
|
|
432
|
+
[MIT](https://github.com/Ravonus/kerf/blob/main/LICENSE)
|