@campo-design/icons 0.0.0-stage → 0.1.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Joshua Litchfield
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,83 @@
1
- # Temporary Holding Version
1
+ # @campo-design/icons
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Campo's icons are [Phosphor](https://phosphoricons.com) (MIT licensed). This
4
+ package pins one Phosphor version, sets Campo's default weights, and gives every
5
+ icon name a TypeScript type. It doesn't depend on any component library.
6
+ `@campo-design/webawesome/icons` uses it to make Phosphor Web Awesome's icon set.
7
+
8
+ ## Weights
9
+
10
+ Phosphor draws every icon in six weights: `thin`, `light`, `regular`, `bold`,
11
+ `fill` and `duotone`.
12
+
13
+ | Use | Weight | Why |
14
+ | --- | --- | --- |
15
+ | Content icons (`defaultWeight`) | `regular` | Its stroke matches body text at 16-24px |
16
+ | Icons inside components (`uiWeight`) | `bold` | Components draw these small (often 12-14px), where regular's strokes get faint |
17
+
18
+ Pick another weight per icon when the design calls for it, for example `fill`
19
+ for a selected state.
20
+
21
+ ## How icons load
22
+
23
+ Phosphor is 1,500+ icons × 6 weights, about 36 MB of SVG files, so nothing
24
+ bundles all of it.
25
+
26
+ - **Any icon:** `iconUrl(name, { weight })` returns the URL of its SVG file. By
27
+ default that's the exact Phosphor version installed here on the jsDelivr CDN,
28
+ so the icons always match the names in the types. Only the icons a page
29
+ actually shows get downloaded, and browsers cache them.
30
+ - **Interface icons** (chevrons, close, check, eye…): `uiIcons` holds about 60
31
+ of them as SVG strings, built into the package. Components need these
32
+ instantly, and they still work offline or when a CDN is blocked.
33
+
34
+ ### Self-hosting
35
+
36
+ A CDN can be blocked by a strict network or a page's Content Security Policy.
37
+ To serve the icons yourself, copy Phosphor's `assets` folder into your site and
38
+ point `base` at it:
39
+
40
+ ```sh
41
+ cp -R node_modules/@phosphor-icons/core/assets public/phosphor
42
+ ```
43
+
44
+ ```js
45
+ iconUrl('house', { base: '/phosphor/' }); // → /phosphor/regular/house.svg
46
+ registerCampoIcons({ base: '/phosphor/' }); // the Web Awesome version
47
+ ```
48
+
49
+ ## API
50
+
51
+ ```js
52
+ import { iconUrl, uiIcons, weights, defaultWeight, uiWeight } from '@campo-design/icons';
53
+
54
+ iconUrl('house'); // regular weight, from the CDN
55
+ iconUrl('house', { weight: 'bold' }); // …/bold/house-bold.svg
56
+ uiIcons['caret-down-bold']; // '<svg …>…</svg>'
57
+ ```
58
+
59
+ | Export | What it is |
60
+ | --- | --- |
61
+ | `iconUrl(name, { weight?, base? })` | URL of one icon's SVG |
62
+ | `fileStem(name, weight?)` | Phosphor's file name: `house`, `house-bold` |
63
+ | `uiIcons` | Inlined interface icons, keyed by file name |
64
+ | `weights`, `defaultWeight`, `uiWeight` | The six weights, and Campo's two defaults |
65
+ | `cdnBase`, `phosphorVersion` | Where icons load from, and which Phosphor version |
66
+ | `IconName`, `IconWeight` (types) | Every icon name and weight, for autocomplete |
67
+ | `@campo-design/icons/names.json` | Every icon name, as JSON |
68
+
69
+ Icon SVGs use `fill="currentColor"` and a square viewBox, so they take the
70
+ color of their text. Size them with font size (`1em`), not with icon-specific
71
+ values.
72
+
73
+ ## Adding an interface icon
74
+
75
+ When a component needs an icon that isn't inlined, add its Phosphor file name to
76
+ `UI_ICONS` in `scripts/build.js` and run `pnpm build`. The build fails if the
77
+ name doesn't exist in Phosphor.
78
+
79
+ ## Updating Phosphor
80
+
81
+ Phosphor is pinned to an exact version in `package.json`. Bumping it updates
82
+ the CDN URLs, the inlined icons and the name types together. Renamed or removed
83
+ icons then show up as type errors and build failures, not as blank icons.