@htmlbricks/hb-paragraps-around-image 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,37 +1,122 @@
1
- ## `hb-paragraps-around-image` — paragraphs around image
1
+ # `hb-paragraps-around-image` — integrator guide
2
2
 
3
- **Category:** content
4
- **Tags:** content
3
+ **Category:** content · **Tags:** content · **Package:** `@htmlbricks/hb-paragraps-around-image`
5
4
 
6
- ### What it does
5
+ **Dependency:** registers **`hb-paragraps-around-image-cell`** at runtime (`addComponent`, same bundle version).
7
6
 
8
- Editorial block with a central image and up to six text blocks in two side columns using `hb-paragraps-around-image-cell` (indices 0, 2, 4 left; 1, 3, 5 right). Parses `paragraphs` from JSON and bubbles `paragraphPressed` when a cell fires it.
7
+ ## Summary
9
8
 
10
- ### Custom element
9
+ `hb-paragraps-around-image` is an editorial layout: a **center column image** flanked by **up to six** rich text blocks rendered as `hb-paragraps-around-image-cell` instances. Paragraph data is supplied as a **JSON string**; each cell is capped at **eight lines** of body text (`max_lines="8"` in the implementation).
11
10
 
12
- `hb-paragraps-around-image`
11
+ The host does not render until **both** a non-empty `paragraphs` array (after parsing) and a non-empty `img` URL are present.
13
12
 
14
- ### Attributes (snake_case; use string values in HTML)
13
+ ## Layout and paragraph order
15
14
 
16
- - `id`, `style` (optional): strings.
17
- - `img` (required): string — image URL.
18
- - `paragraphs` (required): JSON string — array of `{ text; title?; icon?; link?; key? }`.
15
+ On viewports **900px and wider**, the outer container is a horizontal flex row with three columns: **left**, **center** (image), **right**. Below that breakpoint the block still uses the same DOM order; spacing and flex behavior follow `styles/webcomponent.scss`.
19
16
 
20
- ### Events
17
+ Paragraphs map to columns by **array index** (0-based):
21
18
 
22
- - `paragraphPressed`: `{ key: string }`.
19
+ | Index | Column |
20
+ |-------|--------|
21
+ | 0, 2, 4 | Left |
22
+ | 1, 3, 5 | Right |
23
23
 
24
- ### Usage notes
24
+ Omitted indices simply leave a gap in that column (for example, a single object only fills the top-left cell). You can use up to **six** entries for a full two-column stack.
25
25
 
26
- - **Slots:** none (layout is composed from `hb-paragraps-around-image-cell` children).
27
- - **CSS parts:** `testpart`.
28
- - Up to six paragraph objects; layout alternates columns per index.
26
+ ## Paragraph object shape
29
27
 
