@htmlbricks/hb-card-video 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.
Files changed (3) hide show
  1. package/README.md +104 -25
  2. package/manifest.json +28 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -2,50 +2,129 @@
2
2
 
3
3
  **Category:** media | **Tags:** media, video
4
4
 
5
- ### What it does
5
+ ### Summary
6
6
 
7
- **Bulma** `card` with a 16:9 `image` frame: YouTube embed when `provider` is `youtube`, otherwise an HTML5 `<video>` with MP4 source. Optional title, truncated description, formatted `time` via Day.js (`dateformat`), “read more” `button is-primary`, and social share placeholders when `pageuri` is set. Bootstrap Icons for the clock in the footer.
7
+ A Bulma **card** with a fixed **16:9** media area at the top, optional title and description, optional timestamp in the footer, and optional “share + action” row when a page URL is supplied. The media area is either an **HTML5 `<video>`** (MP4 `source`) or a **YouTube iframe embed**, depending on `provider`.
8
8
 
9
- ### Custom element
9
+ ### Behavior: native video vs YouTube
10
+
11
+ - **`provider` is `"youtube"`** — Renders an `<iframe>` inside Bulma’s `image is-16by9` figure. Set **`videosrc`** to the **full embed URL** (for example `https://www.youtube.com/embed/VIDEO_ID`). The iframe uses `allowfullscreen` and a static `title` of `YouTube video` for accessibility.
12
+ - **Any other `provider` (including omitted or empty)** — Renders a native **`<video controls>`** with a single **`<source src={videosrc} type="video/mp4">`**, plus an empty captions `<track>` placeholder. The figure uses **`has-background-black`** behind the letterboxed frame.
13
+
14
+ Browsers that do not support `<video>` see the fallback text inside the video element.
15
+
16
+ ### Layout
17
+
18
+ Structure follows Bulma’s **card** pattern:
19
+
20
+ 1. **`card-image`** — 16:9 figure (`image is-16by9`) containing either the iframe or the video.
21
+ 2. **`card-content`** — Optional `title` (`title is-5`), optional description block, then (only if **`pageuri`** is set) Facebook “like” placeholder markup, a Twitter intent link styled as `twitter-share-button`, a line break, and optionally a primary **button** when **`linklabel`** is non-empty.
22
+ 3. **`card-footer`** — Rendered **only when `time` is set**. It wraps a **named slot** (see Slots) whose default content is a small grey line with a clock icon and the formatted date/time.
23
+
24
+ The root inner wrapper uses **`hb-card-video-root`** with flex column layout so the card can stretch vertically (`card-content` grows with `flex: 1`).
25
+
26
+ ### Logic
27
+
28
+ - **Description** — If `description` is longer than **100 characters**, the UI shows only the **first 100 characters** (no ellipsis added in markup).
29
+ - **`time` + `dateformat`** — When `time` is provided, the footer shows **Day.js**–formatted text. Default **`dateformat`** is `dddd DD MMMM YYYY HH:mm`. The formatter uses **`navigator.language`** as the Day.js locale, then applies a small transform that **uppercases the first letter of each word** in the formatted string.
30
+ - **`pageuri`** — When set, the content area includes **Facebook** (`fb-like` div with `data-href`, etc.) and **Twitter** (`twitter-share-button` / intent URL) **placeholder markup**. Those widgets only become interactive if the **host page** loads the corresponding third-party scripts and initializes them; this component does not bundle those SDKs.
31
+ - **`linklabel`** — Defaults to **`read more`**. The primary **`<a class="button is-primary">`** is rendered only when **`pageuri`** is set **and** `linklabel` is truthy with **non-zero** length (so an empty string hides the button even if `pageuri` is set).
32
+
33
+ ### Custom element tag
10
34
 
11
35
  `hb-card-video`
12
36
 
13
- ### Attributes / props (snake_case)
37
+ ### Attributes (names as in typings; string values from HTML)
14
38
 
15
- | Property | Type | Notes |
39
+ From HTML / `setAttribute`, values are **strings** (dates as parseable strings, for example ISO 8601). Use the same attribute names as in the table below (aligned with this package’s typings and custom-element props).
40
+
41
+ | Attribute | Required | Description |
16
42
  | --- | --- | --- |
