ng-hub-ui-ds 22.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/README.md ADDED
@@ -0,0 +1,352 @@
1
+ # ng-hub-ui-ds
2
+
3
+ [Español](./README.es.md) | **English**
4
+
5
+ The shared **design-token foundation** for the [ng-hub-ui](https://hubui.dev/)
6
+ family. It ships the canonical `--hub-ref-*` (primitive) and `--hub-sys-*`
7
+ (semantic) CSS custom properties — colour ramps, spacing, radii, typography,
8
+ surfaces, semantic colours, shadows, focus ring and more — with light/dark and
9
+ **8 built-in themes**.
10
+
11
+ Import it **once** and every ng-hub-ui library (panels, forms, calendar, …)
12
+ reads the same palette. Re-theme in one place and the whole family follows.
13
+
14
+ > Framework-agnostic — it is just CSS variables. There is no Angular or JS
15
+ > dependency; ship the compiled CSS or the SCSS source.
16
+
17
+ ## Documentation and Live Examples
18
+
19
+ This package is part of [Hub UI](https://hubui.dev/), a collection of Angular
20
+ component libraries for standalone apps.
21
+
22
+ - Docs: https://hubui.dev/design-system/
23
+ - Hub UI: https://hubui.dev/
24
+
25
+ ## 🧩 Library Family `ng-hub-ui`
26
+
27
+ This package is the design-token foundation the rest of the **ng-hub-ui**
28
+ ecosystem reads from:
29
+
30
+ - [**ng-hub-ui-accordion**](https://www.npmjs.com/package/ng-hub-ui-accordion) (deprecated — use ng-hub-ui-panels)
31
+ - [**ng-hub-ui-action-sheet**](https://www.npmjs.com/package/ng-hub-ui-action-sheet)
32
+ - [**ng-hub-ui-avatar**](https://www.npmjs.com/package/ng-hub-ui-avatar)
33
+ - [**ng-hub-ui-board**](https://www.npmjs.com/package/ng-hub-ui-board)
34
+ - [**ng-hub-ui-breadcrumbs**](https://www.npmjs.com/package/ng-hub-ui-breadcrumbs)
35
+ - [**ng-hub-ui-calendar**](https://www.npmjs.com/package/ng-hub-ui-calendar)
36
+ - [**ng-hub-ui-dropdown**](https://www.npmjs.com/package/ng-hub-ui-dropdown)
37
+ - [**ng-hub-ui-ds**](https://www.npmjs.com/package/ng-hub-ui-ds) ← You are here
38
+ - [**ng-hub-ui-forms**](https://www.npmjs.com/package/ng-hub-ui-forms)
39
+ - [**ng-hub-ui-history**](https://www.npmjs.com/package/ng-hub-ui-history)
40
+ - [**ng-hub-ui-milestones**](https://www.npmjs.com/package/ng-hub-ui-milestones)
41
+ - [**ng-hub-ui-modal**](https://www.npmjs.com/package/ng-hub-ui-modal)
42
+ - [**ng-hub-ui-nav**](https://www.npmjs.com/package/ng-hub-ui-nav)
43
+ - [**ng-hub-ui-paginable**](https://www.npmjs.com/package/ng-hub-ui-paginable)
44
+ - [**ng-hub-ui-panels**](https://www.npmjs.com/package/ng-hub-ui-panels)
45
+ - [**ng-hub-ui-portal**](https://www.npmjs.com/package/ng-hub-ui-portal)
46
+ - [**ng-hub-ui-skeleton**](https://www.npmjs.com/package/ng-hub-ui-skeleton)
47
+ - [**ng-hub-ui-sortable**](https://www.npmjs.com/package/ng-hub-ui-sortable)
48
+ - [**ng-hub-ui-stepper**](https://www.npmjs.com/package/ng-hub-ui-stepper)
49
+ - [**ng-hub-ui-utils**](https://www.npmjs.com/package/ng-hub-ui-utils)
50
+
51
+ ---
52
+
53
+ ## 📋 Table of Contents
54
+
55
+ 1. [🧩 What is it and what is it for?](#-what-is-it-and-what-is-it-for)
56
+ 2. [📦 Installation](#-installation)
57
+ 3. [🚀 Import](#-import)
58
+ 4. [🧱 Architecture: the two layers](#-architecture-the-two-layers)
59
+ 5. [🎨 Semantic colours](#-semantic-colours)
60
+ 6. [🌗 Themes](#-themes)
61
+ 7. [🛠️ How to customise it](#️-how-to-customise-it)
62
+ 8. [🧩 SCSS functions (how it is generated internally)](#-scss-functions-how-it-is-generated-internally)
63
+ 9. [📋 Quick reference table](#-quick-reference-table)
64
+ 10. [📊 Changelog](#-changelog)
65
+ 11. [🤝 Contribution](#-contribution)
66
+ 12. [☕ Support](#-support)
67
+ 13. [📄 License](#-license)
68
+
69
+ ---
70
+
71
+ ## 🧩 What is it and what is it for?
72
+
73
+ Every ng-hub-ui library is themed with `--hub-*` CSS variables, but it does
74
+ **not define** the colours: it only **consumes** them (with sensible
75
+ fallbacks). This package is **the single source of truth** for those variables.
76
+
77
+ Without it, each library would use its fallback values in isolation. With it:
78
+
79
+ - **One single palette** feeds panels, forms, calendar, board… all at once.
80
+ - **Re-theme once** (a single token) and the change propagates across the whole
81
+ family.
82
+ - **Dark mode and 8 themes** ready, switchable with one attribute.
83
+ - You can use it in **your own CSS** too (`var(--hub-sys-color-info-subtle)`),
84
+ so your UI matches the components.
85
+
86
+ ---
87
+
88
+ ## 📦 Installation
89
+
90
+ ```bash
91
+ npm install ng-hub-ui-ds
92
+ ```
93
+
94
+ It has no dependencies. It is pure CSS/SCSS.
95
+
96
+ ---
97
+
98
+ ## 🚀 Import
99
+
100
+ Import it **once**, at the root of your application. Pick one path:
101
+
102
+ ### Drop-in CSS (any app, no Sass required)
103
+
104
+ ```css
105
+ @import 'ng-hub-ui-ds/styles/tokens/hub-tokens.css';
106
+ ```
107
+
108
+ or in `angular.json`:
109
+
110
+ ```json
111
+ "styles": [
112
+ "node_modules/ng-hub-ui-ds/styles/tokens/hub-tokens.css",
113
+ "src/styles.scss"
114
+ ]
115
+ ```
116
+
117
+ ### SCSS source (if you use Sass)
118
+
119
+ It emits exactly the same `:root` rules, and lets you reference the source:
120
+
121
+ ```scss
122
+ @use 'ng-hub-ui-ds/styles/tokens/hub-tokens';
123
+ ```
124
+
125
+ Every ng-hub-ui component already reads these variables. Reference them in your
126
+ own styles too:
127
+
128
+ ```css
129
+ .my-callout {
130
+ background: var(--hub-sys-color-info-subtle);
131
+ color: var(--hub-sys-color-info-emphasis);
132
+ border: 1px solid var(--hub-sys-color-info-border-subtle);
133
+ }
134
+ ```
135
+
136
+ ---
137
+
138
+ ## 🧱 Architecture: the two layers
139
+
140
+ The tokens follow a layered system:
141
+
142
+ | Layer | Prefix | What it is | Examples |
143
+ | -------------- | ------------------- | ------------------------------------------------------------- | ----------------------------------------------------------------------- |
144
+ | **Reference** | `--hub-ref-*` | Raw, context-free values | `--hub-ref-color-blue-500`, `--hub-ref-space-3`, `--hub-ref-radius-md` |
145
+ | **System** | `--hub-sys-*` | Meaningful assignments that components consume | `--hub-sys-color-primary`, `--hub-sys-surface-page`, `--hub-sys-text-primary` |
146
+ | **Container** | `--hub-container-*` | Inheritable bridge from `sys` to concrete containers/slots — a **re-base hook** | `--hub-container-bg`, `--hub-container-padding-x`, `--hub-container-gap` |
147
+
148
+ Golden rule: **components reference `sys` tokens only**. The `sys` tokens point
149
+ at the `ref` tokens. So changing a `sys` token re-themes; changing a `ref`
150
+ token adjusts the base palette.
151
+
152
+ ```text
153
+ --hub-ref-color-blue-500 → --hub-sys-color-primary → (consumed by components)
154
+ ```
155
+
156
+ The optional `container` layer sits on top of `sys` as a **re-base hook**:
157
+ overriding one `--hub-container-*` token on a subtree re-bases every descendant
158
+ container that reads it (e.g. `ng-hub-ui-panels`), without touching `sys`. Paired
159
+ spacing uses the directional `-x` / `-y` form only (`--hub-container-padding-x/-y`,
160
+ `--hub-container-margin-x/-y`) — no shorthand.
161
+
162
+ ---
163
+
164
+ ## 🎨 Semantic colours
165
+
166
+ Each semantic colour (`primary` · `success` · `danger` · `warning` · `info`)
167
+ exposes a **uniform family** of five tokens:
168
+
169
+ | Token | Typical use |
170
+ | ----------------------------------- | ---------------------------------------------- |
171
+ | `--hub-sys-color-<v>` | Solid colour (accent, icon, strong border) |
172
+ | `--hub-sys-color-<v>-subtle` | Faint background (banners, alerts) |
173
+ | `--hub-sys-color-<v>-border-subtle` | Faint border over the subtle background |
174
+ | `--hub-sys-color-<v>-emphasis` | Legible text over the subtle background |
175
+ | `--hub-sys-color-<v>-dark` | Dark variant of the colour |
176
+
177
+ Usage example (a callout that matches the rest of the family):
178
+
179
+ ```css
180
+ .my-callout {
181
+ background: var(--hub-sys-color-info-subtle);
182
+ color: var(--hub-sys-color-info-emphasis);
183
+ border: 1px solid var(--hub-sys-color-info-border-subtle);
184
+ }
185
+ ```
186
+
187
+ ---
188
+
189
+ ## 🌗 Themes
190
+
191
+ Activate a theme with the `data-theme` attribute on `<html>` (or on any
192
+ container to theme a region):
193
+
194
+ ```html
195
+ <html data-theme="dark">
196
+ <!-- light (default) · base · bootstrap · dark · sunset · forest · mono · terminal -->
197
+ </html>
198
+ ```
199
+
200
+ Because each theme **redefines the same tokens** with its own values,
201
+ everything that reads `--hub-sys-*` re-colours automatically, including your
202
+ own CSS.
203
+
204
+ ---
205
+
206
+ ## 🛠️ How to customise it
207
+
208
+ There are three mechanisms, from simplest to most advanced.
209
+
210
+ ### 1. Override a token (CSS) — the main path
211
+
212
+ Because every value is a CSS custom property, re-theming is a one-liner — and
213
+ it **cascades to the whole family**:
214
+
215
+ ```css
216
+ :root {
217
+ --hub-sys-color-primary: #7c3aed;
218
+ --hub-sys-color-primary-subtle: #ede9fe;
219
+ --hub-sys-color-primary-emphasis: #5b21b6;
220
+ }
221
+ ```
222
+
223
+ You can do it globally (`:root`), per theme (`[data-theme='dark']`) or per
224
+ region (`.my-section`).
225
+
226
+ ### 2. Add your own accent
227
+
228
+ Define a `--hub-sys-color-<name>` family and components that accept a semantic
229
+ variant pick it up **without changes**. For example, the panels alert
230
+ (`<hub-panel appearance="alert" variant="brand">`):
231
+
232
+ ```css
233
+ :root {
234
+ --hub-sys-color-brand: #9333ea;
235
+ --hub-sys-color-brand-subtle: #f3e8ff;
236
+ --hub-sys-color-brand-border-subtle: #d8b4fe;
237
+ --hub-sys-color-brand-emphasis: #6b21a8;
238
+ }
239
+ ```
240
+
241
+ > With just `--hub-sys-color-brand` (the base accent) it already works:
242
+ > components derive the rest with `color-mix`. Define the full family when you
243
+ > want exact tints.
244
+
245
+ ### 3. Create your own theme
246
+
247
+ Group your overrides under a theme attribute and activate it whenever you want:
248
+
249
+ ```css
250
+ [data-theme='corporate'] {
251
+ --hub-sys-color-primary: #0033a0;
252
+ --hub-sys-surface-page: #fbfcff;
253
+ --hub-sys-text-primary: #0a1f44;
254
+ /* …the rest of the tokens that differ from the base theme */
255
+ }
256
+ ```
257
+
258
+ ---
259
+
260
+ ## 🧩 SCSS functions (how it is generated internally)
261
+
262
+ The semantic colour families are **not written by hand**, and a theme only ever
263
+ sets the **accent** of each variant — `-subtle`, `-border-subtle` and `-emphasis`
264
+ are derived **once** in `:root` with `color-mix()` from the live accent, surface
265
+ and ink CSS variables. Adding a colour or a theme is uniform and boilerplate-free.
266
+
267
+ ```scss
268
+ $hub-variants: primary, success, danger, warning, info;
269
+
270
+ // One accent per variant, per theme — just the base colour.
271
+ $hub-accents-light: (
272
+ primary: var(--hub-ref-color-blue-500, #0d6efd),
273
+ success: var(--hub-ref-color-green-500, #198754),
274
+ danger: var(--hub-ref-color-red-500, #dc3545),
275
+ warning: var(--hub-ref-color-yellow-500, #ffc107),
276
+ info: var(--hub-ref-color-cyan-500, #0dcaf0)
277
+ );
278
+
279
+ // Sets ONLY --hub-sys-color-<variant> (the accent). Called in every theme block.
280
+ @mixin hub-color-accents($accents) {
281
+ @each $name in $hub-variants {
282
+ --hub-sys-color-#{$name}: #{map.get($accents, $name)};
283
+ }
284
+ }
285
+
286
+ // Derives the role family from the live accent + surface + ink. Emitted ONCE in
287
+ // :root; themes only override the inputs, so the family recomputes contextually.
288
+ @mixin hub-color-derive() {
289
+ @each $name in $hub-variants {
290
+ --hub-sys-color-#{$name}-subtle: color-mix(in srgb, var(--hub-sys-color-#{$name}) 12%, var(--hub-sys-surface-page, #fff));
291
+ --hub-sys-color-#{$name}-border-subtle: color-mix(in srgb, var(--hub-sys-color-#{$name}) 35%, var(--hub-sys-surface-page, #fff));
292
+ --hub-sys-color-#{$name}-emphasis: color-mix(in srgb, var(--hub-sys-color-#{$name}) 80%, var(--hub-sys-color-ink, #212529));
293
+ --hub-sys-color-#{$name}-dark: var(--hub-sys-color-#{$name}-emphasis); // back-compat alias
294
+ }
295
+ }
296
+
297
+ :root,
298
+ [data-theme='light'] {
299
+ @include hub-color-accents($hub-accents-light);
300
+ @include hub-color-derive();
301
+ }
302
+ ```
303
+
304
+ > You almost never need to touch the SCSS: because the family is derived from the
305
+ > **single accent** at runtime, overriding `--hub-sys-color-<variant>` in plain CSS
306
+ > — even on a subtree — recomputes `-subtle` / `-border-subtle` / `-emphasis`
307
+ > automatically. The maps + mixins are just the internal mechanism, useful if you
308
+ > contribute to the package or compile your own palette variant.
309
+
310
+ ---
311
+
312
+ ## 📋 Quick reference table
313
+
314
+ | I want to… | How |
315
+ | -------------------------- | ----------------------------------------------------------- |
316
+ | Use the palette | `@import '…/hub-tokens.css'` once |
317
+ | Change a global colour | `:root { --hub-sys-color-primary: … }` |
318
+ | Change dark mode | `[data-theme='dark'] { --hub-sys-… : … }` |
319
+ | Add your own accent | define `--hub-sys-color-<x>` (+ optional family) |
320
+ | Create a theme | `[data-theme='<name>'] { … }` and activate it |
321
+ | See all the tokens | the tokens page at [hubui.dev](https://hubui.dev/design-system/) |
322
+
323
+ ---
324
+
325
+ ## 📊 Changelog
326
+
327
+ See [CHANGELOG.md](./CHANGELOG.md).
328
+
329
+ ## 🤝 Contribution
330
+
331
+ Contributions are welcome.
332
+
333
+ 1. **Fork** the repository.
334
+ 2. **Create** a feature branch: `git checkout -b feature/amazing-feature`.
335
+ 3. **Commit** your changes: `git commit -m 'Add amazing feature'`.
336
+ 4. **Push** to your branch: `git push origin feature/amazing-feature`.
337
+ 5. **Submit** a pull request.
338
+
339
+ Repository: https://github.com/carlos-morcillo/ng-hub-ui-ds
340
+
341
+ ## ☕ Support
342
+
343
+ Do you like this package? You can support the project by buying a coffee ☕:
344
+ [!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://buymeacoffee.com/carlosmorcillo)
345
+
346
+ ## 📄 License
347
+
348
+ This project is licensed under the MIT License.
349
+
350
+ MIT © [Carlos Morcillo](https://www.carlosmorcillo.com)
351
+ </content>
352
+ </invoke>
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "ng-hub-ui-ds",
3
+ "version": "22.1.0",
4
+ "license": "MIT",
5
+ "scripts": {
6
+ "build:tokens": "sass styles/tokens/hub-tokens.scss styles/tokens/hub-tokens.css --style=expanded --no-source-map",
7
+ "prepublishOnly": "npm run build:tokens"
8
+ },
9
+ "description": "Design tokens for the ng-hub-ui family \u2014 the canonical `--hub-ref-*` (primitive) and `--hub-sys-*` (semantic) CSS custom properties, with light/dark and 8 built-in themes. Framework-agnostic: ship the compiled CSS or the SCSS source. Import once and every ng-hub-ui library reads the same palette.",
10
+ "author": "Carlos Morcillo <carlos.morcillo@me.com> (https://www.carlosmorcillo.com)",
11
+ "homepage": "https://hubui.dev/",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/carlos-morcillo/ng-hub-ui-ds.git"
15
+ },
16
+ "keywords": [
17
+ "design-tokens",
18
+ "design-system",
19
+ "css-variables",
20
+ "theme",
21
+ "dark-mode",
22
+ "scss",
23
+ "ng-hub-ui",
24
+ "hub-ui"
25
+ ],
26
+ "sideEffects": [
27
+ "**/*.css",
28
+ "**/*.scss"
29
+ ],
30
+ "exports": {
31
+ "./styles/tokens/hub-tokens.css": "./styles/tokens/hub-tokens.css",
32
+ "./styles/tokens/hub-tokens": "./styles/tokens/hub-tokens.scss",
33
+ "./styles/tokens/hub-tokens.scss": "./styles/tokens/hub-tokens.scss"
34
+ },
35
+ "files": [
36
+ "styles",
37
+ "README.md",
38
+ "README.es.md",
39
+ "CHANGELOG.md"
40
+ ],
41
+ "devDependencies": {
42
+ "sass": "^1.99.0"
43
+ }
44
+ }