sisyo 1.6.7 → 1.7.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 +6 -1
- package/bin/known-hashes.json +109 -0
- package/bin/sisyo.js +285 -285
- package/package.json +30 -30
- package/templates/.claude/rules/agents-and-tests.md +24 -0
- package/templates/.claude/skills/g6-style/SKILL.md +125 -0
- package/templates/.claude/skills/g6-style/references/checks.md +58 -0
- package/templates/.claude/skills/g6-style/references/imagery.md +103 -0
- package/templates/.claude/skills/g6-style/references/motion.md +121 -0
- package/templates/.claude/skills/g6-style/references/sections.md +263 -0
- package/templates/.claude/skills/g6-style/references/tokens.md +197 -0
- package/templates/.claude/skills/hindsight/SKILL.md +13 -10
- package/templates/.claude/skills/i18n-multilang/SKILL.md +153 -0
- package/templates/.claude/skills/i18n-multilang/assets/languages.json +47 -0
- package/templates/.claude/skills/i18n-multilang/assets/plural-vectors.json +46 -0
- package/templates/.claude/skills/i18n-multilang/assets/project/README.md +17 -0
- package/templates/.claude/skills/i18n-multilang/assets/project/gitattributes.txt +6 -0
- package/templates/.claude/skills/i18n-multilang/assets/project/gitignore.txt +4 -0
- package/templates/.claude/skills/i18n-multilang/assets/project/glossary.json +6 -0
- package/templates/.claude/skills/i18n-multilang/assets/project/i18n.config.json +22 -0
- package/templates/.claude/skills/i18n-multilang/assets/project/locales/__source__/common.json +10 -0
- package/templates/.claude/skills/i18n-multilang/assets/project/notes/common.json +5 -0
- package/templates/.claude/skills/i18n-multilang/assets/project/style.md +20 -0
- package/templates/.claude/skills/i18n-multilang/references/format.md +100 -0
- package/templates/.claude/skills/i18n-multilang/references/languages.md +97 -0
- package/templates/.claude/skills/i18n-multilang/references/layout-and-versioning.md +256 -0
- package/templates/.claude/skills/i18n-multilang/references/numbers.md +161 -0
- package/templates/.claude/skills/i18n-multilang/references/platform-unity.md +142 -0
- package/templates/.claude/skills/i18n-multilang/references/platform-web.md +107 -0
- package/templates/.claude/skills/i18n-multilang/references/translation.md +143 -0
- package/templates/.claude/skills/i18n-multilang/references/voice.md +271 -0
- package/templates/.claude/skills/i18n-multilang/scripts/i18n.py +1041 -0
- package/templates/.claude/skills/i18n-multilang/scripts/numwords.py +1013 -0
- package/templates/.claude/skills/i18n-multilang/scripts/voice.py +478 -0
- package/templates/.claude/skills/neon-game-ui-ux-skill/COMPONENTS.md +490 -0
- package/templates/.claude/skills/neon-game-ui-ux-skill/GAMIFICATION.md +246 -0
- package/templates/.claude/skills/neon-game-ui-ux-skill/ICONS.md +249 -0
- package/templates/.claude/skills/neon-game-ui-ux-skill/LAYOUT-NAV.md +362 -0
- package/templates/.claude/skills/neon-game-ui-ux-skill/MOTION-A11Y.md +168 -0
- package/templates/.claude/skills/neon-game-ui-ux-skill/SKILL.md +137 -0
- package/templates/.claude/skills/neon-game-ui-ux-skill/TOKENS.md +323 -0
- package/templates/SISYO.md +1 -1
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# Gamification
|
|
2
|
+
|
|
3
|
+
The game layer as reusable UX patterns, the honesty rules that keep it from turning into a dark pattern, and the data
|
|
4
|
+
contract the UI expects from a backend. The UI only **displays** game state; every number is decided by the server.
|
|
5
|
+
The components that draw these patterns are described in `COMPONENTS.md`.
|
|
6
|
+
|
|
7
|
+
## 1. The loop
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
action (answer, finish, save, claim)
|
|
11
|
+
→ server grants XP, returns a Reward
|
|
12
|
+
→ burst flies from the control to the HUD (the moment)
|
|
13
|
+
→ HUD numbers update, path / quest advance (the state)
|
|
14
|
+
→ next step is highlighted (the pull)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Each element answers one question for the user:
|
|
18
|
+
|
|
19
|
+
| Element | Question | Where |
|
|
20
|
+
|---|---|---|
|
|
21
|
+
| XP + level | "Am I getting anywhere overall?" | HUD: level hexagon + XP bar |
|
|
22
|
+
| Daily goal | "Have I done enough today?" | HUD ring; centre dial of the bottom bar |
|
|
23
|
+
| Streak | "Am I consistent?" | HUD pill |
|
|
24
|
+
| Daily path | "What do I do next?" | Home hero card |
|
|
25
|
+
| Quests | "What else could I do today?" | Home side column |
|
|
26
|
+
| Achievements | "What have I collected over months?" | Home / profile grid |
|
|
27
|
+
|
|
28
|
+
If a product cannot answer one of these questions honestly (for example there is no meaningful daily unit), leave that
|
|
29
|
+
element out. A streak in an app people use twice a month is noise.
|
|
30
|
+
|
|
31
|
+
## 2. XP
|
|
32
|
+
|
|
33
|
+
- XP is granted for **completed, meaningful actions**, by the server, in small integers (LenS: 5 for a
|
|
34
|
+
correct answer, 1 for a wrong one, 2 per answered question up to 10 for finishing a session, 30 for the daily
|
|
35
|
+
chest, 10-20 for a quest).
|
|
36
|
+
- **Every repeatable source has a bound**: a per-session maximum and a number of paid repetitions per local day
|
|
37
|
+
(LenS pays 5 session-completion bonuses a day; later sessions still work but earn 0). Without bounds a loop
|
|
38
|
+
of tiny sessions farms XP, levels and count-based achievements, and the numbers stop meaning anything.
|
|
39
|
+
- **Every grant is idempotent.** A grant has a `(source, source_id)` key that is unique per user (examples:
|
|
40
|
+
`quiz_complete` + session id; `quest` + `<local date>:<quest id>`; `chest` + local date; `word_added` + the
|
|
41
|
+
normalised word). Repeating the request returns a Reward with `xp_earned: 0, duplicate: true` and the current
|
|
42
|
+
totals. The UI can therefore retry and double-tap safely, and must treat `duplicate` as "nothing to celebrate".
|
|
43
|
+
- Wrong or failed attempts may earn a token amount (1 XP) so that effort is acknowledged, but never as much as
|
|
44
|
+
success.
|
|
45
|
+
|
|
46
|
+
## 3. Levels
|
|
47
|
+
|
|
48
|
+
- Thresholds are cumulative XP: `0, 100, 250, 500, 1000, 2000, 3500, 5500, 8000, 12000, 17000, 25000`, then a fixed
|
|
49
|
+
step (10 000) per level, so levels never end and the bar never sticks at a cap.
|
|
50
|
+
- The API sends `level`, `total_xp`, `level_floor`, `next_level_xp`. The XP bar gets
|
|
51
|
+
`current = max(0, total_xp - level_floor)` and `span = max(1, next_level_xp - level_floor)` and shows
|
|
52
|
+
`current / span`. **Do not** compute `total_xp / next_level_xp`: thresholds are cumulative, so that bar starts each
|
|
53
|
+
level half full and is wrong.
|
|
54
|
+
- The client never holds the level table (only a dev gallery may, to simulate). One source of truth avoids a HUD that
|
|
55
|
+
disagrees with the server after a rule change.
|
|
56
|
+
- A level-up is the top of the intensity ladder (§8): a modal, once, with what was unlocked if anything.
|
|
57
|
+
|
|
58
|
+
## 4. Streak
|
|
59
|
+
|
|
60
|
+
Three states, decided by the server from the user's **local** day:
|
|
61
|
+
|
|
62
|
+
| State | Meaning | HUD | Copy |
|
|
63
|
+
|---|---|---|---|
|
|
64
|
+
| `done` | Active today | Ember ring + glow, flame glows | "You were active today. See you tomorrow!" |
|
|
65
|
+
| `at_risk` | Last active yesterday, nothing yet today | Amber ring, flame floats 3 times | "Earn any XP today to keep your streak alive." |
|
|
66
|
+
| `zero` | Lapsed or never started | Grey, flame mono | "Earn any XP today to start a new streak." |
|
|
67
|
+
|
|
68
|
+
- The first XP of a local day extends the streak (`Reward.streak_extended`).
|
|
69
|
+
- **Read-decay**: a lapsed streak reads as `0 / zero` immediately, before the next activity; the stored counter is
|
|
70
|
+
only reset on the next grant. The user never sees a streak that is already lost.
|
|
71
|
+
- The "local day" comes from a time zone stored in the user's settings (UTC when unset), not from the request's
|
|
72
|
+
clock. A user who travels west must not lose a day: a last-active day in the future counts as today.
|
|
73
|
+
- `at_risk` is information, not alarm: amber, a short finite animation, no countdown timer, no push of guilt.
|
|
74
|
+
A lapsed streak is shown plainly; the longest streak stays visible ("best 21") so past effort is not erased.
|
|
75
|
+
|
|
76
|
+
## 5. Daily goal
|
|
77
|
+
|
|
78
|
+
- Ratio = `min(1, today.xp / today.goal)`; a goal of 0 counts as reached (ratio 1). The goal is a **user setting**.
|
|
79
|
+
- Shown as a 34 px ring in the HUD with the percentage inside; at 100 % the ring's own check pops in.
|
|
80
|
+
- The same ring is the centre "dial" of the mobile bottom bar (LAYOUT-NAV.md): the thing the user came to do is the
|
|
81
|
+
biggest, most central control, and it shows how much of today is done.
|
|
82
|
+
- Reaching the goal (`Reward.goal_reached_now`) is a medium moment: toast-level, not a modal.
|
|
83
|
+
|
|
84
|
+
## 6. Daily path and chest
|
|
85
|
+
|
|
86
|
+
A short fixed sequence of today's activities (LenS: Review → Quiz → Read → Speak) ending in a chest.
|
|
87
|
+
|
|
88
|
+
- Each step has a goal measured from today's counts; the server returns per step
|
|
89
|
+
`{ id, label, state: done | in_progress | current | todo, progress 0..1, to }`.
|
|
90
|
+
- Done steps stay done. The **first** open step is `current` (or `in_progress` once it has partial progress); later
|
|
91
|
+
open steps are `todo`, which the UI shows as **locked** with the hint "Finish <current> to unlock". The lock is a
|
|
92
|
+
focus device: only one thing is asked at a time. (Whether locked steps are really unreachable is a product choice;
|
|
93
|
+
in LenS the pages stay reachable from the navigation, the path only recommends an order.)
|
|
94
|
+
- The chest is `locked` until every step is done, then `ready`, then `claimed`; one per local day, a fixed amount
|
|
95
|
+
shown in advance (`+30 XP`). Claiming is an explicit tap on a CTA that replaces "Continue": the user opens it.
|
|
96
|
+
- Hero card copy follows the state: "Start today's path" → "2 of 4 steps done · Next up: ..." → "Path complete!
|
|
97
|
+
Open your chest to collect +30 XP" → "Every step is done. A new path unlocks tomorrow."
|
|
98
|
+
- After the claim the chest button disappears; if it was activated from the keyboard, move focus to the card heading
|
|
99
|
+
(`tabIndex={-1}`) so focus does not fall to `<body>`.
|
|
100
|
+
|
|
101
|
+
## 7. Quests and achievements
|
|
102
|
+
|
|
103
|
+
**Quests** (daily, 3 per day): one constant ("Earn {daily goal} XP") plus two drawn from a pool by a hash of the
|
|
104
|
+
date, so they are the same for everyone that day and stable across servers, never two with the same metric.
|
|
105
|
+
|
|
106
|
+
- `{ id, title, icon, tone, progress, goal, reward_xp, state: active | complete | claimed }`; `progress` is capped at
|
|
107
|
+
`goal`.
|
|
108
|
+
- A complete quest must be **claimed** by the user (gold Claim keycap). The claim is the reward moment; granting
|
|
109
|
+
silently on completion wastes it.
|
|
110
|
+
- Claim errors: 404 (not one of today's quests: the day rolled over) and 409 (not complete) mean the client's view is
|
|
111
|
+
stale. Do not show an error toast for these; refetch and show the server's view.
|
|
112
|
+
- Optimistic step: mark the quest `claimed` in the cache as soon as the claim succeeds; the refetch confirms it.
|
|
113
|
+
|
|
114
|
+
**Achievements** (long-term): a fixed catalog `{ key, name, description, tier, icon }` plus per user
|
|
115
|
+
`{ earned_at, progress 0..1 }`.
|
|
116
|
+
|
|
117
|
+
- Tiers map to effort: first steps bronze; hundreds / a week silver; many hundreds / a month gold; extremes rare.
|
|
118
|
+
- Progress for "reach level N" is measured in XP, so the ring moves with every grant.
|
|
119
|
+
- Newly earned ones arrive in `Reward.new_achievements` and are toasted; the grid shows a NEW ribbon once.
|
|
120
|
+
- Locked achievements show their name and goal. Use `secret` sparingly, for surprises, not to hide requirements.
|
|
121
|
+
|
|
122
|
+
## 8. Reward moments: the intensity ladder
|
|
123
|
+
|
|
124
|
+
| Level | Trigger | What plays | Blocks input? |
|
|
125
|
+
|---|---|---|---|
|
|
126
|
+
| 0 | Any XP < 50 | Burst dots + `+N XP` chip flies to the XP bar, bar pulses; screen-reader announcement only | No |
|
|
127
|
+
| 1 | XP >= 50, achievement, goal reached | The same + a toast (2.5 s) | No |
|
|
128
|
+
| 2 | Quest complete (waiting for claim) | Card turns gold, Claim button pulses, sheen loops | No |
|
|
129
|
+
| 3 | Chest ready | Node pops in with a gold burst; hero CTA becomes "Open chest" | No |
|
|
130
|
+
| 4 | Level up | Modal after the chip lands: rays, badge opens, Continue | Yes, dismissible at once (Esc, scrim, Continue) |
|
|
131
|
+
|
|
132
|
+
Rules:
|
|
133
|
+
|
|
134
|
+
- **Match intensity to rarity.** If every answer opened a modal, the level-up would mean nothing and the user would
|
|
135
|
+
be interrupted hundreds of times a day.
|
|
136
|
+
- **Merge.** Gains within 400 ms become one burst with the sum. Several grants from one action must not stack three
|
|
137
|
+
animations.
|
|
138
|
+
- **The reward lands on the HUD.** The chip flies to the XP bar and the bar updates when it arrives: the user sees
|
|
139
|
+
where the number went. Updating the HUD first and animating afterwards breaks the cause-and-effect.
|
|
140
|
+
- **Start from where the user acted.** Pass the pressed control as the anchor, or better its centre point, measured
|
|
141
|
+
**at press time**: the reward arrives after the request, when the control may have re-rendered or gone (a Claim
|
|
142
|
+
button becomes "Claimed").
|
|
143
|
+
- **Never block for more than 700 ms**, never require watching. Level 4 is the only modal and closes on the first key.
|
|
144
|
+
- Reduced motion: the chip fades in place, numbers change instantly, colour and text feedback stay.
|
|
145
|
+
|
|
146
|
+
## 9. Honesty rules
|
|
147
|
+
|
|
148
|
+
1. **No fake scarcity.** No invented countdowns, no "only 2 left", no rewards that expire to create pressure. The
|
|
149
|
+
only real deadline is the end of the local day, and it is stated plainly.
|
|
150
|
+
2. **No loss framing beyond the facts.** "Earn any XP today to keep your streak" is a fact. "You are about to lose
|
|
151
|
+
everything" is not acceptable copy.
|
|
152
|
+
3. **Rewards are shown before they are earned** (`+30 XP` on the chest, `+20 XP` on the quest) and paid exactly.
|
|
153
|
+
No random amounts presented as fixed, no bait.
|
|
154
|
+
4. **The server is the only authority.** The client never adds XP locally except as a short optimistic patch that
|
|
155
|
+
a refetch then replaces. A client-side counter that drifts from the server is a bug the user will notice.
|
|
156
|
+
5. **Idempotent grants** (§2), so a retry or a double tap can never pay twice or show a second celebration.
|
|
157
|
+
6. **Farming is closed** by per-session and per-day bounds, not by hiding the activity. A capped action still works,
|
|
158
|
+
it just earns nothing more today, and the UI can say so.
|
|
159
|
+
7. **Nothing is gated behind the game.** Locks in the path order the day; they do not withhold features the user
|
|
160
|
+
has. XP buys no advantage that can also be bought with money.
|
|
161
|
+
8. **Opt-out friendly.** The HUD is compact; celebrations are skippable; reduced motion is respected. A user who
|
|
162
|
+
ignores the game still gets a usable product.
|
|
163
|
+
|
|
164
|
+
## 10. Data contract
|
|
165
|
+
|
|
166
|
+
### HUD read model: `GET /gamification/hud`
|
|
167
|
+
|
|
168
|
+
One request returns everything the shell and the home page show.
|
|
169
|
+
|
|
170
|
+
| Field | Type | Meaning |
|
|
171
|
+
|---|---|---|
|
|
172
|
+
| `level` | integer | Current level |
|
|
173
|
+
| `total_xp` | integer | Lifetime XP |
|
|
174
|
+
| `level_floor` | integer | Cumulative XP where this level started |
|
|
175
|
+
| `next_level_xp` | integer | Cumulative XP where the next level starts |
|
|
176
|
+
| `streak.current` | integer | Days in the streak (0 when lapsed: read-decay, §4) |
|
|
177
|
+
| `streak.longest` | integer | Best streak ever |
|
|
178
|
+
| `streak.state` | `done` \| `at_risk` \| `zero` | §4 |
|
|
179
|
+
| `today.date` | `YYYY-MM-DD` | The user's local day |
|
|
180
|
+
| `today.xp` | integer | XP earned today |
|
|
181
|
+
| `today.goal` | integer | The user's daily goal |
|
|
182
|
+
| `today.<counts>` | integers | Product-specific counts of today (LenS: quizzes, readings, speaking seconds, dictations, words reviewed, words added) |
|
|
183
|
+
| `path[]` | list | Today's steps, in order |
|
|
184
|
+
| `path[].id` | string | Stable step id |
|
|
185
|
+
| `path[].label` | string | Short label under the node |
|
|
186
|
+
| `path[].state` | `done` \| `in_progress` \| `current` \| `todo` | `todo` is drawn as locked |
|
|
187
|
+
| `path[].progress` | 0..1 | Ring around an in-progress node |
|
|
188
|
+
| `path[].to` | string | Route of the step |
|
|
189
|
+
| `quests[]` | list | Today's quests |
|
|
190
|
+
| `quests[].id`, `.title` | string | |
|
|
191
|
+
| `quests[].icon`, `.tone` | string | Names from the icon registry and the tone list |
|
|
192
|
+
| `quests[].progress`, `.goal` | integer | `progress` is capped at `goal` |
|
|
193
|
+
| `quests[].reward_xp` | integer | Shown before it is earned |
|
|
194
|
+
| `quests[].state` | `active` \| `complete` \| `claimed` | |
|
|
195
|
+
| `chest.state` | `locked` \| `ready` \| `claimed` | |
|
|
196
|
+
| `chest.xp` | integer | The chest's fixed reward |
|
|
197
|
+
|
|
198
|
+
- One read model, not five endpoints: the top bar, its panel, the bottom bar's dial and the home page share one
|
|
199
|
+
cached query (stale time about 30 s) and can never disagree.
|
|
200
|
+
- `icon` and `tone` come from the server as names. Map unknown names to a fallback on the client; a server deploy
|
|
201
|
+
must not be able to crash the page.
|
|
202
|
+
- The server computes "today" and every state. The client does no date arithmetic.
|
|
203
|
+
- Mapping to the components: the API's `at_risk` is the pill's `at-risk`; a path step's `todo` is the node's
|
|
204
|
+
`locked`, `in_progress` is `in-progress`; the chest becomes the last node of the path with state `chest` (the node
|
|
205
|
+
shows "ready" when every earlier step is done).
|
|
206
|
+
|
|
207
|
+
### Reward: returned by every response that grants XP
|
|
208
|
+
|
|
209
|
+
| Field | Type | Meaning |
|
|
210
|
+
|---|---|---|
|
|
211
|
+
| `xp_earned` | integer | The delta; 0 for a repeat |
|
|
212
|
+
| `total_xp`, `level`, `level_floor`, `next_level_xp` | integers | The **new totals**, same meaning as in the HUD |
|
|
213
|
+
| `leveled_up` | boolean | This grant crossed a level threshold |
|
|
214
|
+
| `streak` | integer | The streak after this grant |
|
|
215
|
+
| `streak_extended` | boolean | First activity of the local day |
|
|
216
|
+
| `new_achievements[]` | `{ key, name, description, tier, icon }` | Earned by this grant |
|
|
217
|
+
| `daily_xp`, `daily_goal` | integers | Today's XP after this grant, and the goal |
|
|
218
|
+
| `goal_reached_now` | boolean | This grant crossed the daily goal |
|
|
219
|
+
| `duplicate` | boolean | This grant was already paid (§2) |
|
|
220
|
+
|
|
221
|
+
A Reward carries the new totals, not only the delta, so the client can patch the HUD without arithmetic.
|
|
222
|
+
|
|
223
|
+
Other endpoints in LenS: `POST /gamification/quests/{id}/claim` and `POST /gamification/chest/claim` (both return a
|
|
224
|
+
Reward; the chest answers 409 until every step is done), `GET /gamification/achievements/catalog` (each catalog item
|
|
225
|
+
plus `earned_at` and `progress` 0..1), `GET /gamification/activity?days=N` (per-day rows for a heatmap, 1 to 120
|
|
226
|
+
days; days without activity have no row).
|
|
227
|
+
|
|
228
|
+
### Client wiring
|
|
229
|
+
|
|
230
|
+
One function, "play a reward", is called from the success handler of every mutation that can grant XP, with the
|
|
231
|
+
Reward and the anchor captured at press time:
|
|
232
|
+
|
|
233
|
+
1. The reward is missing or `duplicate`: invalidate the game queries and stop. Nothing to celebrate.
|
|
234
|
+
2. If `xp_earned > 0`, or it levelled up, or it brought achievements: call the reward system
|
|
235
|
+
(`rewardXp({ xp: xp_earned, anchor, levelUp: leveled_up ? { level } : undefined, achievements })`,
|
|
236
|
+
COMPONENTS.md).
|
|
237
|
+
3. After **1100 ms** when XP was earned (the 400 ms merge window + the 700 ms flight; otherwise at once): write the
|
|
238
|
+
new totals into the cached HUD and invalidate every game query. The bar fills at the moment the chip visibly
|
|
239
|
+
arrives; the refetch then replaces the optimistic values.
|
|
240
|
+
4. The optimistic patch copies `level`, `total_xp`, `level_floor`, `next_level_xp`; sets the streak to
|
|
241
|
+
`{ current: reward.streak, longest: max(old longest, reward.streak), state: 'done' }`; sets `today.xp` and
|
|
242
|
+
`today.goal` from `daily_xp` / `daily_goal`. It **never moves totals backwards**: when
|
|
243
|
+
`reward.total_xp < hud.total_xp` the HUD is kept as it is, because two rewards can land out of order.
|
|
244
|
+
5. All game queries share a key prefix, so one invalidation refreshes the HUD, path, quests, chest and badges.
|
|
245
|
+
6. A write that earns XP **without** returning a Reward (a side effect of another API) emits a small "HUD is stale"
|
|
246
|
+
signal that the shell subscribes to and answers with the same invalidation. Prefer returning a Reward.
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
# Icons
|
|
2
|
+
|
|
3
|
+
How the duotone icon set is made, the rules that keep it even, and how to set up the same pipeline in another
|
|
4
|
+
project. Nothing here is copied from a file: a project builds its own small generator from this description. The
|
|
5
|
+
component that paints an icon (`<Icon name tone size glow />`) is described in `COMPONENTS.md`.
|
|
6
|
+
|
|
7
|
+
## 1. The method in one paragraph
|
|
8
|
+
|
|
9
|
+
Base shapes come from **Lucide** (ISC licence), an open icon family drawn on a 24 px grid with round caps and joins.
|
|
10
|
+
Each icon of the set is a short **recipe**: which Lucide icon, and which of its drawing nodes go into which **layer**
|
|
11
|
+
(`main`, `detail`, `fine`, `solid`, `glint`, `cut`). A small **generator** reads the recipes and Lucide's node data
|
|
12
|
+
and writes the **registry**: one data file with path data per layer per icon. The registry is generated and never
|
|
13
|
+
edited by hand; the `Icon` component and any export script only read it. A **preview sheet** renders icons from the
|
|
14
|
+
recipes at their real size, so every change is judged at 24 px before it is built.
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
recipes (one per icon) + Lucide node data --generator--> icon registry --Icon component / export--> UI, SVG files
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
LenS has 68 icons made this way: 67 on Lucide shapes and one drawing of its own (a treasure chest, which Lucide does
|
|
21
|
+
not have).
|
|
22
|
+
|
|
23
|
+
Start from an established family; do not type path coordinates by hand. A hand-typed set ends up with uneven visual
|
|
24
|
+
weight between neighbours, no optical correction (round shapes look smaller than boxy ones, pointed shapes look
|
|
25
|
+
off-centre) and a different corner radius on every icon. A family has already solved these, and the recipes add the
|
|
26
|
+
project's identity (duotone fill, tones, one accent) on top of it.
|
|
27
|
+
|
|
28
|
+
## 2. The layer model
|
|
29
|
+
|
|
30
|
+
Grid: 24x24 viewBox, 2 units of padding (live area 2..22), stroke 1.75, round caps and joins.
|
|
31
|
+
|
|
32
|
+
Each registry entry is `{ tone, main?, detail?, fine?, solid?, glint?, cut?, vector? }`; every layer is one SVG path
|
|
33
|
+
data string (several subpaths allowed). Layers are painted in this order:
|
|
34
|
+
|
|
35
|
+
| Layer | Paint | Use |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| `main` | tone gradient **stroke 1.75** + the same gradient as **fill at 18 %** | The silhouette. This fill is what makes the set "duotone". Must be closed paths |
|
|
38
|
+
| `detail` | gradient stroke 1.75, no fill | Inner lines, handles, check marks; whole glyphs that have no silhouette |
|
|
39
|
+
| `fine` | gradient stroke 1.5 | Sparks, small sparkles, speed lines |
|
|
40
|
+
| `solid` | gradient fill at 100 %, no stroke | Dots, pips, one filled accent shape |
|
|
41
|
+
| `glint` | white stroke 1.25 at 60 % opacity | A short highlight "reflection". Dropped in mono |
|
|
42
|
+
| `cut` | a slash stroked in the paint, **and** a mask that knocks a 4.25 unit wide gap out of every other layer | "Off" variants (mic-off): the slash gets 1.25 units of clearance on each side |
|
|
43
|
+
|
|
44
|
+
The `cut` mask: a `<mask>` in user space covering the 24 grid, a white rectangle with the slash path stroked in black
|
|
45
|
+
at width 4.25. Every other layer goes into a group that uses the mask; the slash itself is drawn after the group.
|
|
46
|
+
|
|
47
|
+
### Paint
|
|
48
|
+
|
|
49
|
+
- One gradient per tone: 3 stops, *light tint → the tone → the neighbouring hue*. Each stop has a colour for the dark
|
|
50
|
+
theme and an ink-safe colour for the light theme:
|
|
51
|
+
|
|
52
|
+
| Tone | Offsets | Dark stops | Light stops | Glow channels |
|
|
53
|
+
|---|---|---|---|---|
|
|
54
|
+
| lime | 0 / .55 / 1 | `#F0FF9E` `#B8FF3D` `#3DF5D8` | `#4F9400` `#3D7A00` `#00786A` | 184 255 61 |
|
|
55
|
+
| aqua | 0 / .5 / 1 | `#B9FFF6` `#3DF5D8` `#2E9BFF` | `#00957F` `#00786A` `#1D5FD0` | 61 245 216 |
|
|
56
|
+
| iris | 0 / .5 / 1 | `#DAD4FF` `#8B7BFF` `#E056E8` | `#6E5CF5` `#5A45EE` `#A21FA0` | 139 123 255 |
|
|
57
|
+
| flare | 0 / .5 / 1 | `#FFC4F0` `#FF4FD8` `#9D6BFF` | `#CC2FB0` `#B8129A` `#6A3FD8` | 255 79 216 |
|
|
58
|
+
| amber | 0 / .5 / 1 | `#FFE7B0` `#FFB23E` `#FF7F3D` | `#B06A00` `#955800` `#C2410C` | 255 178 62 |
|
|
59
|
+
| ember | 0 / .55 / 1 | `#FFE27A` `#FF9B3D` `#FF4D3D` | `#D9530F` `#C2410C` `#B3261E` | 255 106 43 |
|
|
60
|
+
| gold | 0 / .5 / 1 | `#FFF2B0` `#FFD65A` `#E0A21F` | `#9C7000` `#8A6200` `#9A4F00` | 255 214 90 |
|
|
61
|
+
| coral | 0 / .5 / 1 | `#FFC2CD` `#FF5C7A` `#F0407E` | `#E0355A` `#CC1A40` `#A8124F` | 255 92 122 |
|
|
62
|
+
| spectral | 0 / .4 / .75 / 1 | `#B8FF3D` `#3DF5D8` `#8B7BFF` `#FF4FD8` | `#3D7A00` `#00786A` `#5A45EE` `#B8129A` | 61 245 216 |
|
|
63
|
+
|
|
64
|
+
`spectral` is the 4-stop brand gradient, for the product's own mark only.
|
|
65
|
+
- The gradient is a `linearGradient` in `userSpaceOnUse` from `(3,3)` to `(21,21)`. An icon can override the
|
|
66
|
+
direction with `vector: [x1, y1, x2, y2]` (a flame runs bottom to top, a bolt tip to tip).
|
|
67
|
+
- **Theme switch inside the SVG**: each `<stop>` carries the dark colour as its `stop-color` attribute and
|
|
68
|
+
`style="stop-color: light-dark(<light>, <dark>)"`. The attribute is the fallback; `light-dark()` follows the
|
|
69
|
+
`color-scheme` set on the root per theme (TOKENS.md §1). Without `color-scheme` the light stops never apply.
|
|
70
|
+
- Gradient and mask ids must be unique per rendered icon (React: `useId()` with the colons removed). Two icons with
|
|
71
|
+
the same hard-coded id share one gradient, and the second paints with the first one's colours.
|
|
72
|
+
- `tone="mono"` paints every layer with `currentColor`, emits no gradient and drops the glint; the 18 % fill stays, so
|
|
73
|
+
a mono icon is still duotone.
|
|
74
|
+
- Keep the registry and the tone table as **pure data with no runtime imports**, so a build script can load the same
|
|
75
|
+
files the app uses.
|
|
76
|
+
|
|
77
|
+
## 3. Recipes
|
|
78
|
+
|
|
79
|
+
A recipe assigns Lucide nodes to layers. Each icon of the `lucide-react` package is one module,
|
|
80
|
+
`lucide-react/dist/esm/icons/<kebab-name>.js`, that exports `__iconNode`: an ordered array of nodes
|
|
81
|
+
(`[tag, attributes]`, tags `path`, `circle`, `rect`, `line`, `polyline`, `ellipse`). A node is referred to by its
|
|
82
|
+
index in that array. Print the array once when writing a recipe (index, tag, attributes):
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
node -e "import('lucide-react/dist/esm/icons/trophy.js').then(m => m.__iconNode.forEach((n, i) => console.log(i, n[0], JSON.stringify(n[1]))))"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`__iconNode` and the module path are internals of the package, not a documented API: that is one more reason for the
|
|
89
|
+
exact version pin (§5). If another version lays them out differently, read the node data from wherever that version
|
|
90
|
+
keeps it and keep the rest of the method.
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
// one Lucide icon: node 3 is the closed book outline, 0-2 are the text lines
|
|
94
|
+
reading: { tone: 'aqua', from: 'book-open-text', main: [3], detail: [0, 1, 2], glint: 'M4.5 7.5v-2' }
|
|
95
|
+
|
|
96
|
+
// two Lucide icons: whole nodes are scaled and moved, never retyped
|
|
97
|
+
level: { tone: 'iris', parts: [{ from: 'hexagon', main: 'all' },
|
|
98
|
+
{ from: 'chevrons-up', detail: 'all', scale: 0.75, dx: 3, dy: 3 }] }
|
|
99
|
+
|
|
100
|
+
// a glyph with no silhouette: stroke only
|
|
101
|
+
check: { tone: 'lime', from: 'check', detail: 'all' }
|
|
102
|
+
|
|
103
|
+
// no Lucide equivalent (last resort): a drawing of the project's own
|
|
104
|
+
chest: { tone: 'gold', custom: { main: '...', detail: '...', glint: '...' } }
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
| Key | Meaning |
|
|
108
|
+
|---|---|
|
|
109
|
+
| `tone` | The default paint: one of the eight tones, `mono` or `spectral` |
|
|
110
|
+
| `from` | The Lucide icon name (kebab-case) |
|
|
111
|
+
| `main` `detail` `fine` `solid` `glint` `cut` | What goes into the layer: node indexes (`[0, 2]`), `'all'`, `'rest'` (the nodes no other layer took), raw path data (`'M6 8l1-1'`), or a list mixing indexes and path data |
|
|
112
|
+
| `scale` `dx` `dy` | Uniform scale about the origin, then a translate: `p' = p * scale + (dx, dy)`. To scale about the centre of the grid use `dx = dy = 12 * (1 - scale)`. Applies to Lucide nodes only; **raw path data is never transformed** |
|
|
113
|
+
| `parts` | A list of `{ from, scale, dx, dy, <layers> }` to combine icons. Layers written next to `parts` may only be raw path data |
|
|
114
|
+
| `custom` | `{ <layer>: path data }`: a drawing of the project's own |
|
|
115
|
+
| `vector` | Gradient vector override |
|
|
116
|
+
| `openMain` | `true` once the preview has confirmed that an open `main` path fills correctly; silences the warning |
|
|
117
|
+
|
|
118
|
+
A node may sit in two layers (three dots as `detail: 'all', solid: 'all'` stay solid at stroke 1.75). A helper
|
|
119
|
+
`dot(cx, cy, r)` that returns the path of a circle keeps pips identical across the set.
|
|
120
|
+
|
|
121
|
+
Three recipe techniques recur:
|
|
122
|
+
|
|
123
|
+
- **Split**: the closed outer node → `main`, everything else → `detail` (`trophy`, `calendar`, `settings`).
|
|
124
|
+
- **Combine**: a container from one icon and a mark from another, scaled and centred (a hexagon + a check for the
|
|
125
|
+
quiz, a circle + a small solid sparkle for "new", a medal + a solid star for "mastered").
|
|
126
|
+
- **Re-cut**: when Lucide draws one path that mixes a closed part and an open part (headphones: ear cups + band), the
|
|
127
|
+
same coordinates are written as two path strings, the closed part in `main` and the open part in `detail`. The
|
|
128
|
+
coordinates are Lucide's; nothing is redrawn.
|
|
129
|
+
|
|
130
|
+
## 4. The customisation rules
|
|
131
|
+
|
|
132
|
+
1. **One closed silhouette per object icon goes to `main`.** Closed shape = fill; open glyph = stroke only. Pure
|
|
133
|
+
glyphs (check, cross, chevrons, arrows, plus, menu, more, search, link, edit, external, log-out) have no `main`.
|
|
134
|
+
A filled lens or door bracket reads as a button at 13-18 px.
|
|
135
|
+
2. **At most one accent per icon**: a `solid` pip **or** a `glint`, never both. A pip is a dot of radius 1.25 (it
|
|
136
|
+
keeps a 1.5 unit gap to its frame). A glint is 2 units long, sits top-left inside the silhouette and follows its
|
|
137
|
+
contour; it is for glossy objects (bolt, flame, trophy, gem, book, bulb, chest).
|
|
138
|
+
3. **`fine` sparks only on game icons that celebrate.** In practice use them even less: LenS keeps a spark on a
|
|
139
|
+
single icon, because the reward icons also run at 14-16 px inside chips, where a spark turns into noise, and every
|
|
140
|
+
base shape already fills the 2..22 box.
|
|
141
|
+
4. **Keep Lucide's proportions and corner radii.** Combine icons with `scale` / `dx` / `dy`, never by retyping
|
|
142
|
+
coordinates. A custom drawing uses the same vocabulary: 24 grid, 2 units of padding, corner radii 1 and 2, round
|
|
143
|
+
joins.
|
|
144
|
+
5. **Equal visual weight at 22-24 px.** Icons that sit side by side (a navigation row, a transport set) must fill the
|
|
145
|
+
same optical box. Lucide's play / pause / stop are 18 units tall and heavier than its other actions, so LenS
|
|
146
|
+
scales them to about 15 units about the grid centre (`scale .78-.85`). Keep the inside open: at most 3-4 strokes
|
|
147
|
+
inside the silhouette, gaps of at least 1.5 units (four half-size sound bars touch at 22 px; three at a 3.5 unit
|
|
148
|
+
pitch do not).
|
|
149
|
+
6. **Every icon must read in mono and on the light theme.** No meaning carried by the gradient alone.
|
|
150
|
+
7. **A family of states shares one frame.** LenS's item states are built around one circle (or its medal) with a
|
|
151
|
+
single mark each (sparkle, check, half disc, turning arrows, star), so they differ by the mark alone at 16-20 px.
|
|
152
|
+
|
|
153
|
+
## 5. The generator
|
|
154
|
+
|
|
155
|
+
A script of a few hundred lines, run by a package script (`icons:build`). `lucide-react` is a **pinned development
|
|
156
|
+
dependency**: an exact version, not a range (LenS: `"lucide-react": "1.7.0"`). Node indexes can change between
|
|
157
|
+
versions, and a silent upgrade would reshuffle layers. The generator and the preview are its only readers. Two more
|
|
158
|
+
development dependencies do the heavy lifting in LenS, as examples: `svgpath` (transform and rounding of path data)
|
|
159
|
+
and `@resvg/resvg-js` (SVG to PNG for the preview sheet).
|
|
160
|
+
|
|
161
|
+
What it does:
|
|
162
|
+
|
|
163
|
+
1. Reads an ordered **name list** (sections and icon names). The icon-name type of the app is derived from the
|
|
164
|
+
registry keys, so renaming an icon is a breaking change that the type-checker finds.
|
|
165
|
+
2. For each recipe, loads the Lucide icon's nodes, converts every node to path data (circle, rect with rounded
|
|
166
|
+
corners, line, polyline, ellipse → `M ... Z` paths), applies `scale` / `dx` / `dy`, rounds to two decimals and
|
|
167
|
+
concatenates the nodes of each layer into one string. The path-data library does the transform and the rounding.
|
|
168
|
+
3. Validates, then writes the registry file with a "generated, do not edit" header that names the Lucide version and
|
|
169
|
+
the licence file.
|
|
170
|
+
|
|
171
|
+
It must **fail without writing** on: an unknown Lucide icon or node index; an unknown recipe key or tone; a name that
|
|
172
|
+
is missing, duplicated, unlisted or out of order compared with the name list; a `'rest'` that selects nothing; a
|
|
173
|
+
`from` that no layer uses; any coordinate outside the 0..24 grid (sample points along curves, not only end points).
|
|
174
|
+
|
|
175
|
+
It **warns** on: an open subpath in `main` or `solid` (the fill would get a straight, unstroked closing edge; check
|
|
176
|
+
the preview, then set `openMain`); a solid pip together with a glint.
|
|
177
|
+
|
|
178
|
+
Unit-test the path helpers (node → path, transform, bounds, closed-subpath detection) and the resolver's failures.
|
|
179
|
+
|
|
180
|
+
Adding an icon is three steps: add the name to its section in the name list; add the recipe at the same position;
|
|
181
|
+
preview it, run the build, and commit the recipe together with the regenerated registry.
|
|
182
|
+
|
|
183
|
+
## 6. The preview sheet
|
|
184
|
+
|
|
185
|
+
A second script renders a contact sheet PNG **straight from the recipes** (not from the registry), so an edit is
|
|
186
|
+
visible before any build. It uses the same layer-to-paint function as the app and an SVG rasteriser (§5), and writes
|
|
187
|
+
its output outside the repository, so many previews can run in parallel without touching tracked files.
|
|
188
|
+
|
|
189
|
+
Per icon the sheet shows its name, tone and Lucide base, then the icon at **24 / 32 / 48 px** in three rows:
|
|
190
|
+
|
|
191
|
+
- in its tone on the dark surface (`#0A0C14`);
|
|
192
|
+
- in its tone on the light surface (`#F4F6FB`) with the light gradient stops;
|
|
193
|
+
- in mono (ink `#D5DAE8` on dark).
|
|
194
|
+
|
|
195
|
+
Options worth having: pick by section, by name or all; a compare mode that puts the previously committed icon next to
|
|
196
|
+
the new one; the number of columns; the device scale (2 by default).
|
|
197
|
+
|
|
198
|
+
How to judge: **look at the 24 px column first**, next to the icon's neighbours. Zoomed-in beauty is irrelevant.
|
|
199
|
+
Keep a sheet to about 12 icons so an image viewer does not shrink it below real size.
|
|
200
|
+
|
|
201
|
+
An export step can follow the build for consumers outside the app: one standalone SVG per icon in its default tone,
|
|
202
|
+
PNGs at 2x, and a static gallery page with every icon at 48 / 24 / 16 px and a strip of all tones. Those files are
|
|
203
|
+
regenerated from the registry and never edited.
|
|
204
|
+
|
|
205
|
+
## 7. Licence obligation
|
|
206
|
+
|
|
207
|
+
Lucide is ISC licensed; parts of it derive from Feather, which is MIT. Both require that the copyright notice and the
|
|
208
|
+
licence text accompany copies. Path data taken from Lucide and re-layered is a derived work, so:
|
|
209
|
+
|
|
210
|
+
- **Ship the licence text next to the registry** (a `LICENSE-lucide.txt` beside the generated file), as a verbatim
|
|
211
|
+
copy of `node_modules/lucide-react/LICENSE`, the licence file of the installed package.
|
|
212
|
+
- Name the source and the version in the generated file's header.
|
|
213
|
+
- Copy the licence again whenever the pinned version changes, then rebuild and check the preview.
|
|
214
|
+
|
|
215
|
+
## 8. Alternative routes
|
|
216
|
+
|
|
217
|
+
| Route | What it is | Trade-off |
|
|
218
|
+
|---|---|---|
|
|
219
|
+
| **Another open stroke family** | Tabler (MIT, 24 grid, stroke 2), Iconoir (MIT, stroke 1.5), Heroicons outline (MIT, stroke 1.5), Material Symbols (Apache 2.0). The same recipe method applies: their SVGs are 24 grid, unfilled, round caps. Use **one** family for the whole set and one stroke width | The set looks like that family; node structure and coverage differ, so recipes are not portable between families. Read the licence of the release in use and ship it the same way |
|
|
220
|
+
| **A ready-made duotone family** | Phosphor duotone (MIT, 256 grid, filled outlines + a 20 % background shape), Solar duotone (CC BY 4.0: **attribution required**) | Two-layer art out of the box, but the shapes are fills, not strokes: scale to 24, put outlines in `solid` and add a fill-only tint layer. The stroke width can no longer be tuned. Paid duotone sets (Font Awesome Pro) must not be copied |
|
|
221
|
+
| **Drawing in a vector tool** | One 24x24 frame per icon, 20x20 live area, keyline shapes (circle 20, square 18, portrait 16x20, landscape 20x16), strokes not outlined, layers named after the layer model; export, optimise, copy each layer's path into the registry | Best quality and a unique look; needs a person with a designer's eye and is the slowest route |
|
|
222
|
+
| **Image-model concepts, then redraw** | Generate one contact sheet so the style is shared, use it as a **reference** and redraw each icon on the grid | Good for finding metaphors quickly. Never ship traced output: tracing yields filled blobs with hundreds of nodes, no stroke and no layers. Check the model's terms for commercial use |
|
|
223
|
+
|
|
224
|
+
The recipe method and a vector tool combine well: a family for the generic 90 %, `custom` drawings for the few icons
|
|
225
|
+
that carry the product's identity.
|
|
226
|
+
|
|
227
|
+
## 9. Checklist before an icon is committed
|
|
228
|
+
|
|
229
|
+
The drawing rules are §4 (silhouette in `main`, one accent, the family's radii, equal optical box, open insides); the
|
|
230
|
+
generator enforces the grid and warns about open fills (§5). What is left to check by eye and by hand:
|
|
231
|
+
|
|
232
|
+
- [ ] Judged at **22-24 px**, at 1x, on the dark canvas, next to its neighbours; then at 16 px where it is used small.
|
|
233
|
+
- [ ] Reads in mono (toolbar, disabled, on a lime disc) and on the light theme.
|
|
234
|
+
- [ ] One stroke width for the whole set (1.75); `fine` (1.5) only for sparks.
|
|
235
|
+
- [ ] Names are nouns for the object or the job, kebab-case, stable.
|
|
236
|
+
- [ ] Recipe, regenerated registry and exported files are committed together; nothing generated was hand-edited.
|
|
237
|
+
- [ ] The licence text sits next to the registry and matches the pinned version.
|
|
238
|
+
|
|
239
|
+
## 10. Using icons in the UI
|
|
240
|
+
|
|
241
|
+
- Sizes: 22 px in tabs and the rail, 16-20 px inside buttons, 18-36 px on round buttons by size, 26 px on the dial's
|
|
242
|
+
menu items, 13-15 px in chips.
|
|
243
|
+
- A tone is a meaning (TOKENS.md §4): an icon takes the tone of the thing it stands for, not a random pretty colour.
|
|
244
|
+
Inactive, disabled and "on a neon fill" are `mono`.
|
|
245
|
+
- `glow` only for the active navigation item, the current step, a just-earned reward.
|
|
246
|
+
- Decorative by default; an icon-only control gets `aria-label` on the control.
|
|
247
|
+
- Icon names that come from a server (a quest's icon) are looked up with a fallback: an unknown name must render a
|
|
248
|
+
default icon, not crash the page.
|
|
249
|
+
- Brand logos (a sign-in provider's mark) are used as supplied, unrecoloured, without glow.
|