@htmlbricks/hb-dashboard-indicator 0.71.35 → 0.71.37
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 +222 -26
- package/manifest.json +14 -6
- package/package.json +1 -1
- package/types/webcomponent.type.d.json +0 -4
- package/types/webcomponent.type.d.ts +2 -2
package/README.md
CHANGED
|
@@ -1,41 +1,185 @@
|
|
|
1
|
-
|
|
1
|
+
# `hb-dashboard-indicator` — Dashboard indicator
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Package folder:** `dashboard-indicator`
|
|
4
|
+
**Category:** data
|
|
5
|
+
**Tags:** data, dashboard
|
|
6
|
+
**NPM scope (distribution):** `@htmlbricks/hb-dashboard-indicator`
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
---
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
## Summary
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
`hb-dashboard-indicator` is a compact KPI tile for dashboards: a colored **header** shows a large **metric** (`number`), an optional **caption** (`text`), and a **Bootstrap Icon**; an optional **footer** appears when `link_label` is set and acts as a single **click target** that emits a **`dashboardIndicatorClick`** custom event carrying the element’s `id`.
|
|
10
13
|
|
|
11
|
-
`hb
|
|
14
|
+
Accent color (“karma”) is either a **Bulma semantic palette** on `:host` (`success`, `danger`, `warning`, `primary`, `secondary`, `info`) or **`none`** to drive header background and footer text color from **`--hb--dashboard-indicator-background`** on the host.
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
---
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
## Behavior
|
|
19
|
+
|
|
20
|
+
### Rendering
|
|
21
|
+
|
|
22
|
+
- **`number`:** Shown as the main value (Bulma `title is-3`, with tightened line-height for a compact header). In markup, pass it as a **string** (web component attributes are always strings); the component coerces to a number internally (default **`0`** when omitted).
|
|
23
|
+
- **`text`:** Optional subtitle under the number (Bulma `subtitle is-7`). Empty string hides the subtitle line container content but the layout still reserves flow; empty caption is visually minimal.
|
|
24
|
+
- **`icon`:** Bootstrap Icons **glyph name only** (no `bi-` prefix). Rendered as `<i class="bi bi-{icon}">`. Implementation default if unset is **`hypnotize`**; the authoring type marks `icon` as optional to mirror HTML usage.
|
|
25
|
+
- **`link_label`:** If **non-empty**, a **footer** strip is rendered with the label and a right-pointing circle arrow icon. If empty or unset, **no footer** and **no** `dashboardIndicatorClick` from this control (there is nothing to click).
|
|
26
|
+
- **`id`:** Optional string forwarded in **`dashboardIndicatorClick`** detail as `{ id: string }`. If unset, detail is `{ id: "" }`.
|
|
27
|
+
|
|
28
|
+
### `karma` (accent)
|
|
29
|
+
|
|
30
|
+
Allowed values: `success`, `danger`, `warning`, `primary`, `secondary`, `info`, `none`.
|
|
31
|
+
|
|
32
|
+
- **`secondary`:** Not a separate Bulma palette in this component; it is **mapped to Bulma `dark`** HSL tokens (`--bulma-dark-h` / `-s` / `-l` with defaults), same as the SCSS comment in the repo.
|
|
33
|
+
- **Semantic values (`success` … `info` except `none`):** Header **background** and footer **text color** use `hsl(var(--bulma-<token>-h), …)` resolved from `:host` (Bulma 1.x CSS variables). **`--hb--dashboard-indicator-background` is ignored** for these values.
|
|
34
|
+
- **`none`:** Header background and footer link/icon color use **`var(--hb--dashboard-indicator-background, <fallback>)`** where fallback is Bulma **success** semantic HSL. Set the variable on **`hb-dashboard-indicator`** (inline `style`, stylesheet, or design token layer).
|
|
35
|
+
|
|
36
|
+
If `karma` is **not** one of the allowed literals (e.g. typo), the component **normalizes to `success`** (`karmaResolved`).
|
|
37
|
+
|
|
38
|
+
### Interaction
|
|
39
|
+
|
|
40
|
+
- **Click:** Only the **footer** (`link_label` visible) calls `dispatch("dashboardIndicatorClick", { id })`. The header is **not** clickable for this event.
|
|
41
|
+
- **Implementation note:** The footer uses a click handler without an equivalent keyboard handler in source; for strict accessibility, integrators may wrap the tile or add host-level keyboard handling if needed.
|
|
42
|
+
|
|
43
|
+
### Assets and shadow DOM
|
|
44
|
+
|
|
45
|
+
- **Bootstrap Icons** are loaded for the shadow tree (stylesheet link in the component head **and** a font import in `styles/webcomponent.scss` in the build). Integrators should use **valid icon names** compatible with the Bootstrap Icons version pinned by the bundle.
|
|
46
|
+
- **Bulma** card, title, and helper utilities are included via `styles/bulma.scss` with `:host` variable forwarding so **`--bulma-*`** tokens on the custom element affect the tile.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Layout
|
|
51
|
+
|
|
52
|
+
- **Root:** Bulma **`card`** with class `hb-dashboard-indicator` and `data-karma={resolved}` for styling hooks.
|
|
53
|
+
- **Header (`card-header`):** Single **`card-header-title`** row (`hb-dashboard-indicator-header-inner`) as a flex row: **`nowrap`**, **space-between**, vertically centered.
|
|
54
|
+
- **Left:** Icon wrapper (`hb-dashboard-indicator-icon`) — large icon (~`4rem`), white glyph on semantic header background.
|
|
55
|
+
- **Right:** Flex column aligned **end** (`has-text-right`): **number** then **text**, white text, `min-width: 0` to avoid overflow blowout in tight grids.
|
|
56
|
+
- **Header padding:** Vertical `0.5rem`; horizontal **`var(--bulma-block-spacing, 1rem)`**. Inner title padding is reset to avoid double padding with Bulma’s defaults.
|
|
57
|
+
- **Footer (`card-footer`):** Only when `link_label` is set. Flex **space-between**, **clickable** (`is-clickable`), vertical padding `py-2`. Surface color from **`--bulma-background`** with scheme fallbacks; top border matches surface for a flush edge. First/last children get horizontal margins from **`--bulma-block-spacing`**.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Logic (implementation reference)
|
|
62
|
+
|
|
63
|
+
| Concern | Rule |
|
|
64
|
+
| --- | --- |
|
|
65
|
+
| Valid `karma` set | `success`, `danger`, `warning`, `primary`, `secondary`, `info`, `none` |
|
|
66
|
+
| Invalid `karma` | Treated as **`success`** |
|
|
67
|
+
| Event emission | `new CustomEvent("dashboardIndicatorClick", { detail: { id } })` on `$host()` |
|
|
68
|
+
| Footer visibility | `{#if link_label}` — truthy string required |
|
|
69
|
+
|
|
70
|
+
The `style` field exists on the **TypeScript `Component`** type for authoring, but the Svelte props block does **not** destructure `style`; host styling still works by setting the standard **`style`** attribute on `<hb-dashboard-indicator>` (especially for CSS variables).
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Custom element tag
|
|
75
|
+
|
|
76
|
+
```html
|
|
77
|
+
<hb-dashboard-indicator …></hb-dashboard-indicator>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Attributes / properties (snake_case, string values in HTML)
|
|
83
|
+
|
|
84
|
+
Web components reflect **string** attributes. Use JSON only where a future API requires it (not used here). Numbers and enums are plain strings.
|
|
85
|
+
|
|
86
|
+
| Attribute | Required | Default (behavior) | Description |
|
|
87
|
+
| --- | --- | --- | --- |
|
|
88
|
+
| `id` | No | `""` | Passed through in `dashboardIndicatorClick` detail. |
|
|
89
|
+
| `number` | No | `0` | Main KPI; pass as string, e.g. `"42"`. |
|
|
90
|
+
| `text` | No | `""` | Caption under the number. |
|
|
91
|
+
| `icon` | No | `"hypnotize"` in implementation | Bootstrap Icons name without `bi-` prefix. |
|
|
92
|
+
| `link_label` | No | `""` | If set, shows footer and enables click + event. |
|
|
93
|
+
| `karma` | No | `"success"` | Accent mode; see Behavior. |
|
|
94
|
+
| `style` | No | — | Standard HTML: useful to set `--hb--dashboard-indicator-background` and other variables on the host. |
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Events
|
|
99
|
+
|
|
100
|
+
Listen with `addEventListener` or framework equivalents.
|
|
101
|
+
|
|
102
|
+
| Event name | `event.detail` | When it fires |
|
|
16
103
|
| --- | --- | --- |
|
|
17
|
-
| `id` |
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
104
|
+
| **`dashboardIndicatorClick`** | `{ id: string }` | User **clicks** the **footer** while `link_label` is set. `id` matches the element’s `id` attribute / property (empty string if unset). |
|
|
105
|
+
|
|
106
|
+
TypeScript (consumer-side):
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
el.addEventListener("dashboardIndicatorClick", (e: CustomEvent<{ id: string }>) => {
|
|
110
|
+
console.log(e.detail.id);
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## CSS custom properties
|
|
117
|
+
|
|
118
|
+
Documented in `extra/docs.ts` / `styleSetup.vars`. Set on **`hb-dashboard-indicator`** (`:host`) unless your bundler wraps the element.
|
|
24
119
|
|
|
25
|
-
|
|
120
|
+
| Variable | Role |
|
|
121
|
+
| --- | --- |
|
|
122
|
+
| **`--hb--dashboard-indicator-background`** | When **`karma="none"`**: header **background** and footer **foreground** (label + arrow). If unset, falls back to Bulma **success** semantic color. **Ignored** when `karma` is any Bulma semantic value. |
|
|
123
|
+
| **`--bulma-block-spacing`** | Horizontal padding in header and footer row (default `1rem` in CSS). |
|
|
124
|
+
| **`--bulma-background`** | Footer strip **surface** color; when unset, SCSS uses scheme HSL fallbacks (`--bulma-scheme-h`, `--bulma-scheme-s`, `--bulma-background-l`, etc.). |
|
|
26
125
|
|
|
27
|
-
|
|
126
|
+
Additional **`--bulma-*-h` / `-s` / `-l`** (and defaults `--bulma-hb-def-*`) on `:host` control semantic karma colors per [Bulma CSS variables](https://bulma.io/documentation/features/css-variables/).
|
|
28
127
|
|
|
29
|
-
|
|
128
|
+
### `::part` names
|
|
30
129
|
|
|
31
|
-
|
|
130
|
+
**None** — `cssParts` is empty.
|
|
32
131
|
|
|
33
|
-
|
|
34
|
-
- Icon name must match bootstrap-icons.
|
|
35
|
-
- Shadow DOM wraps the tile; pass `id` when using click events.
|
|
36
|
-
- No i18n in `docs.ts`.
|
|
132
|
+
### Slots
|
|
37
133
|
|
|
38
|
-
|
|
134
|
+
**None** — `htmlSlots` is empty; all content is props-driven.
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## Typings (`types/webcomponent.type.d.ts`)
|
|
139
|
+
|
|
140
|
+
### `Karma`
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
export type Karma =
|
|
144
|
+
| "success"
|
|
145
|
+
| "danger"
|
|
146
|
+
| "warning"
|
|
147
|
+
| "primary"
|
|
148
|
+
| "secondary"
|
|
149
|
+
| "info"
|
|
150
|
+
/** Use `--hb--dashboard-indicator-background` on the host instead of Bulma `karma` tokens. */
|
|
151
|
+
| "none";
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### `Component`
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
export type Component = {
|
|
158
|
+
id?: string;
|
|
159
|
+
style?: string;
|
|
160
|
+
number?: number;
|
|
161
|
+
text?: string;
|
|
162
|
+
icon?: string;
|
|
163
|
+
link_label?: string;
|
|
164
|
+
karma?: Karma;
|
|
165
|
+
};
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### `Events`
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
export type Events = {
|
|
172
|
+
dashboardIndicatorClick: { id: string };
|
|
173
|
+
};
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Generated builds also emit **`types/html-elements.d.ts`** and **`types/svelte-elements.d.ts`** under the package output for DOM and Svelte typings.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Examples
|
|
181
|
+
|
|
182
|
+
### Minimal tile with footer and Bulma success accent
|
|
39
183
|
|
|
40
184
|
```html
|
|
41
185
|
<hb-dashboard-indicator
|
|
@@ -48,14 +192,66 @@ Compact KPI tile: large `number`, caption `text`, configurable Bootstrap Icon, a
|
|
|
48
192
|
></hb-dashboard-indicator>
|
|
49
193
|
```
|
|
50
194
|
|
|
51
|
-
###
|
|
195
|
+
### Danger accent (queue / errors)
|
|
196
|
+
|
|
197
|
+
```html
|
|
198
|
+
<hb-dashboard-indicator
|
|
199
|
+
id="kpi-failures"
|
|
200
|
+
number="3"
|
|
201
|
+
text="Failed jobs"
|
|
202
|
+
icon="exclamation-triangle"
|
|
203
|
+
link_label="Open queue"
|
|
204
|
+
karma="danger"
|
|
205
|
+
></hb-dashboard-indicator>
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Custom brand color (`karma="none"`)
|
|
52
209
|
|
|
53
210
|
```html
|
|
54
211
|
<hb-dashboard-indicator
|
|
212
|
+
id="kpi-custom"
|
|
55
213
|
karma="none"
|
|
56
214
|
style="--hb--dashboard-indicator-background: #6366f1"
|
|
57
215
|
number="12"
|
|
58
|
-
text="Custom"
|
|
216
|
+
text="Custom metric"
|
|
59
217
|
icon="stars"
|
|
218
|
+
link_label="Details"
|
|
219
|
+
></hb-dashboard-indicator>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### No footer (display-only KPI)
|
|
223
|
+
|
|
224
|
+
```html
|
|
225
|
+
<hb-dashboard-indicator
|
|
226
|
+
number="11"
|
|
227
|
+
text="Active sessions"
|
|
228
|
+
icon="window"
|
|
229
|
+
karma="primary"
|
|
60
230
|
></hb-dashboard-indicator>
|
|
61
231
|
```
|
|
232
|
+
|
|
233
|
+
### Vanilla JS: handle navigation by `id`
|
|
234
|
+
|
|
235
|
+
```html
|
|
236
|
+
<hb-dashboard-indicator
|
|
237
|
+
id="orders"
|
|
238
|
+
number="54"
|
|
239
|
+
text="Open orders"
|
|
240
|
+
icon="inbox"
|
|
241
|
+
link_label="Go to inbox"
|
|
242
|
+
karma="warning"
|
|
243
|
+
></hb-dashboard-indicator>
|
|
244
|
+
<script>
|
|
245
|
+
document.querySelector("hb-dashboard-indicator").addEventListener("dashboardIndicatorClick", (e) => {
|
|
246
|
+
if (e.detail.id === "orders") {
|
|
247
|
+
location.assign("/inbox");
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
</script>
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## i18n
|
|
256
|
+
|
|
257
|
+
None configured in `extra/docs.ts` (`i18nLanguages` is empty). All visible strings are supplied by the host via attributes.
|
package/manifest.json
CHANGED
|
@@ -57,10 +57,6 @@
|
|
|
57
57
|
"type": "string"
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
|
-
"required": [
|
|
61
|
-
"number",
|
|
62
|
-
"icon"
|
|
63
|
-
],
|
|
64
60
|
"type": "object"
|
|
65
61
|
},
|
|
66
62
|
"Karma": {
|
|
@@ -124,7 +120,19 @@
|
|
|
124
120
|
"name": "--hb--dashboard-indicator-background",
|
|
125
121
|
"valueType": "color",
|
|
126
122
|
"defaultValue": "",
|
|
127
|
-
"description": "Header background and footer
|
|
123
|
+
"description": "Header background and footer link color when `karma` is `none` (any valid CSS color). If unset, falls back to Bulma semantic `success`. Ignored for other `karma` values (those use Bulma `--bulma-*-h/s/l` palettes)."
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"name": "--bulma-block-spacing",
|
|
127
|
+
"valueType": "number",
|
|
128
|
+
"defaultValue": "1rem",
|
|
129
|
+
"description": "Horizontal padding in the card header and footer strip."
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"name": "--bulma-background",
|
|
133
|
+
"valueType": "color",
|
|
134
|
+
"defaultValue": "",
|
|
135
|
+
"description": "Footer strip surface color (with scheme fallbacks in CSS when unset)."
|
|
128
136
|
}
|
|
129
137
|
],
|
|
130
138
|
"parts": []
|
|
@@ -195,5 +203,5 @@
|
|
|
195
203
|
"size": {},
|
|
196
204
|
"iifePath": "main.iife.js",
|
|
197
205
|
"repoName": "@htmlbricks/hb-dashboard-indicator",
|
|
198
|
-
"version": "0.71.
|
|
206
|
+
"version": "0.71.37"
|
|
199
207
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htmlbricks/hb-dashboard-indicator",
|
|
3
|
-
"version": "0.71.
|
|
3
|
+
"version": "0.71.37",
|
|
4
4
|
"contributors": [],
|
|
5
5
|
"description": "Compact KPI tile: large `number`, caption `text`, configurable Bootstrap Icon, and `karma` accent (`success` | `danger` | `warning` | `primary` | `secondary` | `info`) using Bulma theme tokens (`secondary` maps to Bulma `dark`), or `karma=\"none\"` with host CSS variable `--hb--dashboard-indicator-background` for a custom color. When `link_label` is set, a footer strip is shown and clicks dispatch `dashboardIndicatorClick` with the component `id`.",
|
|
6
6
|
"licenses": [
|
|
@@ -11,9 +11,9 @@ export type Karma =
|
|
|
11
11
|
export type Component = {
|
|
12
12
|
id?: string;
|
|
13
13
|
style?: string;
|
|
14
|
-
number
|
|
14
|
+
number?: number;
|
|
15
15
|
text?: string;
|
|
16
|
-
icon
|
|
16
|
+
icon?: string;
|
|
17
17
|
link_label?: string;
|
|
18
18
|
/**
|
|
19
19
|
* Semantic accent from Bulma (`secondary` → `dark` tokens), or `none` for a custom host color via
|