@htmlbricks/hb-site-paragraph-with-image 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.
Files changed (3) hide show
  1. package/README.md +109 -21
  2. package/manifest.json +38 -13
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,39 +1,127 @@
1
- ## `hb-site-paragraph-with-image` — site-paragraph-with-image
1
+ # hb-site-paragraph-with-image
2
2
 
3
- **Category:** content
4
- **Tags:** content
3
+ **Package:** `@htmlbricks/hb-site-paragraph-with-image` · **Custom element:** `hb-site-paragraph-with-image`
4
+ **Category:** content · **Tags:** content
5
5
 
6
- ### What it does
6
+ ## Description
7
7
 
8
- Marketing block pairing an image (`img`: `src`, optional `alt`) with rich text (`text`: optional `title`, `body`, optional `link` with `label` and optional `src`, `key`, colors). Use `text_side` (`left` / `right`) and `half_space` for layout; CSS parts cover mobile and desktop. CTA uses a **Bulma** `button is-primary` (custom link colors still applied inline). Fires `elClick` when the link is activated.
8
+ A marketing-style content block that pairs a hero **image** with **title**, **body**, and an optional **call-to-action** button. Layout switches between a stacked **mobile** presentation and a side-by-side **wide** row based on the host viewport width. Styling is **Bulma 1.x** inside the shadow root (section spacing, typography, and a primary `button` for the CTA).
9
9
 
10
- ### Custom element
10
+ ## Layout and breakpoints
11
11
 
12
- `hb-site-paragraph-with-image`
12
+ - **Narrow layout** (when the window inner width is **under 800px**): copy appears first (when `text.title` or `text.body` is present), then the image. Each region exposes dedicated `::part` names prefixed with `mobile_`.
13
+ - **Wide layout** (**800px and wider**): a horizontal flex row places the **image** and **text** columns according to **`text_side`**:
14
+ - **`text_side="right"`** (default): image column first, text column second.
15
+ - **`text_side="left"`**: text column first, image column second.
16
+ - Any value other than **`left`** is treated as **`right`** (including empty or unknown strings after normalization).
17
+ - **`half_space`**: on wide layouts, the **image** column uses **`flex-grow: 5`** when `half_space` is enabled, and **`flex-grow: 2`** when it is disabled, so you can bias how much horizontal space the image takes relative to the text column.
13
18
 
14
- ### Attributes (snake_case; use string values in HTML)
19
+ If neither `text.title` nor `text.body` is set, the component shows a plain **“no title or body”** placeholder in the text area. If `img.src` is missing, it shows **“no img”** in the image area.
15
20
 
16
- - `id` (optional), `style` (optional): strings.
17
- - `img` (required): JSON string — `{ src: string; alt?: string }`.
18
- - `text` (required): JSON string — `{ title?, body?, link?: { label; src?; key?; bgColor?; textColor? } }`.
19
- - `text_side` (optional): `"left"` | `"right"`.
20
- - `half_space` (optional): boolean as string when used from HTML.
21
+ ## Props and attributes
21
22
 
22
- ### Events
23
+ Attributes use **snake_case**. From HTML, pass **strings**; nested structures use **JSON strings** (see project conventions: booleans as **`yes`** / **`no`** where applicable).
23
24
 