30
- ### Minimal HTML example
28
+ Each item in the `paragraphs` array matches the `Paragraphs` type:
29
+
30
+ | Field | Required | Description |
31
+ |-------|----------|-------------|
32
+ | `text` | Yes | Body copy (line-clamped per cell). |
33
+ | `title` | No | Heading shown by the cell. |
34
+ | `icon` | No | Bootstrap Icons **icon name** (e.g. `globe`, `journal-text`) used inside the cell. |
35
+ | `link` | No | If set, the title behaves as a link to this URL. |
36
+ | `key` | No | Identifier forwarded on `paragraphPressed` when the cell reports a press (see Events). |
37
+
38
+ Icons rely on **Bootstrap Icons**; the component loads the icon font from a CDN (`<svelte:head>` in the implementation, plus a font import in `styles/webcomponent.scss`).
39
+
40
+ ## Custom element tag
41
+
42
+ ```html
43
+ <hb-paragraps-around-image …></hb-paragraps-around-image>
44
+ ```
45
+
46
+ ## Attributes (HTML / reflected props)
47
+
48
+ Web component attributes are **strings** (**snake_case**).
49
+
50
+ | Attribute | Required | Description |
51
+ |-----------|----------|-------------|
52
+ | `img` | No | Center column image URL (non-empty **`img`** plus parsed **`paragraphs`** required for the layout to render). |
53
+ | `paragraphs` | No | JSON string or array: paragraph objects (see above). Parsed in an **`$effect`**; invalid JSON is ignored. |
54
+ | `id` | No | Optional host id. |
55
+ | `style` | No | Optional on **`Component`**; host **`style`** still applies in the light DOM. |
56
+
57
+ ## Events
58
+
59
+ | Event | `detail` | When |
60
+ |-------|----------|------|
61
+ | `paragraphPressed` | `{ key: string }` | Bubbled from a child `hb-paragraps-around-image-cell` when it emits `paragraphPressed`. Consumers should set a stable `key` on each paragraph object if they need to identify which block was activated. |
62
+
63
+ Listen with `addEventListener("paragraphPressed", ...)` or your framework’s equivalent.
64
+
65
+ ## Styling (Bulma theme variables)
66
+
67
+ The component forwards shared Bulma setup (`styles/bulma.scss`) and local layout (`styles/webcomponent.scss`). Set public **`--bulma-*`** variables on `body`, `:root`, or an ancestor so they cascade into `:host` and nested cells. See [Bulma CSS variables](https://bulma.io/documentation/features/css-variables/).
68
+
69
+ | Variable | Role |
70
+ |----------|------|
71
+ | `--bulma-block-spacing` | Horizontal padding on the left and right columns (`.col`). Default in metadata: `1.5rem`. |
72
+ | `--bulma-text` | Default body text color (inherited by nested `hb-paragraps-around-image-cell`). |
73
+ | `--bulma-link` | Title links and interactive affordances in child cells. |
74
+ | `--bulma-text-strong` | Strong / title-weight copy where the theme distinguishes it. |
75
+
76
+ **Slots:** none — layout is entirely data-driven.
77
+ **CSS parts:** none on this host.
78
+
79
+ ## Minimal example
31
80
 
32
81
  ```html
33
82
  <hb-paragraps-around-image
34
83
  img="https://placehold.co/300x200"
35
- paragraphs='[{"text":"Hello body","title":"Title","icon":"globe","link":"https://example.com"}]'
84
+ paragraphs='[{"text":"Body copy here.","title":"Title","icon":"globe","link":"https://example.com","key":"intro"}]'
36
85
  ></hb-paragraps-around-image>
37
86
  ```
87
+
88
+ ## Multi-block example (two columns)
89
+
90
+ ```html
91
+ <hb-paragraps-around-image
92
+ img="https://placehold.co/300x200"
93
+ paragraphs='[
94
+ {"text":"Left column first block.","title":"Left 1","icon":"journal-text","link":"https://example.com","key":"L1"},
95
+ {"text":"Right column first block.","title":"Right 1","icon":"journal-text","link":"https://example.org","key":"R1"},
96
+ {"text":"Left column second block.","title":"Left 2","icon":"journal-text","key":"L2"},
97
+ {"text":"Right column second block.","title":"Right 2","icon":"journal-text","key":"R2"}
98
+ ]'
99
+ ></hb-paragraps-around-image>
100
+ ```
101
+
102
+ ## Script listener example
103
+
104
+ ```html
105
+ <hb-paragraps-around-image
106
+ id="editorial"
107
+ img="https://placehold.co/300x200"
108
+ paragraphs='[{"text":"Click the title if it is a link; keys identify blocks.","title":"Press me","key":"block-a"}]'
109
+ ></hb-paragraps-around-image>
110
+
111
+ <script>
112
+ document.getElementById("editorial")?.addEventListener("paragraphPressed", (e) => {
113
+ console.log("key:", e.detail.key);
114
+ });
115
+ </script>
116
+ ```
117
+
118
+ ## Implementation notes for integrators
119
+
120
+ - **Empty state:** If `paragraphs` is missing, empty, not parseable as JSON, or `img` is missing, nothing inside `#container` is shown.
121
+ - **Child package:** Ensure `hb-paragraps-around-image-cell` is available (same bundle or registered before use) so nested custom elements upgrade correctly.
122
+ - **Accessibility:** Central image uses `alt=""`; prefer meaningful `img` URLs or extend the cell package if you need richer semantics.