Skip to Content

Example: Adding an Icon to glyphicons-v1

A complete, nothing-skipped walkthrough: adding one new icon, wrench-adjustable, to the existing icons/glyphicons-v1/halflings/ folder. Every command below is meant to be run for real, in order.

This is the “existing sub-folder” case — the fast path. If the sub-folder itself doesn’t exist yet, that’s a different (longer) process — see Adding a whole new icon set instead.

1. Add the icon asset

glyphicons-v1 ships as an icon font — each .svg is one glyph exported from that font, named after its ligature code (icon_uni<CODE>.svg), not a descriptive name. Add the exported file, numbered one past the last one in the folder:

icons/glyphicons-v1/halflings/icon_uniE261.svg

2. Add the entry to mapping.json

glyphicons-v1 is the one library whose mapping.json bakes the sub-library name into the key twice: once as the leading space-separated word, once again as a prefix on the classname itself. Every other library just uses the plain classname (see Normalize mapping.json).

icons/glyphicons-v1/halflings/mapping.json
{ // ...existing entries "halflings halflings-wrench-adjustable": "icon_uniE261.svg" }

3. mapping-with-filepath.json — there isn’t one

Unlike glyphicons-v2 and phpc, glyphicons-v1 has no combined mapping file and no generate-mapping.py step. IconDropdown.tsx imports each sub-folder’s mapping.json directly, by its literal path (see the import question):

import iconsGlyphiconsV1Halflings from "../../icons/glyphicons-v1/halflings/mapping.json";

Since that import already points at the file you just edited in step 2, the data side is done — skip straight to keywords.

4. Regenerate keywords.json

icons/glyphicons-v1/halflings/mapping.json is already one of the hand-written tuples in script/generate-keywords.py’s sets list, with "halflings" as the prefix to strip — no edit needed there for an existing sub-folder. Just re-run the generator:

python3 script/generate-keywords.py

Trace of what it just did for halflings halflings-wrench-adjustable (see Keywords & Translations for the full algorithm):

  1. Take the last space-separated part of the key: "halflings-wrench-adjustable"
  2. Strip the halflings- prefix: "wrench-adjustable"
  3. Split: ["wrench", "adjustable"]
  4. Translate: wrench"clé à molette" (already in translations-en-fr.json), adjustable → not found, falls back to "adjustable" unchanged
  5. FR phrase "clé à molette adjustable" differs from EN "wrench adjustable" → added as a keyword
  6. More than one word → no-separator join "wrenchadjustable" also added
icons/glyphicons-v1/halflings/keywords.json
"halflings halflings-wrench-adjustable": ["clé à molette adjustable", "wrenchadjustable"]

5. (Optional) Add the missing translation

script/translations-en-fr.json
{ // ...existing entries "adjustable": "réglable" }

Re-run the same command as step 4:

icons/glyphicons-v1/halflings/keywords.json
"halflings halflings-wrench-adjustable": ["clé à molette réglable", "wrenchadjustable"]

6. IconDropdown.tsx — no change needed

This is an existing sub-folder: iconsGlyphiconsV1Halflings and its keywords are already imported and already wired into v1Sets / v1KeywordSets. Nothing to touch here for this case — that’s only required when the sub-folder itself is brand new, or for a genuinely new top-level library (see Adding a whole new icon set, part B).

7. Verify

Run the app, open IconDropdown, and confirm the icon is findable by:

  • wrench-adjustable (English classname)
  • clé à molette réglable (French translation)
  • wrenchadjustable (no-separator English)

Files touched

FileWhat happened
icons/glyphicons-v1/halflings/icon_uniE261.svgNew asset
icons/glyphicons-v1/halflings/mapping.jsonHand-edited
icons/glyphicons-v1/halflings/keywords.jsonRegenerated (generate-keywords.py)
script/translations-en-fr.jsonHand-edited, optional

Notice what’s missing compared to the glyphicons-v2 example: no generate-mapping.py, no combined mapping file, no master mapping. That asymmetry is the whole point of the import questionglyphicons-v1 is the library where the icon data pipeline is fully manual, not just the keywords.

Last updated on