ng-hub-ui-icons 22.0.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Carlos Morcillo
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 ADDED
@@ -0,0 +1,205 @@
1
+ # ng-hub-ui-icons
2
+
3
+ [![npm](https://img.shields.io/npm/v/ng-hub-ui-icons.svg)](https://www.npmjs.com/package/ng-hub-ui-icons)
4
+ [![license](https://img.shields.io/npm/l/ng-hub-ui-icons.svg)](LICENSE)
5
+
6
+ > Read this in other languages: [EspaΓ±ol](README.es.md)
7
+
8
+ Icon-set-**agnostic** icon rendering for Angular. Render **Font Awesome**, **Bootstrap Icons**, **Material Symbols**, **Solar** or your **own SVGs** through a single API β€” with **no hard dependency** on any icon pack. You load the set's CSS/font/SVG in your app; `ng-hub-ui-icons` only knows each set's naming convention and themes them uniformly through `--hub-icon-*` CSS variables.
9
+
10
+ Part of the [ng-hub-ui](https://hubui.dev/) ecosystem.
11
+
12
+ ## Documentation and Live Examples
13
+
14
+ Full documentation and interactive examples: **[hubui.dev](https://hubui.dev/)**
15
+
16
+ ## πŸš€ Quick Start
17
+
18
+ ### 1. Install
19
+
20
+ ```bash
21
+ npm install ng-hub-ui-icons
22
+ ```
23
+
24
+ Then load the icon set(s) you want in your app as usual β€” see [Supported icon sets](#-supported-icon-sets) for each set's link and stylesheet. This library does **not** ship any icon assets.
25
+
26
+ ### 2. Register your packs
27
+
28
+ ```ts
29
+ import { ApplicationConfig } from '@angular/core';
30
+ import { provideHubIcons, faPack, bootstrapPack, materialSymbolsPack, solarPack } from 'ng-hub-ui-icons';
31
+
32
+ export const appConfig: ApplicationConfig = {
33
+ providers: [
34
+ provideHubIcons({
35
+ defaultPack: 'fa',
36
+ packs: {
37
+ fa: faPack({ defaultVariant: 'solid' }),
38
+ bi: bootstrapPack(),
39
+ ms: materialSymbolsPack({ variant: 'outlined' }),
40
+ solar: solarPack({ variant: 'linear' })
41
+ }
42
+ })
43
+ ]
44
+ };
45
+ ```
46
+
47
+ ### 3. Use it
48
+
49
+ ```html
50
+ <!-- default pack (fa) -->
51
+ <hub-icon name="house" />
52
+
53
+ <!-- explicit pack / variant -->
54
+ <hub-icon name="house" pack="bi" />
55
+ <hub-icon name="home" pack="ms" variant="rounded" />
56
+
57
+ <!-- pack:variant:name shorthand -->
58
+ <hub-icon name="fa:brands:github" label="GitHub" />
59
+
60
+ <!-- size & color, accessible label -->
61
+ <hub-icon name="trash" color="var(--hub-sys-color-danger)" size="1.5rem" label="Delete" />
62
+ ```
63
+
64
+ ## 🎨 Supported icon sets
65
+
66
+ The library bundles **no** icon assets β€” it ships a thin preset per popular set and you load that set's stylesheet once in your app (`index.html` or global styles). Browse the set, pick names from it, and register its preset in `provideHubIcons`.
67
+
68
+ | Set | Preset | Browse icons | Add to your app (load once) |
69
+ | --- | --- | --- | --- |
70
+ | **Font Awesome** 6 | `faPack()` | [fontawesome.com/icons](https://fontawesome.com/icons) | `<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.1/css/all.min.css">` |
71
+ | **Bootstrap Icons** | `bootstrapPack()` | [icons.getbootstrap.com](https://icons.getbootstrap.com/) | `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">` |
72
+ | **Material Symbols** | `materialSymbolsPack()` | [fonts.google.com/icons](https://fonts.google.com/icons) | `<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200">` |
73
+ | **Solar** | `solarPack()` | [icon-sets.iconify.design/solar](https://icon-sets.iconify.design/solar/) | No webfont β€” load via [Iconify CSS](https://iconify.design/docs/usage/css/): `<link rel="stylesheet" href="https://api.iconify.design/solar.css?icons=home-bold,star-bold">` and point the pack `template` at the `.icon--solar--<name>-<variant>` classes (or use `svgPack`). |
74
+
75
+ ### Bring your own set
76
+
77
+ Any other source works without a preset:
78
+
79
+ - **Class-based** webfont β†’ [`classPack`](#custom-packs) with a `template` that builds its class names.
80
+ - **Ligature-based** font β†’ `ligaturePack`.
81
+ - **Inline SVG** β†’ `svgPack({ map })` (your own artwork, no third-party set).
82
+ - **SVG sprite** β†’ a pack returning `{ kind: 'use', href: '#id' }` (or `assets/sprite.svg#id`).
83
+ - **Images** (flags, logos, emoji) β†’ a pack returning `{ kind: 'img', src, alt }`.
84
+
85
+ > `size` themes every mode; `color` themes glyphs and `currentColor`/mask SVGs, but not raster images.
86
+
87
+ ## πŸ“¦ Description
88
+
89
+ `ng-hub-ui-icons` decouples *how you reference an icon* from *which icon set draws it*. A **pack** is a pure resolver `(name, variant?) β†’ render spec`; the library ships factories and presets for the popular sets but bundles none of them, so your bundle stays lean and you can mix sets freely. One `--hub-icon-*` token set themes every pack the same way.
90
+
91
+ ## 🎯 Features
92
+
93
+ - **Agnostic** β€” Font Awesome, Bootstrap Icons, Material Symbols (ligature + variable-font axes), Solar, sprites, inline SVG and `<img>` β€” all behind one API.
94
+ - **Zero icon dependencies** β€” no fonts/SVGs bundled; you load the set, the library formats it.
95
+ - **Component & directive** β€” `<hub-icon>` for standalone icons, `[hubIcon]` to decorate your own element.
96
+ - **Central registry** β€” `provideHubIcons({ defaultPack, packs })`; per-call `pack` / `variant` overrides, plus the `pack:variant:name` shorthand.
97
+ - **Uniform theming** β€” `--hub-icon-size` / `--hub-icon-color` (+ variable-font axes) work across every set.
98
+ - **Accessible** β€” `label` exposes `role="img"` + `aria-label`; label-less icons are `aria-hidden`.
99
+ - **Composable packs** β€” `classPack` / `ligaturePack` / `svgPack` factories for any custom set, plus sprite (`use`) and image (`img`) render modes.
100
+
101
+ ## βš™οΈ Usage
102
+
103
+ ### Component
104
+
105
+ ```html
106
+ <hub-icon name="house" />
107
+ <hub-icon name="house" pack="bi" />
108
+ <hub-icon name="home" pack="ms" variant="sharp" />
109
+ <hub-icon name="spinner" spin label="Loading" />
110
+ ```
111
+
112
+ ### Directive
113
+
114
+ Decorate an element you own β€” the directive keeps your classes and only manages the pack-resolved ones:
115
+
116
+ ```html
117
+ <i class="me-2" hubIcon name="house"></i>
118
+ <span [hubIcon]="'home'" pack="ms" variant="rounded"></span>
119
+ ```
120
+
121
+ > For directive-only usage (no `<hub-icon>` rendered anywhere), include the base styles once: `@use 'ng-hub-ui-icons/styles' as *;`.
122
+
123
+ ### Custom packs
124
+
125
+ ```ts
126
+ import { provideHubIcons, classPack, svgPack } from 'ng-hub-ui-icons';
127
+
128
+ provideHubIcons({
129
+ defaultPack: 'app',
130
+ packs: {
131
+ // any class-based set
132
+ myset: classPack({ template: (name, variant) => `ms ms-${variant ?? 'line'}-${name}`, defaultVariant: 'line' }),
133
+ // your own inline SVGs
134
+ app: svgPack({ map: { logo: '<svg viewBox="0 0 24 24">…</svg>' } })
135
+ }
136
+ });
137
+ ```
138
+
139
+ ### Theming
140
+
141
+ Every pack reads the same tokens, so you theme once:
142
+
143
+ ```css
144
+ .toolbar hub-icon {
145
+ --hub-icon-size: 1.25rem;
146
+ --hub-icon-color: var(--hub-sys-text-muted);
147
+ }
148
+
149
+ /* Material Symbols variable-font axes */
150
+ .filled hub-icon {
151
+ --hub-icon-fill: 1;
152
+ --hub-icon-weight: 600;
153
+ }
154
+ ```
155
+
156
+ ### Icons in other components
157
+
158
+ No adapter needed β€” just project a `<hub-icon>` as content. For example, inside an `ng-hub-ui` button the icon's side follows the markup order:
159
+
160
+ ```html
161
+ <button hubButton><hub-icon name="floppy-disk" /> Save</button>
162
+ <button hubButton>Next <hub-icon name="arrow-right" /></button>
163
+ ```
164
+
165
+ ## πŸ”§ API
166
+
167
+ ### `<hub-icon>` / `[hubIcon]` inputs
168
+
169
+ | Input | Type | Default | Description |
170
+ | ----- | ---- | ------- | ----------- |
171
+ | `name` | `string` | β€” | Icon name. Accepts the `pack:variant:name` / `pack:name` shorthand. |
172
+ | `pack` | `string` | `defaultPack` | Pack key; overrides a shorthand pack. |
173
+ | `variant` | `string` | pack default | Variant; overrides a shorthand variant. |
174
+ | `size` | `string` | `1em` | Per-instance size (`--hub-icon-size`). _(component only)_ |
175
+ | `color` | `string` | `currentColor` | Per-instance color (`--hub-icon-color`). _(component only)_ |
176
+ | `label` | `string` | β€” | Accessible label (`role="img"` + `aria-label`). _(component only)_ |
177
+ | `spin` | `boolean` | `false` | Continuously rotate. _(component only)_ |
178
+
179
+ ### Packs
180
+
181
+ `faPack(options?)` Β· `bootstrapPack()` Β· `materialSymbolsPack(options?)` Β· `solarPack(options?)` β€” built-in presets.
182
+ `classPack(options)` Β· `ligaturePack(options)` Β· `svgPack(options)` β€” generic factories for any set.
183
+
184
+ ## 🎨 Styling tokens
185
+
186
+ | Token | Default | Description |
187
+ | ----- | ------- | ----------- |
188
+ | `--hub-icon-size` | `1em` | Glyph font-size / SVG width & height |
189
+ | `--hub-icon-color` | `currentColor` | Glyph color / SVG fill |
190
+ | `--hub-icon-fill` | `0` | Material Symbols `FILL` axis |
191
+ | `--hub-icon-weight` | `400` | Material Symbols `wght` axis |
192
+ | `--hub-icon-grade` | `0` | Material Symbols `GRAD` axis |
193
+ | `--hub-icon-optical-size` | `24` | Material Symbols `opsz` axis |
194
+
195
+ ## β™Ώ Accessibility
196
+
197
+ Pass `label` for meaningful icons (rendered as `role="img"` with `aria-label`). Omit it for decorative icons, which are automatically `aria-hidden="true"`.
198
+
199
+ ## πŸ“Š Changelog
200
+
201
+ See [CHANGELOG.md](CHANGELOG.md).
202
+
203
+ ## πŸ“„ License
204
+
205
+ MIT Β© [Carlos Morcillo](https://www.carlosmorcillo.com)