@htmlbricks/hb-site-slideshow-horizontal 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 CHANGED
@@ -1,36 +1,161 @@
1
- ## `hb-site-slideshow-horizontal` — site-slideshow-horizontal
1
+ # `hb-site-slideshow-horizontal` — integrator guide
2
2
 
3
- **Category:** content
4
- **Tags:** content, media
3
+ **Category:** content · **Tags:** content, media · **Package:** `@htmlbricks/hb-site-slideshow-horizontal`
5
4
 
6
- ### What it does
5
+ ## Summary
7
6
 
8
- Horizontal media strip: `data` lists slides with `href`, `caption`, and optional `link`, `externalLink`, `key`, or `duration` for video-style rows. Set `type` to `videos` for that layout; optional `slide` index and `size`. Emits `slideClick` when a slide is activated.
7
+ Horizontal slideshow strip that shows a window of image (or video-style) tiles, with previous/next arrows. Slides are **data-driven** (JSON); there are no light DOM slots.
9
8
 
10
- ### Custom element
9
+ ## Behavior
11
10
 
12
- `hb-site-slideshow-horizontal`
11
+ - Accepts a **required** `data` payload: an ordered list of slides. Each slide must include a **`href`** (image URL). Entries without `href` are dropped.
12
+ - Slides are sorted by optional **`index`** (ascending), then renumbered internally from `0`.
13
+ - The strip shows **`size`** tiles at once when you set `size` as a positive number. If you omit `size`, the count is derived from the viewport: `round(windowInnerWidth / 250)` (minimum practical width still comes from the host).
14
+ - **`slide`** is the starting index into the flattened list (also used as the window offset for the arrows). It can be synced from the outside; string values are coerced with `Number(...)`.
15
+ - **Previous / next** arrows shift that index and **wrap** across the list so the window is always filled when there are more slides than visible tiles (the implementation may concatenate from the beginning of the list to pad the row).
16
+ - **`type`** switches between a plain image caption layout (`images`, default) and a **video-style** row with a play affordance and optional **`duration`** text.
13
17
 
14
- ### Attributes (snake_case; use string values in HTML)
18
+ ---
15
19
 
16
- - `id` (optional), `style` (optional): strings.
17
- - `data` (required): JSON string — array of `{ href; caption?; externalLink?; link?; key?; duration?; index? }`.
18
- - `type` (optional): `"images"` | `"videos"`.
19
- - `slide` (optional): number as string (current slide).
20
- - `size` (optional): number as string.
20
+ ## Custom element
21
21
 