17
- | `id` | string (optional) | Element identifier. |
18
- | `style` | string (optional) | Inline style string. |
19
- | `title` | string (optional) | Card title. |
20
- | `description` | string (optional) | Body text (truncated in UI). |
21
- | `videosrc` | string (required) | Video URL or embed source. |
22
- | `provider` | union (optional) | `"youtube"` or `""` for native video. |
23
- | `pageuri` | string (optional) | Page URL for share widgets. |
24
- | `linklabel` | string (optional) | Label for the “read more” style link. |
25
- | `time` | Date (optional) | Publication or event time; pass parseable date string in HTML. |
26
- | `dateformat` | string (optional) | Day.js format string for `time`. |
43
+ | `videosrc` | **Yes** | URL for the MP4 `source` (native video) or the full **YouTube embed** URL (`provider="youtube"`). |
44
+ | `provider` | No | Set to **`youtube`** for iframe mode; omit or use an empty string for native `<video>`. |
45
+ | `title` | No | Card heading (`title is-5`). |
46
+ | `description` | No | Body paragraph; truncated to **100** characters in the UI when longer. |
47
+ | `pageuri` | No | Canonical URL passed into share placeholders and the optional primary button `href`. |
48
+ | `linklabel` | No | Label for the primary button when `pageuri` is set; implementation default **`read more`**. |
49
+ | `time` | No | When set, shows the footer with formatted clock line (or slot content). Use a string the runtime can treat as a `Date` (for example `2026-03-01T12:00:00.000Z`). |
50
+ | `dateformat` | No | Day.js format string; default **`dddd DD MMMM YYYY HH:mm`**. |
51
+ | `id` | No | Passed through for the host / styling hooks. |
52
+ | `style` | No | Inline style string on the component, if your setup forwards it. |
53
+
54
+ ### Events
55
+
56
+ None. The public **`Events`** type is `{}` — no custom `CustomEvent` payloads are declared for this component.
57
+
58
+ ### Styling
59
+
60
+ The shadow tree bundles **Bulma 1.x** pieces needed for the card, image ratio, typography, button, and content spacing. **Bootstrap Icons** are loaded for the footer clock icon (see `styles/webcomponent.scss`).
27
61
 
28
- **Slot:** `card-footer`. No CSS vars in metadata.
62
+ #### CSS custom properties
29
63
 
30
- ### Events (`CustomEvent` names)
64
+ | Variable | Role |
65
+ | --- | --- |
66
+ | `--bulma-black` | Background behind the 16:9 **native** video frame (`has-background-black`). |
67
+ | `--bulma-primary` | Primary **button** (`is-primary`) for the `pageuri` action. |
68
+ | `--bulma-text` | Title and body copy. |
69
+ | `--bulma-link` | Link-toned controls where Bulma applies link styling. |
31
70
 
