@htmlbricks/hb-messages-topics-card 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.
- package/README.md +114 -24
- package/manifest.json +24 -48
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,49 +1,139 @@
|
|
|
1
1
|
# hb-messages-topics-card
|
|
2
2
|
|
|
3
|
+
**Category:** messaging · **Tags:** messaging, chat
|
|
4
|
+
**Package:** `@htmlbricks/hb-messages-topics-card`
|
|
5
|
+
|
|
3
6
|
## Description
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
Renders a vertical list of chat or channel previews from a **`chats`** collection. Each row shows a rounded avatar, a title, a short message preview, a time label, and an unread counter rendered as a Bulma tag. Clicking a row updates internal selection state (`_selected`), highlights the row, and dispatches a **`select`** custom event with the clicked chat object so the host can open a thread or switch context.
|
|
6
9
|
|
|
7
10
|
## Styling (Bulma)
|
|
8
11
|
|
|
9
|
-
The component bundles **Bulma 1.x**
|
|
12
|
+
The component bundles **Bulma 1.x** inside the shadow root: **`layout/media`**, **`layout/level`**, **`elements/image`**, **`elements/tag`**, and typography / spacing helpers, with the light theme applied on `:host`. Public **`--bulma-*`** variables can be set on `body`, `:root`, or the host so they cascade consistently with the rest of the app — see [Bulma CSS variables](https://bulma.io/documentation/features/css-variables/) and the `styleSetup.vars` entries in `extra/docs.ts`.
|
|
13
|
+
|
|
14
|
+
| Variable | Purpose |
|
|
15
|
+
|----------|---------|
|
|
16
|
+
| `--bulma-text` | Title and preview snippet text. |
|
|
17
|
+
| `--bulma-text-strong` | Strong title weight color (falls back to `--bulma-text`). |
|
|
18
|
+
| `--bulma-text-weak` | Muted time label beside each preview. |
|
|
19
|
+
| `--bulma-border` | Divider between rows. |
|
|
20
|
+
| `--bulma-scheme-main-bis` | Hover background for rows that are not selected. |
|
|
21
|
+
| `--bulma-scheme-main-ter` | Selected row background. |
|
|
22
|
+
| `--bulma-radius-rounded` | Pill shape for the unread counter tag. |
|
|
10
23
|
|
|
11
24
|
**Shadow markup (simplified):**
|
|
12
25
|
|
|
13
|
-
- **`
|
|
14
|
-
- **`
|
|
26
|
+
- **`article.media.hb-topics-item`** — clickable row; **`hb-topics-item--selected`** when that chat is selected.
|
|
27
|
+
- **`figure.media-left`** + **`p.image.is-64x64`** + **`img.is-rounded`** — avatar from `img_uri`.
|
|
28
|
+
- **`div.media-content`** — Bulma **`level`** rows for title + time, then preview + counter tag.
|
|
29
|
+
|
|
30
|
+
## CSS parts
|
|
31
|
+
|
|
32
|
+
None.
|
|
33
|
+
|
|
34
|
+
## HTML slots
|
|
35
|
+
|
|
36
|
+
None.
|
|
37
|
+
|
|
38
|
+
## Custom element
|
|
39
|
+
|
|
40
|
+
`hb-messages-topics-card`
|
|
41
|
+
|
|
42
|
+
## Attributes (snake_case; string values in HTML)
|
|
43
|
+
|
|
44
|
+
Per the web component contract, attributes are strings. The primary payload is JSON on **`chats`**.
|
|
45
|
+
|
|
46
|
+
| Attribute | Required | Description |
|
|
47
|
+
|-----------|----------|-------------|
|
|
48
|
+
| `id` | No | Optional host identifier. |
|
|
49
|
+
| `style` | No | Optional inline host styles (typed on the component surface). |
|
|
50
|
+
| `chats` | No* | JSON string: array of chat objects (`IChat[]`). Defaults to an empty list if omitted. |
|
|
51
|
+
|
|
52
|
+
\* **`chats`** is required in the TypeScript **`Component`** type for a fully configured instance; in markup you may omit it and get no rows until you set or update the attribute / property.
|
|
53
|
+
|
|
54
|
+
### `chats` JSON shape (`IChat`)
|
|
55
|
+
|
|
56
|
+
Fields used for layout and labels in the current implementation:
|
|
15
57
|
|
|
16
|
-
|
|
58
|
+
| Field | Role |
|
|
59
|
+
|-------|------|
|
|
60
|
+
| `chat_id` | Stable key for each row (also used in `{#each}` keyed updates). |
|
|
61
|
+
| `title` | Primary line (semibold). |
|
|
62
|
+
| `text` | Preview line under the title. |
|
|
63
|
+
| `img_uri` | Avatar URL (`img` `src`). |
|
|
64
|
+
| `time` | Source for the time label when `localeTimeString` is not set; use an **ISO 8601** string in JSON so it parses as a date. |
|
|
65
|
+
| `localeTimeString` | If set, shown as-is instead of deriving `HH:MM` from `time`. |
|
|
66
|
+
| `counter` | Unread count; rendered in the tag (missing or falsy shows **`0`**). |
|
|
67
|
+
| `_selected` | When `true`, that row starts selected and receives the selected background. |
|
|
68
|
+
|
|
69
|
+
Additional optional fields (`is_group`, `chat_name`, `chat_img`, `last_message_*`, and so on) are part of the **`IChat`** type so you can carry richer metadata; they are not read by the template today but are still present on objects emitted by **`select`**.
|
|
70
|
+
|
|
71
|
+
If the **`chats`** prop arrives as a string (for example from an HTML attribute), the component parses it with **`JSON.parse`**; invalid JSON is logged to the console and parsing is skipped.
|
|
72
|
+
|
|
73
|
+
## Events
|
|
74
|
+
|
|
75
|
+
| Event | `detail` |
|
|
76
|
+
|-------|----------|
|
|
77
|
+
| `select` | The clicked **`IChat`** object (same reference the list uses after selection is updated). |
|
|
78
|
+
|
|
79
|
+
Listen in plain JavaScript:
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
const el = document.querySelector("hb-messages-topics-card");
|
|
83
|
+
el.addEventListener("select", (e) => {
|
|
84
|
+
const chat = e.detail;
|
|
85
|
+
console.log(chat.chat_id, chat.title);
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Usage notes
|
|
90
|
+
|
|
91
|
+
- **Initial selection:** set **`_selected`** on at most one item in the JSON if you want a default active row.
|
|
92
|
+
- **Time display:** without **`localeTimeString`**, the component fills it from **`time`** using the **local** hours and minutes (`HH:MM`). Provide **`localeTimeString`** yourself for relative times or locale-specific formatting.
|
|
93
|
+
- **Unread badge:** the tag always shows a value; **`0`** is shown when there is no positive counter.
|
|
94
|
+
- **Avatars:** the template sets **`alt=""`** on images; if you need accessible names, extend your integration (for example wrapping context or contributing upstream) because the component does not derive labels from `title` today.
|
|
17
95
|
|
|
18
96
|
## Types
|
|
19
97
|
|
|
20
98
|
```typescript
|
|
21
99
|
export type IChat = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
100
|
+
time: Date;
|
|
101
|
+
title: string;
|
|
102
|
+
text: string;
|
|
103
|
+
img_uri: string;
|
|
104
|
+
is_group?: boolean;
|
|
105
|
+
chat_name?: string;
|
|
106
|
+
chat_img?: string;
|
|
107
|
+
chat_id: string;
|
|
108
|
+
last_message_author?: string;
|
|
109
|
+
last_message_author_img?: string;
|
|
110
|
+
last_message_time?: Date;
|
|
111
|
+
last_message_text?: string;
|
|
112
|
+
counter?: number;
|
|
113
|
+
localeTimeString?: string;
|
|
114
|
+
_selected?: boolean;
|
|
37
115
|
};
|
|
38
116
|
|
|
39
117
|
export type Component = {
|
|
40
|
-
|
|
41
|
-
|
|
118
|
+
id?: string;
|
|
119
|
+
style?: string;
|
|
42
120
|
|
|
43
|
-
|
|
121
|
+
chats: IChat[];
|
|
44
122
|
};
|
|
45
123
|
|
|
46
124
|
export type Events = {
|
|
47
|
-
|
|
125
|
+
select: IChat;
|
|
48
126
|
};
|
|
49
127
|
```
|
|
128
|
+
|
|
129
|
+
## Minimal HTML example
|
|
130
|
+
|
|
131
|
+
```html
|
|
132
|
+
<hb-messages-topics-card
|
|
133
|
+
chats='[{"chat_id":"1","title":"Team","text":"Hello","time":"2026-01-01T12:00:00.000Z","img_uri":"https://example.com/a.png","counter":2}]'
|
|
134
|
+
></hb-messages-topics-card>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Storybook / metadata
|
|
138
|
+
|
|
139
|
+
Argument controls and additional named examples (selected row, unread badges, single chat) live in `extra/docs.ts`.
|
package/manifest.json
CHANGED
|
@@ -183,67 +183,43 @@
|
|
|
183
183
|
"name": "--bulma-text",
|
|
184
184
|
"valueType": "color",
|
|
185
185
|
"defaultValue": "#363636",
|
|
186
|
-
"description": "
|
|
186
|
+
"description": "Title and preview snippet text."
|
|
187
187
|
},
|
|
188
188
|
{
|
|
189
189
|
"name": "--bulma-text-strong",
|
|
190
190
|
"valueType": "color",
|
|
191
191
|
"defaultValue": "#363636",
|
|
192
|
-
"description": "
|
|
192
|
+
"description": "Strong title weight color (falls back to `--bulma-text`)."
|
|
193
193
|
},
|
|
194
194
|
{
|
|
195
195
|
"name": "--bulma-text-weak",
|
|
196
196
|
"valueType": "color",
|
|
197
197
|
"defaultValue": "#7a7a7a",
|
|
198
|
-
"description": "Muted time
|
|
198
|
+
"description": "Muted foreground for the timestamp or relative time shown beside each chat preview."
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"name": "--bulma-border",
|
|
202
|
+
"valueType": "color",
|
|
203
|
+
"defaultValue": "#dbdbdb",
|
|
204
|
+
"description": "Row divider between chat previews."
|
|
199
205
|
},
|
|
200
206
|
{
|
|
201
207
|
"name": "--bulma-scheme-main-bis",
|
|
202
208
|
"valueType": "color",
|
|
203
|
-
"defaultValue": "
|
|
204
|
-
"description": "Hover
|
|
209
|
+
"defaultValue": "#fafafa",
|
|
210
|
+
"description": "Hover background for non-selected rows."
|
|
205
211
|
},
|
|
206
212
|
{
|
|
207
213
|
"name": "--bulma-scheme-main-ter",
|
|
208
214
|
"valueType": "color",
|
|
209
|
-
"defaultValue": "
|
|
210
|
-
"description": "Selected row background
|
|
215
|
+
"defaultValue": "#f5f5f5",
|
|
216
|
+
"description": "Selected row background."
|
|
211
217
|
},
|
|
212
218
|
{
|
|
213
219
|
"name": "--bulma-radius-rounded",
|
|
214
220
|
"valueType": "number",
|
|
215
221
|
"defaultValue": "9999px",
|
|
216
222
|
"description": "Pill shape for the unread counter tag."
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
"name": "--hb-topics-card-double-padding",
|
|
220
|
-
"valueType": "string",
|
|
221
|
-
"defaultValue": ""
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
"name": "--hb-topics-card-double-size",
|
|
225
|
-
"valueType": "number",
|
|
226
|
-
"defaultValue": ""
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
"name": "--hb-topics-card-hover-background-color",
|
|
230
|
-
"valueType": "color",
|
|
231
|
-
"defaultValue": ""
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
"name": "--hb-topics-card-padding",
|
|
235
|
-
"valueType": "string",
|
|
236
|
-
"defaultValue": ""
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
"name": "--hb-topics-card-selected-background-color",
|
|
240
|
-
"valueType": "color",
|
|
241
|
-
"defaultValue": ""
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
"name": "--hb-topics-card-size",
|
|
245
|
-
"valueType": "number",
|
|
246
|
-
"defaultValue": ""
|
|
247
223
|
}
|
|
248
224
|
],
|
|
249
225
|
"parts": []
|
|
@@ -261,7 +237,7 @@
|
|
|
261
237
|
"counter": 0,
|
|
262
238
|
"text": "Hello 0",
|
|
263
239
|
"title": "Hello0",
|
|
264
|
-
"time": "2026-04-
|
|
240
|
+
"time": "2026-04-17T00:14:14.046Z",
|
|
265
241
|
"img_uri": "https://www.w3schools.com/howto/img_avatar.png"
|
|
266
242
|
},
|
|
267
243
|
{
|
|
@@ -269,7 +245,7 @@
|
|
|
269
245
|
"counter": 0,
|
|
270
246
|
"text": "Hello 1",
|
|
271
247
|
"title": "Hello1",
|
|
272
|
-
"time": "2026-04-
|
|
248
|
+
"time": "2026-04-17T00:14:14.046Z",
|
|
273
249
|
"img_uri": "https://www.w3schools.com/howto/img_avatar.png"
|
|
274
250
|
},
|
|
275
251
|
{
|
|
@@ -277,7 +253,7 @@
|
|
|
277
253
|
"counter": 0,
|
|
278
254
|
"text": "Hello 2",
|
|
279
255
|
"title": "Hello2",
|
|
280
|
-
"time": "2026-04-
|
|
256
|
+
"time": "2026-04-17T00:14:14.046Z",
|
|
281
257
|
"img_uri": "https://www.w3schools.com/howto/img_avatar.png"
|
|
282
258
|
}
|
|
283
259
|
]
|
|
@@ -292,7 +268,7 @@
|
|
|
292
268
|
"counter": 0,
|
|
293
269
|
"text": "Hello 0",
|
|
294
270
|
"title": "Hello0",
|
|
295
|
-
"time": "2026-04-
|
|
271
|
+
"time": "2026-04-17T00:14:14.046Z",
|
|
296
272
|
"img_uri": "https://www.w3schools.com/howto/img_avatar.png"
|
|
297
273
|
},
|
|
298
274
|
{
|
|
@@ -300,7 +276,7 @@
|
|
|
300
276
|
"counter": 0,
|
|
301
277
|
"text": "Hello 1",
|
|
302
278
|
"title": "Hello1",
|
|
303
|
-
"time": "2026-04-
|
|
279
|
+
"time": "2026-04-17T00:14:14.046Z",
|
|
304
280
|
"img_uri": "https://www.w3schools.com/howto/img_avatar.png",
|
|
305
281
|
"_selected": true
|
|
306
282
|
},
|
|
@@ -309,7 +285,7 @@
|
|
|
309
285
|
"counter": 0,
|
|
310
286
|
"text": "Hello 2",
|
|
311
287
|
"title": "Hello2",
|
|
312
|
-
"time": "2026-04-
|
|
288
|
+
"time": "2026-04-17T00:14:14.046Z",
|
|
313
289
|
"img_uri": "https://www.w3schools.com/howto/img_avatar.png"
|
|
314
290
|
}
|
|
315
291
|
]
|
|
@@ -325,7 +301,7 @@
|
|
|
325
301
|
"counter": 3,
|
|
326
302
|
"text": "Can you review the PR?",
|
|
327
303
|
"title": "Engineering",
|
|
328
|
-
"time": "2026-04-
|
|
304
|
+
"time": "2026-04-17T00:14:14.046Z",
|
|
329
305
|
"img_uri": "https://www.w3schools.com/howto/img_avatar.png"
|
|
330
306
|
},
|
|
331
307
|
{
|
|
@@ -333,7 +309,7 @@
|
|
|
333
309
|
"counter": 12,
|
|
334
310
|
"text": "Contract signed",
|
|
335
311
|
"title": "Sales",
|
|
336
|
-
"time": "2026-04-
|
|
312
|
+
"time": "2026-04-17T00:14:14.046Z",
|
|
337
313
|
"img_uri": "https://www.w3schools.com/howto/img_avatar.png"
|
|
338
314
|
},
|
|
339
315
|
{
|
|
@@ -341,7 +317,7 @@
|
|
|
341
317
|
"counter": 1,
|
|
342
318
|
"text": "Ticket #4421 updated",
|
|
343
319
|
"title": "Support",
|
|
344
|
-
"time": "2026-04-
|
|
320
|
+
"time": "2026-04-17T00:14:14.046Z",
|
|
345
321
|
"img_uri": "https://www.w3schools.com/howto/img_avatar.png"
|
|
346
322
|
}
|
|
347
323
|
]
|
|
@@ -357,7 +333,7 @@
|
|
|
357
333
|
"counter": 0,
|
|
358
334
|
"text": "Only conversation in the list",
|
|
359
335
|
"title": "Direct message",
|
|
360
|
-
"time": "2026-04-
|
|
336
|
+
"time": "2026-04-17T00:14:14.046Z",
|
|
361
337
|
"img_uri": "https://www.w3schools.com/howto/img_avatar.png",
|
|
362
338
|
"_selected": true
|
|
363
339
|
}
|
|
@@ -386,5 +362,5 @@
|
|
|
386
362
|
"size": {},
|
|
387
363
|
"iifePath": "main.iife.js",
|
|
388
364
|
"repoName": "@htmlbricks/hb-messages-topics-card",
|
|
389
|
-
"version": "0.71.
|
|
365
|
+
"version": "0.71.36"
|
|
390
366
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htmlbricks/hb-messages-topics-card",
|
|
3
|
-
"version": "0.71.
|
|
3
|
+
"version": "0.71.36",
|
|
4
4
|
"contributors": [],
|
|
5
5
|
"description": "Lists chat or channel previews from `chats`: avatar, title, last message snippet, derived time label, and unread `counter` badge. Clicking a row marks it selected (`_selected`) and dispatches `select` with that chat payload for opening a thread or switching context.",
|
|
6
6
|
"licenses": [
|