24
- - `elClick`: `{ key: string }`.
25
+ | Attribute | Required | Description |
26
+ |-----------|----------|-------------|
27
+ | `img` | Yes | JSON object: **`{ "src": string, "alt"?: string }`**. `src` is the image URL. `alt` is passed to the `<img>` when present. |
28
+ | `text` | Yes | JSON object: optional **`title`**, **`body`**, and optional **`link`** (see [Link object](#link-object)). At least one of `title` or `body` should be set for meaningful copy. |
29
+ | `text_side` | No | **`"left"`** or **`"right"`**. Controls column order on wide layouts. Defaults to **`right`**. |
30
+ | `half_space` | No | Wider image column when truthy. From attributes, the implementation treats the string **`"yes"`**, the string **`"true"`**, or boolean **`true`** (after coercion) as enabled. Prefer **`yes`** / **`no`** for HTML consistency with other web components in this library. |
31
+ | `id` | No | Optional identifier (typed on the component; reserved for host integration). |
32
+ | `style` | No | Optional inline host style (present on the TypeScript `Component` type; not applied by the current Svelte implementation). |
25
33
 
26
- ### Usage notes
34
+ The component parses **`img`** and **`text`** when they arrive as strings (typical from HTML attributes) via `JSON.parse` inside an effect.
27
35
 
28
- - **CSS parts:** `mobile_text_content`, `mobile_title`, `mobile_text_body`, `mobile_link_button`, `mobile_image_content`, `image_content`, `text_content`, `link_button`, `title`, `text_body`.
29
- - No `htmlSlots` in docs; structure is prop-driven.
36
+ ### `img` object
30
37
 
31
- ### Minimal HTML example
38
+ | Field | Required | Description |
39
+ |-------|----------|-------------|
40
+ | `src` | Yes | Image URL used for the `<img>` element. |
41
+ | `alt` | No | Alternate text for the image. |
42
+
43
+ ### `text` object
44
+
45
+ | Field | Type | Description |
46
+ |-------|------|-------------|
47
+ | `title` | string | Optional main heading (rendered as **`h1`** in both layouts). |
48
+ | `body` | string | Optional body copy (single **`<p>`**). |
49
+ | `link` | object | Optional CTA; see [Link object](#link-object). |
50
+
51
+ ### Link object
52
+
53
+ | Field | Required | Description |
54
+ |-------|----------|-------------|
55
+ | `label` | Yes (for a visible button) | Button label. A Bulma **`button is-primary`** is rendered only when `label` is set. |
56
+ | `key` | No | Logical key forwarded in **`elClick`** when the button is activated (see [Events](#events)). |
57
+ | `src` | No | Reserved in the type definition for host apps; **this component does not navigate** or open URLs from `src` automatically. |
58
+ | `bgColor` | No | When set, applied inline as **background** and **border** color on the CTA. |
59
+ | `textColor` | No | When set, applied inline as **text** color on the CTA. |
60
+
61
+ ## Events
62
+
63
+ Listen with `addEventListener` or your framework’s event binding.
64
+
65
+ | Event | `detail` | When it fires |
66
+ |-------|----------|----------------|
67
+ | `elClick` | `{ key: string }` | When the user activates the CTA **and** `text.link.key` is defined. The `detail.key` matches `text.link.key`. |
68
+
69
+ If the user clicks the CTA but **`text.link.key`** is missing, the handler logs a console warning (**`"no key"`**) and **does not** dispatch `elClick`. To receive clicks, always set a **`key`** on `text.link` when you rely on this event.
70
+
71
+ ## Styling (Bulma CSS variables)
72
+
73
+ The shadow tree uses **Bulma 1.x** and shared host baseline styles. Theme the block from the light DOM by setting **`--bulma-*`** variables so they inherit onto the custom element. Documented overrides (from component metadata):
74
+
75
+ | Variable | Role |
76
+ |----------|------|
77
+ | `--bulma-section-padding` | Feeds internal **`--hb-spiw-pad`** for host padding and text column insets (see `styles/webcomponent.scss`). |
78
+ | `--bulma-primary` | Primary CTA styling for **`button is-primary`** when a link is present. |
79
+ | `--bulma-text` | Title and body copy color. |
80
+ | `--bulma-text-strong` | Strong heading / emphasis tone where Bulma maps it. |
81
+
82
+ The host also uses **`min-height: 21.875rem`** and **`display: block`** so the section keeps a stable footprint in page layouts.
83
+
84
+ ## CSS `::part`
85
+
86
+ Use these part names to style inner surfaces without piercing the shadow root arbitrarily.
87
+
88
+ | Part | Description |
89
+ |------|-------------|
90
+ | `mobile_text_content` | Mobile column wrapping title, body, and CTA. |
91
+ | `mobile_title` | Mobile headline (`h1`). |
92
+ | `mobile_text_body` | Mobile body paragraph. |
93
+ | `mobile_link_button` | Mobile primary CTA button. |
94
+ | `mobile_image_content` | Mobile figure wrapper around the image. |
95
+ | `image_content` | Wide-layout image column surface. |
96
+ | `text_content` | Wide-layout text column wrapper (title, body, CTA). |
97
+ | `link_button` | Wide-layout primary CTA button. |
98
+ | `title` | Wide-layout section headline (`h1`). |
99
+ | `text_body` | Wide-layout body paragraph. |
100
+
101
+ ## Slots
102
+
103
+ None. All structure and copy come from the **`img`** and **`text`** attributes (JSON).
104
+
105
+ ## Minimal HTML example
32
106
 
33
107
  ```html
34
108
  <hb-site-paragraph-with-image
35
- img='{"src":"https://example.com/image.png","alt":"Logo"}'
36
- text='{"title":"Heading","body":"Short copy.","link":{"label":"Read more"}}'
109
+ img='{"src":"https://example.com/hero.png","alt":"Product"}'
110
+ text='{"title":"Built for clarity","body":"Short supporting copy goes here.","link":{"label":"Learn more","key":"learn-more"}}'
37
111
  text_side="right"
112
+ half_space="yes"
38
113
  ></hb-site-paragraph-with-image>
39
114
  ```
115
+
116
+ ### Listening for `elClick`
117
+
118
+ ```html
119
+ <script>
120
+ const el = document.querySelector("hb-site-paragraph-with-image");
121
+ el.addEventListener("elClick", (e) => {
122
+ console.log("CTA key:", e.detail.key);
123
+ });
124
+ </script>
125
+ ```
126
+
127
+ Ensure **`text.link.key`** is set whenever you need this event; the label alone is not enough for dispatch.
package/manifest.json CHANGED
@@ -143,47 +143,72 @@
143
143
  }
144
144
  },
145
145
  "styleSetup": {
146
- "vars": [],
146
+ "vars": [
147
+ {
148
+ "name": "--bulma-section-padding",
149
+ "valueType": "number",
150
+ "defaultValue": "",
151
+ "description": "Feeds `--hb-spiw-pad` for host padding and text column insets."
152
+ },
153
+ {
154
+ "name": "--bulma-primary",
155
+ "valueType": "color",
156
+ "defaultValue": "",
157
+ "description": "Primary CTA (`button is-primary`) when a `link` is present."
158
+ },
159
+ {
160
+ "name": "--bulma-text",
161
+ "valueType": "color",
162
+ "defaultValue": "",
163
+ "description": "Title and body copy."
164
+ },
165
+ {
166
+ "name": "--bulma-text-strong",
167
+ "valueType": "color",
168
+ "defaultValue": "",
169
+ "description": "Heading weight / strong emphasis where Bulma maps it."
170
+ }
171
+ ],
147
172
  "parts": [
148
173
  {
149
174
  "name": "mobile_text_content",
150
- "description": "mobile_text_content"
175
+ "description": "Stacked mobile column wrapping title, body, and CTA."
151
176
  },
152
177
  {
153
178
  "name": "mobile_title",
154
- "description": "mobile_title"
179
+ "description": "Mobile headline (`h1`) above the body."
155
180
  },
156
181
  {
157
182
  "name": "mobile_text_body",
158
- "description": "mobile_text_body"
183
+ "description": "Mobile paragraph body."
159
184
  },
160
185
  {
161
186
  "name": "mobile_link_button",
162
- "description": "mobile_link_button"
187
+ "description": "Mobile primary button wrapping the optional link."
163
188
  },
164
189
  {
165
190
  "name": "mobile_image_content",
166
- "description": "mobile_image_content"
191
+ "description": "Mobile figure wrapper for the hero image."
167
192
  },
168
193
  {
169
194
  "name": "image_content",
170
- "description": "image content"
195
+ "description": "Desktop (or wide) image column surface."
171
196
  },
172
197
  {
173
198
  "name": "text_content",
174
- "description": "text content"
199
+ "description": "Desktop text column wrapper (title, body, CTA)."
175
200
  },
176
201
  {
177
202
  "name": "link_button",
178
- "description": "link button"
203
+ "description": "Desktop CTA button (`button is-primary`)."
179
204
  },
180
205
  {
181
206
  "name": "title",
182
- "description": "title"
207
+ "description": "Desktop section headline rendered as an `h1` above the body copy."
183
208
  },
184
209
  {
185
210
  "name": "text_body",
186
- "description": "text body"
211
+ "description": "Desktop body paragraph."
187
212
  }
188
213
  ]
189
214
  },
@@ -198,7 +223,7 @@
198
223
  "src": "https://upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/446px-Commons-logo.svg.png"
199
224
  },
200
225
  "text": {
201
- "title": "PragraphWithImage Regular",
226
+ "title": "ParagraphWithImage regular",
202
227
  "body": "lore ipsum dolor sit ame1t, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
203
228
  "link": {
204
229
  "label": "linkato"
@@ -279,5 +304,5 @@
279
304
  "size": {},
280
305
  "iifePath": "main.iife.js",
281
306
  "repoName": "@htmlbricks/hb-site-paragraph-with-image",
282
- "version": "0.71.34"
307
+ "version": "0.71.36"
283
308
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htmlbricks/hb-site-paragraph-with-image",
3
- "version": "0.71.34",
3
+ "version": "0.71.36",
4
4
  "contributors": [],
5
5
  "description": "Marketing block pairing an image (`img`) with rich text (`text`: title, body, optional link). Use `text_side` (`left` / `right`) and `half_space` for layout; responsive parts cover mobile and desktop. CTA is a Bulma `button is-primary` (optional inline colors on the link). Fires `elClick` when the link area is used.",
6
6
  "licenses": [