32
- None declared in types (`Events` is an empty object).
71
+ Other **`--bulma-*`** variables from the bundled Bulma setup may apply on `:host`; see [Bulma CSS variables](https://bulma.io/documentation/features/css-variables/).
33
72
 
34
- ### Usage notes
73
+ #### CSS parts (`::part`)
35
74
 
36
- - Card layout follows Bulma `card` / `card-image` / `card-content` / `card-footer` patterns.
37
- - YouTube vs file video is selected only via `provider`; ensure `videosrc` matches the mode.
38
- - Shadow DOM contains the player and share UI; slot `card-footer` extends the card.
39
- - No i18n in `docs.ts`.
75
+ None exposed (`cssParts` is empty in `extra/docs.ts`).
40
76
 
41
- ### Minimal HTML example
77
+ #### HTML slots
78
+
79
+ | Slot | Description |
80
+ | --- | --- |
81
+ | `card-footer` | **Named slot** inside **`card-footer`**, only when **`time`** is set. **Default** slot content is the formatted timestamp row (clock icon + Day.js output). If you supply **slotted** content for `card-footer`, it **replaces** that default (standard slot behavior), while the outer `<footer class="card-footer">` wrapper remains. |
82
+
83
+ ### Typings (`types/webcomponent.type.d.ts`)
84
+
85
+ ```ts
86
+ export type Component = {
87
+ id?: string;
88
+ style?: string;
89
+ title?: string;
90
+ description?: string;
91
+ videosrc: string;
92
+ provider?: "youtube" | "";
93
+ pageuri?: string;
94
+ linklabel?: string;
95
+ time?: Date;
96
+ dateformat?: string;
97
+ };
98
+
99
+ export type Events = {};
100
+ ```
101
+
102
+ Use this shape for TypeScript wrappers, Storybook args, or casts when querying the host element. Remember that **DOM attributes are still strings** at the boundary even when typings use `Date` for `time`.
103
+
104
+ ### Example
105
+
106
+ **Native MP4**
42
107
 
43
108
  ```html
44
109
  <hb-card-video
45
- videosrc="https://example.com/media/clip.mp4"
110
+ videosrc="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4"
46
111
  title="Product tour"
47
112
  description="A short walkthrough of the dashboard."
48
113
  time="2026-03-01T12:00:00.000Z"
49
114
  dateformat="MMM D, YYYY"
115
+ pageuri="https://example.com/posts/product-tour"
116
+ linklabel="Open post"
117
+ ></hb-card-video>
118
+ ```
119
+
120
+ **YouTube embed**
121
+
122
+ ```html
123
+ <hb-card-video
124
+ videosrc="https://www.youtube.com/embed/dQw4w9WgXcQ"
125
+ provider="youtube"
126
+ title="Sample clip"
127
+ description="Embedded iframe player."
128
+ time="2024-01-01T12:00:00.000Z"
50
129
  ></hb-card-video>
51
130
  ```
package/manifest.json CHANGED
@@ -105,14 +105,39 @@
105
105
  }
106
106
  },
107
107
  "styleSetup": {
108
- "vars": [],
108
+ "vars": [
109
+ {
110
+ "name": "--bulma-black",
111
+ "valueType": "color",
112
+ "defaultValue": "#000",
113
+ "description": "Background behind the 16:9 media frame (`.has-background-black` on the video area)."
114
+ },
115
+ {
116
+ "name": "--bulma-primary",
117
+ "valueType": "color",
118
+ "defaultValue": "#00d1b2",
119
+ "description": "Primary “read more” / action `button is-primary` styling."
120
+ },
121
+ {
122
+ "name": "--bulma-text",
123
+ "valueType": "color",
124
+ "defaultValue": "#363636",
125
+ "description": "Card title and body copy."
126
+ },
127
+ {
128
+ "name": "--bulma-link",
129
+ "valueType": "color",
130
+ "defaultValue": "#485fc7",
131
+ "description": "Link-styled controls in the card content when used."
132
+ }
133
+ ],
109
134
  "parts": []
110
135
  },
111
136
  "contributors": [],
112
137
  "htmlSlots": [
113
138
  {
114
139
  "name": "card-footer",
115
- "description": ""
140
+ "description": "Extra actions or metadata below the default footer (timestamp row and share placeholders); appends inside the Bulma `card-footer`."
116
141
  }
117
142
  ],
118
143
  "i18n": [],
@@ -180,5 +205,5 @@
180
205
  "size": {},
181
206
  "iifePath": "main.iife.js",
182
207
  "repoName": "@htmlbricks/hb-card-video",
183
- "version": "0.71.35"
208
+ "version": "0.71.36"
184
209
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htmlbricks/hb-card-video",
3
- "version": "0.71.35",
3
+ "version": "0.71.36",
4
4
  "contributors": [],
5
5
  "description": "Bulma `card` with a 16:9 `image` frame: YouTube embed when `provider` is `youtube`, otherwise an HTML5 `<video>` with MP4 source. Optional title, truncated description (100 chars), formatted `time` via Day.js (`dateformat`), “read more” primary button, and social share placeholders (Facebook/Twitter widgets) when `pageuri` is set.",
6
6
  "licenses": [