ng-hub-ui-buttons 22.7.0 → 22.9.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 +59 -27
- package/fesm2022/ng-hub-ui-buttons.mjs +206 -43
- package/fesm2022/ng-hub-ui-buttons.mjs.map +1 -1
- package/ng-hub-ui-buttons-22.9.0.tgz +0 -0
- package/package.json +1 -1
- package/styles/_btn-mixins.scss +58 -17
- package/styles/_btn-theme.scss +49 -0
- package/styles/_index.scss +1 -0
- package/types/ng-hub-ui-buttons.d.ts +143 -9
- package/ng-hub-ui-buttons-22.7.0.tgz +0 -0
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ This library is part of the **ng-hub-ui** ecosystem:
|
|
|
51
51
|
## Features
|
|
52
52
|
|
|
53
53
|
- **Signal-based API** — all inputs use `input()`, `model()` and `output()`; fully `OnPush`-safe and compatible with zoneless apps.
|
|
54
|
-
- **Five variants ×
|
|
54
|
+
- **Five variants × nine colours** — `solid`, `outline`, `soft`, `ghost` and `link`, each available in `primary`, `secondary`, `success`, `danger`, `warning`, `info`, `neutral`, `light` and `dark`.
|
|
55
55
|
- **Four sizes** — `sm`, `md`, `lg`, `xl` with proportional padding and font scaling.
|
|
56
56
|
- **FAB with nine positions** — fixed-viewport placement at any corner, edge-center or screen-center via CSS logical properties (RTL-ready).
|
|
57
57
|
- **Speed Dial** — expandable FAB menu with `isOpen` two-way model, directional expansion and Escape close.
|
|
@@ -117,10 +117,9 @@ A single component with a dual selector — use it as an **element** or as an **
|
|
|
117
117
|
| Input | Type | Default | Description |
|
|
118
118
|
|-------|------|---------|-------------|
|
|
119
119
|
| `variant` | `solid \| outline \| soft \| ghost \| link` | `solid` | Visual style |
|
|
120
|
-
| `color` | `primary \| secondary \| success \| danger \| warning \| info` | `primary` | Semantic colour |
|
|
120
|
+
| `color` | `HubSemanticColor` — the nine built-ins (`primary \| secondary \| success \| danger \| warning \| info \| neutral \| light \| dark`) **or any custom accent** registered with `hub-btn-color-rules()` | `primary` | Semantic colour (open set) |
|
|
121
121
|
| `size` | `sm \| md \| lg \| xl` | `md` | Size scale |
|
|
122
|
-
| `
|
|
123
|
-
| `loading` | `boolean` | `false` | Shows spinner and blocks interaction |
|
|
122
|
+
| `loading` | `boolean` | `false` | Shows the spinner and marks the button **busy + disabled** — non-focusable, inert to pointer/keyboard, reflects `aria-busy="true"` and the `disabled` attribute |
|
|
124
123
|
| `disabled` | `boolean` | `false` | Disables the button and sets the `disabled` attribute |
|
|
125
124
|
|
|
126
125
|
```html
|
|
@@ -132,10 +131,27 @@ A single component with a dual selector — use it as an **element** or as an **
|
|
|
132
131
|
<a hubButton variant="link" color="primary" href="/docs">Read more</a>
|
|
133
132
|
```
|
|
134
133
|
|
|
135
|
-
> **Tip:** prefer the attribute form on a native `<button>` / `<a>` when you need real button semantics (focus, keyboard activation, form submission). `<hub-button>` is a styling host
|
|
134
|
+
> **Tip:** prefer the attribute form on a native `<button>` / `<a>` when you need real button semantics (focus, keyboard activation, form submission). The `<hub-button>` element form is a styling host, but it self-advertises `role="button"`, a focusable `tabindex` and Enter/Space activation so it stays keyboard-accessible; because it then reports as a button, don't nest it inside another interactive element.
|
|
136
135
|
>
|
|
137
136
|
> **Deprecated aliases:** `HubBtnComponent` and `HubBtnDirective` still export (pointing to `HubButtonComponent`) for backward compatibility — migrate to `HubButtonComponent`.
|
|
138
137
|
|
|
138
|
+
#### Loading / busy state
|
|
139
|
+
|
|
140
|
+
```html
|
|
141
|
+
<button hubButton color="primary" [loading]="saving()">Save</button>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
While `loading` is `true` the button shows an animated spinner and is fully inert: it reflects `aria-busy="true"` and the native `disabled` attribute, drops out of the tab order and ignores pointer and keyboard activation — so an in-flight submit can't fire twice.
|
|
145
|
+
|
|
146
|
+
The spinner glyph is the swappable `--hub-button-spinner` token (a `url("data:image/svg+xml,…")` painted through `mask`, so it inherits the button's text colour). Point it at any SVG to replace the loader, and tune `--hub-button-spinner-duration` / `--hub-button-spinner-size`:
|
|
147
|
+
|
|
148
|
+
```css
|
|
149
|
+
hub-button, [hubButton] {
|
|
150
|
+
--hub-button-spinner: url("data:image/svg+xml,%3Csvg …%3E"); /* your loader */
|
|
151
|
+
--hub-button-spinner-duration: 1s;
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
139
155
|
### `HubFabComponent` — `<hub-fab>`
|
|
140
156
|
|
|
141
157
|
| Input | Type | Default | Description |
|
|
@@ -235,8 +251,18 @@ All visual properties are CSS custom properties scoped with `:where()` (zero spe
|
|
|
235
251
|
--hub-button-gap: 0.375rem;
|
|
236
252
|
--hub-button-transition: all 0.15s ease;
|
|
237
253
|
--hub-button-spinner-size: 0.875em;
|
|
254
|
+
--hub-button-spinner-duration: 0.7s;
|
|
255
|
+
--hub-button-spinner: url("data:image/svg+xml,…"); /* the loading glyph — swap for any SVG */
|
|
238
256
|
--hub-button-disabled-opacity: 0.55;
|
|
239
257
|
|
|
258
|
+
/* Button interaction slots (overridable hover / pressed families) */
|
|
259
|
+
--hub-btn-hover-bg: var(--hub-btn-accent-subtle);
|
|
260
|
+
--hub-btn-hover-border: transparent;
|
|
261
|
+
--hub-btn-hover-color: var(--hub-btn-accent-emphasis);
|
|
262
|
+
--hub-btn-active-bg: color-mix(in oklch, var(--hub-btn-accent) 70%, var(--hub-sys-color-ink, #212529));
|
|
263
|
+
--hub-btn-active-border: transparent;
|
|
264
|
+
--hub-btn-active-color: var(--hub-btn-accent-on);
|
|
265
|
+
|
|
240
266
|
/* FAB */
|
|
241
267
|
--hub-fab-size-mini: 2.5rem;
|
|
242
268
|
--hub-fab-size-standard: 3.5rem;
|
|
@@ -256,17 +282,17 @@ All visual properties are CSS custom properties scoped with `:where()` (zero spe
|
|
|
256
282
|
/* Dropdown panel */
|
|
257
283
|
--hub-dropdown-panel-min-width: 11.25rem;
|
|
258
284
|
--hub-dropdown-panel-max-height: 20rem;
|
|
259
|
-
--hub-dropdown-panel-padding-y: 0.25rem;
|
|
260
|
-
--hub-dropdown-panel-bg: var(--hub-sys-color-surface-default, #
|
|
261
|
-
--hub-dropdown-panel-border-color: var(--hub-sys-color-border-subtle, #
|
|
262
|
-
--hub-dropdown-panel-border-radius: var(--hub-sys-radius-md, 0.
|
|
263
|
-
--hub-dropdown-panel-shadow: var(--hub-sys-shadow-lg);
|
|
264
|
-
--hub-dropdown-panel-zindex: 1000;
|
|
285
|
+
--hub-dropdown-panel-padding-y: var(--hub-ref-space-1, 0.25rem);
|
|
286
|
+
--hub-dropdown-panel-bg: var(--hub-sys-color-surface-default, #ffffff);
|
|
287
|
+
--hub-dropdown-panel-border-color: var(--hub-sys-color-border-subtle, #dee2e6);
|
|
288
|
+
--hub-dropdown-panel-border-radius: var(--hub-sys-radius-md, 0.375rem);
|
|
289
|
+
--hub-dropdown-panel-shadow: var(--hub-sys-shadow-lg, 0 1rem 3rem rgba(0, 0, 0, 0.175));
|
|
290
|
+
--hub-dropdown-panel-zindex: var(--hub-sys-zindex-dropdown, 1000);
|
|
265
291
|
|
|
266
292
|
/* Dropdown item */
|
|
267
|
-
--hub-dropdown-item-padding-x:
|
|
268
|
-
--hub-dropdown-item-padding-y: 0.
|
|
269
|
-
--hub-dropdown-item-hover-bg: var(--hub-sys-color-surface-subtle, #
|
|
293
|
+
--hub-dropdown-item-padding-x: var(--hub-ref-space-3, 1rem);
|
|
294
|
+
--hub-dropdown-item-padding-y: var(--hub-ref-space-2, 0.5rem);
|
|
295
|
+
--hub-dropdown-item-hover-bg: var(--hub-sys-color-surface-subtle, #f8f9fa);
|
|
270
296
|
--hub-dropdown-item-border-radius: var(--hub-sys-radius-sm, 0.25rem);
|
|
271
297
|
--hub-dropdown-item-disabled-opacity: 0.45;
|
|
272
298
|
```
|
|
@@ -285,12 +311,15 @@ Register custom semantic colors without modifying the library. Import the mixin
|
|
|
285
311
|
|
|
286
312
|
### Add a custom color to all five button variants
|
|
287
313
|
|
|
314
|
+
`hub-btn-color-rules('brand')` points the local `--hub-btn-accent` slot at
|
|
315
|
+
`--hub-sys-color-brand`. You only define that **one** value — the button derives
|
|
316
|
+
the whole role family (`-emphasis` / `-subtle` / `-on`) from it at runtime, so
|
|
317
|
+
every appearance (solid/outline/soft/ghost/link) works and `color="brand"`
|
|
318
|
+
type-checks (the `color` input is an open set):
|
|
319
|
+
|
|
288
320
|
```scss
|
|
289
321
|
:root {
|
|
290
|
-
--hub-sys-color-brand
|
|
291
|
-
--hub-sys-color-brand-emphasis: #cc5500;
|
|
292
|
-
--hub-sys-color-brand-subtle: #fff0e6;
|
|
293
|
-
--hub-sys-color-brand-on-default: #fff;
|
|
322
|
+
--hub-sys-color-brand: #ff6b00; // the single accent — that's all it needs
|
|
294
323
|
}
|
|
295
324
|
|
|
296
325
|
hub-button, [hubButton] {
|
|
@@ -305,17 +334,20 @@ hub-button, [hubButton] {
|
|
|
305
334
|
|
|
306
335
|
### Create a fully custom variant
|
|
307
336
|
|
|
308
|
-
`hub-btn-variant-rules` is the generic primitive
|
|
337
|
+
`hub-btn-variant-rules` is the generic primitive — **all parameters are named**
|
|
338
|
+
(there is no positional `$type`). Its defaults match the `ghost` variant, and
|
|
339
|
+
every colour reads the local `--hub-btn-accent*` slot family, so it stays
|
|
340
|
+
accent-agnostic. Override only the values that differ:
|
|
309
341
|
|
|
310
342
|
```scss
|
|
311
343
|
hub-button, [hubButton] {
|
|
312
344
|
&.hub-btn-inverted.hub-btn-brand {
|
|
313
|
-
@include hub.hub-btn-variant-rules(
|
|
314
|
-
$bg: var(--hub-
|
|
315
|
-
$color: var(--hub-
|
|
316
|
-
$border: var(--hub-
|
|
317
|
-
$hover-bg: var(--hub-
|
|
318
|
-
$hover-color: var(--hub-
|
|
345
|
+
@include hub.hub-btn-variant-rules(
|
|
346
|
+
$bg: var(--hub-btn-accent-on),
|
|
347
|
+
$color: var(--hub-btn-accent),
|
|
348
|
+
$border: var(--hub-btn-accent),
|
|
349
|
+
$hover-bg: var(--hub-btn-accent),
|
|
350
|
+
$hover-color: var(--hub-btn-accent-on)
|
|
319
351
|
);
|
|
320
352
|
}
|
|
321
353
|
}
|
|
@@ -341,8 +373,8 @@ hub-button, [hubButton] {
|
|
|
341
373
|
|
|
342
374
|
| Mixin | Context | Description |
|
|
343
375
|
|---|---|---|
|
|
344
|
-
| `hub-btn-variant-rules($
|
|
345
|
-
| `hub-btn-color-rules($type)` | global `hub-button, [hubButton]` block |
|
|
376
|
+
| `hub-btn-variant-rules($bg, $color, $border, $hover-*, $active-*, …)` | inside a `hub-button, [hubButton]` variant selector | Generic primitive — every appearance property as a **named** param (no positional `$type`) |
|
|
377
|
+
| `hub-btn-color-rules($type)` | global `hub-button, [hubButton]` block | Registers one custom accent (`--hub-btn-accent` → `--hub-sys-color-$type`); all five appearances derive from it |
|
|
346
378
|
| `hub-fab-color($type)` | root | Global `.hub-fab-{type}` color rule |
|
|
347
379
|
| `hub-dropdown-panel-color($type)` | root | Global color rule for `hub-dropdown-panel` |
|
|
348
380
|
| `hub-dropdown-panel-color-rules($type)` | inside `hub-dropdown-panel` selector | CSS properties only — bring your own selector |
|