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