@htmlbricks/hb-dashboard-counter-lines 0.71.34 → 0.71.36

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.
Files changed (3) hide show
  1. package/README.md +115 -27
  2. package/manifest.json +10 -6
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,50 +1,138 @@
1
- ## `hb-dashboard-counter-lines` — dashboard-counter-lines
1
+ # `hb-dashboard-counter-lines`
2
2
 
3
- **Category:** data | **Tags:** data, dashboard
3
+ **Category:** data · **Tags:** data, dashboard
4
4
 
5
- ### What it does
5
+ ## Overview
6
6
 
7
- Vertical list of metric rows from JSON `lines`: each row shows optional Bootstrap Icon, label text, and a Bulma light rounded tag for the counter value. `link.type` chooses behavior—open URI in a new tab, same-window navigation, custom `counterClick` event with a key, or a static row with no click handler.
7
+ `hb-dashboard-counter-lines` renders a vertical list of dashboard-style metrics. Each row can show an optional Bootstrap Icon, a primary label, and a compact counter value in a Bulma light, rounded tag. Rows may be static or clickable depending on an optional `link` object.
8
8
 
9
- ### Styling (Bulma)
9
+ The custom element is registered as **`hb-dashboard-counter-lines`**.
10
10
 
11
- The component bundles **Bulma 1.x** in the shadow root: **`elements/tag`** only, with theme defaults on `:host` (`--bulma-hb-def-*`). Set public **`--bulma-*`** on `body` or `:root` so they inherit onto the host. Icons remain **Bootstrap Icons** (loaded via `<svelte:head>`); use icon names in the `icon` field. See [Bulma CSS variables](https://bulma.io/documentation/features/css-variables/).
11
+ ## When to use it
12
12
 
13
- **Shadow markup (simplified):**
13
+ Use this component when you need a simple, scannable summary of several numeric or textual KPIs (counts, rates, totals) with optional navigation or a custom click action per row.
14
14
 
15
- - **`div.item`** row; optional click for `tab` / `page` / `event` links.
16
- - **`div.item_content`** / **`div.text`** — label + optional **`i.bi`**.
17
- - **`div.value.tag.is-light.is-rounded`** — counter (exposed as part **`value`**).
15
+ ## Data model (`lines`)
18
16
 
19
- ### Custom element
17
+ The `lines` prop is a **`Line[]`** array. From HTML, pass it as a **JSON string** (serialized array).
20
18
 
21
- `hb-dashboard-counter-lines`
19
+ Each line object supports:
22
20
 
23
- ### Attributes / props (snake_case)
21
+ | Field | Type | Description |
22
+ | --- | --- | --- |
23
+ | `text` | string | Primary label shown on the row (truncated with an ellipsis when space is tight). |
24
+ | `value` | string | Counter text rendered inside the Bulma `tag is-light is-rounded` pill. |
25
+ | `icon` | string (optional) | Bootstrap Icons **glyph name only** (without the `bi-` prefix), e.g. `"people"`, `"clock"`. Renders as `class="bi bi-{icon}"`. |
26
+ | `link` | object (optional) | When present and valid, the whole row becomes clickable. See [Link behavior](#link-behavior) below. |
27
+ | `index` | number (optional) | Reserved in the type for ordering or metadata; the current markup does not display it. |
28
+
29
+ ### Parsing rules
30
+
31
+ - If `lines` is omitted, `null`, or an empty string after trim, nothing is rendered.
32
+ - If `lines` is a string, the component **`JSON.parse`s** it once (synchronously) before paint. Invalid JSON logs an error to the console and results in an empty list.
33
+ - Non-array JSON or an empty array also yields no visible content.
34
+
35
+ ## Attributes and properties (snake_case)
36
+
37
+ Web component attributes are strings. Complex values must be JSON strings.
38
+
39
+ | Name | Required | Description |
40
+ | --- | --- | --- |
41
+ | `id` | No | Optional; present on the authoring `Component` type for integrations that set it from JavaScript. |
42
+ | `style` | No | Optional on the authoring `Component` type; the implementation does not forward a `style` prop into the shadow tree—use Bulma variables, `::part`, or the native HTML `style` attribute on the host element if you need one-off host styling. |
43
+ | `lines` | No | JSON string representing `Line[]`, e.g. `[{"text":"Users","value":"42","icon":"people"}]`. |
44
+
45
+ ## Link behavior
46
+
47
+ When `link` is set and includes both `type` and `uri`, the row is interactive (`cursor`/click styling from your theme and `::part(item)`).
48
+
49
+ | `link.type` | Effect |
50
+ | --- | --- |
51
+ | `"tab"` | Opens `link.uri` in a new browser tab (`window.open(..., "_blank")`). |
52
+ | `"page"` | Navigates the current window to `link.uri` (`window.location.href`). |
53
+ | `"event"` | Dispatches a **`counterClick`** custom event with **`detail.key`** equal to `link.uri` (use `uri` as your logical event key). |
54
+
55
+ If `link` is missing, incomplete, or `uri` is empty, the row is **not** clickable.
56
+
57
+ ## Events
58
+
59
+ | Event name | `detail` shape | When it fires |
60
+ | --- | --- | --- |
61
+ | `counterClick` | `{ key: string }` | When the user activates a row whose `link.type` is `"event"`. `key` is the line’s `link.uri`. |
62
+
63
+ Listen with `addEventListener("counterClick", ...)` or the equivalent in your framework.
64
+
65
+ ## Layout and styling
66
+
67
+ - **Host:** `:host` is a column flex container with spacing between rows, full width, `min-width: 0` so flex children can shrink inside tight layouts.
68
+ - **Row:** Label cluster (icon + text) grows/shrinks; the value tag stays on the right and does not shrink.
69
+ - **Typography:** Long labels use a single line with ellipsis overflow.
70
+
71
+ Theming uses **Bulma CSS variables** inside the shadow root. You can also target exposed **CSS parts** from the light DOM.
72
+
73
+ ### CSS custom properties (`--bulma-*`)
24
74
 
25
- | Property | Type | Notes |
75
+ | Variable | Default | Role |
26
76
  | --- | --- | --- |
27
- | `id` | string (optional) | Element identifier. |
28
- | `style` | string (optional) | Inline style string. |
29
- | `lines` | array (optional) | JSON `Line[]`: text, value, link?: `{ type: "tab" \| "page" \| "event"; uri: string }`, index?, icon?. |
77
+ | `--bulma-primary` | `#00d1b2` | Primary brand color (e.g. tag accents when using Bulma color modifiers). |
78
+ | `--bulma-text` | `#363636` | Main label text color. |
79
+ | `--bulma-text-weak` | `#7a7a7a` | Muted supporting text where applicable. |
80
+ | `--bulma-radius` | `0.375rem` | Base radius for components that depend on Bulma radius tokens. |
81
+ | `--bulma-radius-rounded` | `9999px` | Pill radius for `.tag.is-rounded`. |
30
82
 
31
- **Parts:** `item`, `icon`, `text`, `value`. No slots.
83
+ Set `--bulma-*` on `html`, `body`, or on the element / its ancestors so values inherit into the shadow tree. See the [Bulma CSS variables documentation](https://bulma.io/documentation/features/css-variables/).
32
84
 
33
- ### Events (`CustomEvent` names)
85
+ ### CSS parts (`::part(...)`)
34
86
 
35
- - **`counterClick`** `{ key: string }` — Used when a line’s `link.type` is `"event"` (per docs behavior).
87
+ | Part | Description |
88
+ | --- | --- |
89
+ | `item` | Outer row container; meaningful for hover, cursor, padding, or background when the row has a `link`. |
90
+ | `icon` | Bootstrap Icon `<i>` element for that row. |
91
+ | `text` | Primary label `<span>`. |
92
+ | `value` | Bulma tag showing the counter value (`tag is-light is-rounded`). |
36
93
 
37
- ### Usage notes
94
+ ### Slots
38
95
 
39
- - Icons use bootstrap-icons names in the `icon` field.
40
- - Rows are dashboard-style metrics, not a navigation menu.
41
- - Shadow DOM exposes granular parts per row segment.
42
- - No i18n in `docs.ts`.
96
+ None.
43
97
 
44
- ### Minimal HTML example
98
+ ## Dependencies (runtime)
99
+
100
+ - **Bootstrap Icons** font (loaded for icon classes used in the shadow tree).
101
+ - **Bulma** (Sass modules forwarded in the component styles).
102
+
103
+ ## Examples
104
+
105
+ ### Several static metrics
106
+
107
+ ```html
108
+ <hb-dashboard-counter-lines
109
+ lines='[{"text":"Active users","value":"1.2k","icon":"people"},{"text":"Errors","value":"3","icon":"exclamation-triangle"},{"text":"Latency p95","value":"120ms","icon":"speedometer2"}]'
110
+ ></hb-dashboard-counter-lines>
111
+ ```
112
+
113
+ ### Row that opens a URL in a new tab
45
114
 
46
115
  ```html
47
116
  <hb-dashboard-counter-lines
48
- lines='[{"text":"Active users","value":"1.2k","icon":"people"},{"text":"Errors","value":"3","icon":"exclamation-triangle"}]'
117
+ lines='[{"text":"Open reports","value":"12","icon":"graph-up-arrow","link":{"type":"tab","uri":"https://example.com/reports"}}]'
49
118
  ></hb-dashboard-counter-lines>
50
119
  ```
120
+
121
+ ### Row that emits `counterClick`
122
+
123
+ ```html
124
+ <hb-dashboard-counter-lines
125
+ id="kpi-block"
126
+ lines='[{"text":"Drill down","value":"99+","link":{"type":"event","uri":"open-details"}}]'
127
+ ></hb-dashboard-counter-lines>
128
+
129
+ <script>
130
+ document.getElementById("kpi-block").addEventListener("counterClick", (e) => {
131
+ console.log("key:", e.detail.key); // "open-details"
132
+ });
133
+ </script>
134
+ ```
135
+
136
+ ## Internationalization
137
+
138
+ No built-in i18n strings; pass already-translated `text` and `value` values in `lines`.
package/manifest.json CHANGED
@@ -124,7 +124,7 @@
124
124
  "name": "--bulma-text-weak",
125
125
  "valueType": "color",
126
126
  "defaultValue": "#7a7a7a",
127
- "description": "Muted text."
127
+ "description": "Tints supplementary or secondary copy on each metric row so supporting labels and hints recede visually behind the primary label column."
128
128
  },
129
129
  {
130
130
  "name": "--bulma-radius",
@@ -141,16 +141,20 @@
141
141
  ],
142
142
  "parts": [
143
143
  {
144
- "name": "item"
144
+ "name": "item",
145
+ "description": "Clickable row container when a `link` is present; use for spacing, cursor, or hover background from the host."
145
146
  },
146
147
  {
147
- "name": "icon"
148
+ "name": "icon",
149
+ "description": "Bootstrap Icon element for the row; adjust size or color without touching inner markup."
148
150
  },
149
151
  {
150
- "name": "text"
152
+ "name": "text",
153
+ "description": "Primary label column for the metric line."
151
154
  },
152
155
  {
153
- "name": "value"
156
+ "name": "value",
157
+ "description": "Bulma `tag is-light is-rounded` showing the counter value; style pill colors and weight here."
154
158
  }
155
159
  ]
156
160
  },
@@ -249,5 +253,5 @@
249
253
  "size": {},
250
254
  "iifePath": "main.iife.js",
251
255
  "repoName": "@htmlbricks/hb-dashboard-counter-lines",
252
- "version": "0.71.34"
256
+ "version": "0.71.36"
253
257
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htmlbricks/hb-dashboard-counter-lines",
3
- "version": "0.71.34",
3
+ "version": "0.71.36",
4
4
  "contributors": [],
5
5
  "description": "Vertical list of metric rows from JSON `lines`: each row shows optional Bootstrap Icon, label text, and a Bulma `tag is-light is-rounded` counter. `link.type` chooses behavior—open URI in a new tab, same-window navigation, custom `counterClick` event with a key, or a static row with no click handler.",
6
6
  "licenses": [