@htmlbricks/hb-vertical-img-txt-archive 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 +111 -17
- package/manifest.json +50 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,36 +1,130 @@
|
|
|
1
|
-
|
|
1
|
+
# `hb-vertical-img-txt-archive`
|
|
2
2
|
|
|
3
|
+
**Package folder:** `vertical-img-txt-archive`
|
|
3
4
|
**Category:** content
|
|
4
5
|
**Tags:** content, archive
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
## Overview
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
`hb-vertical-img-txt-archive` renders a **responsive CSS grid** of archive cards. Each card stacks an **image** above a **title** (`h3`) and **body text** (`p`). Data comes from a single **`collection`** value: either an array (when using the element from JavaScript) or a **JSON string** (typical in HTML).
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
If `collection` is missing, empty, not an array, or invalid JSON, the component renders **nothing** (no placeholder).
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
## Custom element
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
```text
|
|
16
|
+
hb-vertical-img-txt-archive
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Data model (`collection` items)
|
|
20
|
+
|
|
21
|
+
Each entry in `collection` matches the `Item` shape in `types/webcomponent.type.d.ts`:
|
|
22
|
+
|
|
23
|
+
| Field | Required | Description |
|
|
24
|
+
| --- | --- | --- |
|
|
25
|
+
| `title` | Yes | Card heading; also used as the image `alt` text. |
|
|
26
|
+
| `text` | Yes | Supporting paragraph under the title. |
|
|
27
|
+
| `image` | Yes | Image URL for the card media. |
|
|
28
|
+
| `link` | Yes (in typings) | Object `{ type: "tab" \| "page" \| "event"; uri: string }`. Reserved for navigation or host-side handling; the current template does not render links or buttons from this field. |
|
|
29
|
+
| `subtitle` | No | Optional metadata (e.g. date or version); not shown in the current markup. |
|
|
30
|
+
| `index` | No | Optional ordering hint for consumers; not used for rendering. |
|
|
31
|
+
|
|
32
|
+
Example item:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"title": "Release notes",
|
|
37
|
+
"subtitle": "v2.4",
|
|
38
|
+
"text": "Changelog highlights.",
|
|
39
|
+
"image": "https://example.com/card.jpg",
|
|
40
|
+
"link": { "type": "page", "uri": "/releases/2-4" }
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Attributes (snake_case, string values in HTML)
|
|
45
|
+
|
|
46
|
+
Web component attributes are strings. Objects and arrays must be **JSON-serialized** for `collection`.
|
|
47
|
+
|
|
48
|
+
| Attribute | Required | Description |
|
|
49
|
+
| --- | --- | --- |
|
|
50
|
+
| `collection` | Yes | JSON array of items (see above). Whitespace-only or invalid JSON logs an error and yields an empty grid. |
|
|
51
|
+
| `id` | No | Optional host id (see `Component` in `types/webcomponent.type.d.ts`). |
|
|
52
|
+
|
|
53
|
+
The authoring `Component` type also lists optional **`style`** and **`size`**. Layout **column count** in the current implementation is **not** driven by `size`: it is derived from the window width as roughly one column per **~250px** of width, capped by the number of items. Optional `style` may still be useful for host-level styling depending on how your build wires custom-element props; refer to your bundle’s generated typings if you rely on it.
|
|
54
|
+
|
|
55
|
+
## Layout behavior
|
|
56
|
+
|
|
57
|
+
- The grid uses `grid-template-columns: repeat(N, auto)` where `N` is computed from `innerWidth` (via `svelte:window`) and the collection length, so the archive **reflows on resize**.
|
|
58
|
+
- Cards use full-width images with **`object-fit: cover`** inside the image area.
|
|
59
|
+
|
|
60
|
+
## Events
|
|
61
|
+
|
|
62
|
+
The `Events` map in `types/webcomponent.type.d.ts` defines:
|
|
63
|
+
|
|
64
|
+
| Event | `detail` |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| `collectionItemClick` | `{ uri: string }` |
|
|
15
67
|
|
|
16
|
-
- `
|
|
17
|
-
- `collection` (required): JSON string — `Item[]` (`title`, `text`, `image`, `link`, optional `subtitle`, `index`).
|
|
18
|
-
- `size` (optional): number as string — column count.
|
|
68
|
+
The present Svelte implementation **does not** attach per-item click handlers or dispatch `collectionItemClick`. Use this type when you extend the component or when your toolchain expects the event name; for plain HTML usage, treat navigation as **host-managed** (e.g. wrap cards or listen on a parent) unless a future version wires clicks to `link.uri`.
|
|
19
69
|
|
|
20
|
-
|
|
70
|
+
## Styling (Bulma variables)
|
|
21
71
|
|
|
22
|
-
|
|
72
|
+
The component uses **Bulma 1.x** design tokens on `:host` and in layout (see [Bulma CSS variables](https://bulma.io/documentation/features/css-variables/)). Prefer **`--bulma-*`** custom properties for theme alignment.
|
|
23
73
|
|
|
24
|
-
###
|
|
74
|
+
### CSS custom properties (documented in `extra/docs.ts`)
|
|
25
75
|
|
|
26
|
-
|
|
27
|
-
|
|
76
|
+
| Variable | Role |
|
|
77
|
+
| --- | --- |
|
|
78
|
+
| `--bulma-block-spacing` | Gap between cards in the grid. |
|
|
79
|
+
| `--bulma-radius` | Corner radius on the image frame. |
|
|
80
|
+
| `--bulma-column-gap` | Space between the image block and text block; also used for spacing under the title. |
|
|
81
|
+
| `--bulma-size-5` | Font size for the card title (`h3`). |
|
|
82
|
+
| `--bulma-text` | Color for the description paragraph. |
|
|
83
|
+
| `--bulma-line-height-main` | Line height for body text. |
|
|
28
84
|
|
|
29
|
-
|
|
85
|
+
Defaults fall back to sensible literals in `styles/webcomponent.scss` if a variable is unset.
|
|
86
|
+
|
|
87
|
+
### CSS `::part` selectors
|
|
88
|
+
|
|
89
|
+
| Part | Targets |
|
|
90
|
+
| --- | --- |
|
|
91
|
+
| `container` | Outer grid wrapper (`part="container"`). |
|
|
92
|
+
| `item` | Single card wrapper (`part="item"`). |
|
|
93
|
+
| `image` | The `<img>` element (`part="image"`). |
|
|
94
|
+
| `title` | The `<h3>` (`part="title"`). |
|
|
95
|
+
| `text` | The `<p>` (`part="text"`). |
|
|
96
|
+
|
|
97
|
+
Example:
|
|
98
|
+
|
|
99
|
+
```css
|
|
100
|
+
hb-vertical-img-txt-archive::part(title) {
|
|
101
|
+
font-weight: 700;
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Slots
|
|
106
|
+
|
|
107
|
+
None (`htmlSlots` is empty in `extra/docs.ts`).
|
|
108
|
+
|
|
109
|
+
## Minimal HTML example
|
|
30
110
|
|
|
31
111
|
```html
|
|
32
112
|
<hb-vertical-img-txt-archive
|
|
33
|
-
collection='[{"title":"One","text":"
|
|
34
|
-
size="3"
|
|
113
|
+
collection='[{"title":"One","text":"Short description.","image":"https://placehold.co/300x200","link":{"type":"tab","uri":"https://example.com"}}]'
|
|
35
114
|
></hb-vertical-img-txt-archive>
|
|
36
115
|
```
|
|
116
|
+
|
|
117
|
+
Multi-item example (attribute stays on one line in production, or build the string in JS):
|
|
118
|
+
|
|
119
|
+
```html
|
|
120
|
+
<hb-vertical-img-txt-archive
|
|
121
|
+
collection='[{"title":"Alpha","text":"First item.","image":"https://placehold.co/300x200","link":{"type":"event","uri":"open:alpha"}},{"title":"Beta","text":"Second item.","image":"https://placehold.co/300x200","link":{"type":"page","uri":"/beta"}}]'
|
|
122
|
+
></hb-vertical-img-txt-archive>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Related files
|
|
126
|
+
|
|
127
|
+
- Implementation: `component.wc.svelte`
|
|
128
|
+
- Authoring types: `types/webcomponent.type.d.ts`
|
|
129
|
+
- Metadata, Storybook args, and examples: `extra/docs.ts`
|
|
130
|
+
- Styles: `styles/bulma.scss`, `styles/webcomponent.scss`
|
package/manifest.json
CHANGED
|
@@ -119,26 +119,68 @@
|
|
|
119
119
|
}
|
|
120
120
|
},
|
|
121
121
|
"collectionItemClick": {
|
|
122
|
-
"
|
|
122
|
+
"action": "collectionItemClick"
|
|
123
123
|
}
|
|
124
124
|
},
|
|
125
125
|
"styleSetup": {
|
|
126
|
-
"vars": [
|
|
126
|
+
"vars": [
|
|
127
|
+
{
|
|
128
|
+
"name": "--bulma-block-spacing",
|
|
129
|
+
"valueType": "number",
|
|
130
|
+
"defaultValue": "",
|
|
131
|
+
"description": "Grid gap between archive cards."
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"name": "--bulma-radius",
|
|
135
|
+
"valueType": "number",
|
|
136
|
+
"defaultValue": "",
|
|
137
|
+
"description": "Rounded corners on card images."
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"name": "--bulma-column-gap",
|
|
141
|
+
"valueType": "number",
|
|
142
|
+
"defaultValue": "",
|
|
143
|
+
"description": "Space between image stack and text block."
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"name": "--bulma-size-5",
|
|
147
|
+
"valueType": "number",
|
|
148
|
+
"defaultValue": "",
|
|
149
|
+
"description": "Card title (`h3`) font size."
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"name": "--bulma-text",
|
|
153
|
+
"valueType": "color",
|
|
154
|
+
"defaultValue": "",
|
|
155
|
+
"description": "Body copy color under each title."
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"name": "--bulma-line-height-main",
|
|
159
|
+
"valueType": "number",
|
|
160
|
+
"defaultValue": "",
|
|
161
|
+
"description": "Line height for description paragraphs."
|
|
162
|
+
}
|
|
163
|
+
],
|
|
127
164
|
"parts": [
|
|
128
165
|
{
|
|
129
|
-
"name": "container"
|
|
166
|
+
"name": "container",
|
|
167
|
+
"description": "CSS grid host; column count follows viewport and optional `size`."
|
|
130
168
|
},
|
|
131
169
|
{
|
|
132
|
-
"name": "item"
|
|
170
|
+
"name": "item",
|
|
171
|
+
"description": "Single archive card wrapper (image + text column)."
|
|
133
172
|
},
|
|
134
173
|
{
|
|
135
|
-
"name": "image"
|
|
174
|
+
"name": "image",
|
|
175
|
+
"description": "Cover image element for the card."
|
|
136
176
|
},
|
|
137
177
|
{
|
|
138
|
-
"name": "title"
|
|
178
|
+
"name": "title",
|
|
179
|
+
"description": "Card heading (`h3`)."
|
|
139
180
|
},
|
|
140
181
|
{
|
|
141
|
-
"name": "text"
|
|
182
|
+
"name": "text",
|
|
183
|
+
"description": "Supporting paragraph under the title."
|
|
142
184
|
}
|
|
143
185
|
]
|
|
144
186
|
},
|
|
@@ -399,5 +441,5 @@
|
|
|
399
441
|
"size": {},
|
|
400
442
|
"iifePath": "main.iife.js",
|
|
401
443
|
"repoName": "@htmlbricks/hb-vertical-img-txt-archive",
|
|
402
|
-
"version": "0.71.
|
|
444
|
+
"version": "0.71.36"
|
|
403
445
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htmlbricks/hb-vertical-img-txt-archive",
|
|
3
|
-
"version": "0.71.
|
|
3
|
+
"version": "0.71.36",
|
|
4
4
|
"contributors": [],
|
|
5
5
|
"description": "Vertical archive grid: `collection` items with `title`, `text`, `image`, and `link` (e.g. `type` + `uri`). Optional `size` sets column count; CSS parts style container, item, image, title, and text. Emits `collectionItemClick` when an item is chosen.",
|
|
6
6
|
"licenses": [
|