22
- ### Events
22
+ ```html
23
+ <hb-site-slideshow-horizontal></hb-site-slideshow-horizontal>
24
+ ```
25
+
26
+ Tag name: **`hb-site-slideshow-horizontal`**
27
+
28
+ ---
29
+
30
+ ## Slide model (`data` items)
31
+
32
+ Each object in the `data` array can include:
33
+
34
+ | Field | Required | Description |
35
+ | --- | --- | --- |
36
+ | `href` | **Yes** | Image URL for the tile. |
37
+ | `caption` | No | Shown under the play overlay in `videos` mode, or as an overlay caption in `images` mode when present. |
38
+ | `index` | No | Sort hint before display (lower first). |
39
+ | `externalLink` | No | If set, clicking the tile opens this URL in a **new** tab (`_blank`). Takes precedence over `link` and `key`. |
40
+ | `link` | No | If set (and no `externalLink`), clicking sets **`window.location.href`** to this URL. |
41
+ | `key` | No | If set (and neither `externalLink` nor `link`), clicking dispatches the **`slideClick`** custom event with `{ key }`. |
42
+ | `duration` | No | In `videos` mode, optional duration string next to the title (exposed via CSS part `video_sub_time`). |
43
+
44
+ If none of `externalLink`, `link`, or `key` is set, the tile is **non-interactive** (still shows image/caption UI).
45
+
46
+ ---
47
+
48
+ ## Attributes and properties (web component)
49
+
50
+ Use **snake_case** names. In HTML, **attribute values are strings**: pass JSON as a string for `data`, and numeric fields as their decimal string form.
51
+
52
+ | Name | Required | Description |
53
+ | --- | --- | --- |
54
+ | `data` | **Yes** | JSON string: array of slide objects (see above). Invalid JSON logs an error and yields an empty strip (nothing rendered). |
55
+ | `type` | No | `"images"` (default) or `"videos"`. |
56
+ | `slide` | No | Current / initial slide index (stringified number). |
57
+ | `size` | No | Number of visible tiles per row (stringified integer). When omitted, width-based sizing is used. |
58
+ | `id` | No | Passed through for identification (standard host usage). |
59
+
60
+ The authoring **`Component`** type also lists an optional `style` field; the current shadow implementation does **not** apply it—prefer styling via **CSS custom properties** and global layout around the host.
61
+
62
+ ---
63
+
64
+ ## Events
65
+
66
+ Listen with `addEventListener` or the equivalent in your framework.
67
+
68
+ | Event | `detail` | When |
69
+ | --- | --- | --- |
70
+ | `slideClick` | `{ key: string }` | User activates a slide that defines **`key`** and does not use `externalLink` or `link`. |
71
+
72
+ ---
73
+
74
+ ## Styling (Bulma tokens)
75
+
76
+ The component uses Bulma **CSS variables** on `:host` for spacing and arrow chrome. See [Bulma CSS variables](https://bulma.io/documentation/features/css-variables/).
77
+
78
+ ### Common CSS custom properties
79
+
80
+ | Variable | Role |
81
+ | --- | --- |
82
+ | `--bulma-block-spacing` | Vertical margin for the strip and horizontal padding on the arrow hit areas. |
83
+ | `--bulma-white` | Color of the arrow glyphs on the gradient fades. |
84
+ | `--bulma-scheme-invert` | Base for arrow gradient overlays and hover contrast. |
85
+
86
+ ### CSS shadow parts
23
87
 
24
- - `slideClick`: `{ key: string }`.
88
+ Style from outside the shadow root with `::part(...)`.
25
89
 
26
- ### Usage notes
90
+ | Part | Role |
91
+ | --- | --- |
92
+ | `video_sub_title` | Title line under the play affordance when `type` is `videos`. |
93
+ | `video_sub_time` | Duration text beside the title when `duration` is set. |
94
+ | `caption_content` | Caption text for image-style slides (`type` `images`). |
27
95
 
28
- - **CSS parts:** `video_sub_title`, `caption_content` (see `extra/docs.ts` for full list).
96
+ ### Slots
29
97
 
30
- ### Minimal HTML example
98
+ None—content is entirely driven by the `data` JSON.
99
+
100
+ ---
101
+
102
+ ## Minimal HTML example
103
+
104
+ ```html
105
+ <hb-site-slideshow-horizontal
106
+ data='[
107
+ {"href":"https://placehold.co/600x400/111/fff","caption":"One"},
108
+ {"href":"https://placehold.co/600x400/222/fff","caption":"Two"}
109
+ ]'
110
+ ></hb-site-slideshow-horizontal>
111
+ ```
112
+
113
+ ### Video-style layout
114
+
115
+ ```html
116
+ <hb-site-slideshow-horizontal
117
+ type="videos"
118
+ data='[
119
+ {"href":"https://placehold.co/640x360/000/fff","caption":"Intro","duration":"0:42"}
120
+ ]'
121
+ ></hb-site-slideshow-horizontal>
122
+ ```
123
+
124
+ ### Initial index, fixed strip width, and `slideClick`
31
125
 
32
126
  ```html
33
127
  <hb-site-slideshow-horizontal
34
- data='[{"href":"https://placehold.co/600x400","caption":"Slide 1"},{"href":"https://placehold.co/600x401","caption":"Slide 2"}]'
128
+ id="strip"
129
+ slide="1"
130
+ size="5"
131
+ data='[
132
+ {"href":"https://placehold.co/400x300/004d40/fff?text=A"},
133
+ {"href":"https://placehold.co/400x300/1b5e20/fff?text=B","key":"b"},
134
+ {"href":"https://placehold.co/400x300/33691e/fff?text=C"}
135
+ ]'
35
136
  ></hb-site-slideshow-horizontal>
137
+
138
+ <script>
139
+ document.getElementById("strip").addEventListener("slideClick", (e) => {
140
+ console.log("key:", e.detail.key);
141
+ });
142
+ </script>
36
143
  ```
144
+
145
+ ---
146
+
147
+ ## TypeScript (authoring)
148
+
149
+ Props and events for wrappers or Storybook align with `types/webcomponent.type.d.ts`:
150
+
151
+ - **`Component`**: `id`, `data`, optional `slide`, `type`, `size`, and optional `style` (see note above).
152
+ - **`Data`**: slide item shape.
153
+ - **`Events`**: `slideClick` with `{ key: string }`.
154
+
155
+ ---
156
+
157
+ ## Behavior notes
158
+
159
+ - If **`data`** parses to an empty list, or every item lacks `href`, the component **renders nothing** (no arrows, no section).
160
+ - Negative **`slide`** values are supported by the internal windowing logic; extremely negative values are normalized toward the start of the list.
161
+ - Tiles use pointer interactions on the host page; ensure slide `href` values and link targets meet your accessibility and security policies.