@htmlbricks/hb-site-contacts-row 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 +132 -20
  2. package/manifest.json +45 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,36 +1,133 @@
1
- ## `hb-site-contacts-row` site-contacts-row
1
+ # `hb-site-contacts-row` (site-contacts-row)
2
2
 
3
3
  **Category:** content
4
- **Tags:** content, contact
4
+ **Tags:** content, contact
5
+ **Package:** `@htmlbricks/hb-site-contacts-row`
5
6
 
6
- ### What it does
7
+ ## Overview
7
8
 
8
- Contact strip for addresses (with optional `latLng`), phones, emails, websites, and `availability` (times, appointment flag). `model` `big` / `small` or omit for auto layouts that adapt to which fields you pass.
9
+ `hb-site-contacts-row` is a contact strip that groups **addresses**, **phones**, **emails**, **websites**, and **availability** (opening hours plus an optional appointment note) into a responsive Bulma layout. Each group can have its own **title**, **Bootstrap Icons** glyph, and list content.
9
10
 
10
- ### Custom element
11
+ The component registers the custom element **`hb-site-contacts-row`**. It runs inside a **shadow root** with Bulma layout and typography, and loads the **Bootstrap Icons** font from jsDelivr in `<svelte:head>`.
11
12
 
12
- `hb-site-contacts-row`
13
+ ## Layout: `model`
13
14
 
14
- ### Attributes (snake_case; use string values in HTML)
15
+ - **`small`** — Compact blocks: addresses use an inline “icon + content” row; phones, emails, websites, and availability use column halves on tablet and full width on mobile.
16
+ - **`big`** — Larger “card-style” columns (`col_big`) with a prominent icon row, title, and list.
15
17
 
16
- - `id` (optional): string.
17
- - `style` (optional): string (inline style).
18
- - `availability` (optional): JSON string — `{ icon?, times: string[], title?, appointment? }`.
19
- - `addresses` (optional): JSON string — `{ icon?, addresses: Address[], title? }` (`Address`: `address`, optional `latLng`, `link`, `name`).
20
- - `phones` (optional): JSON string — `{ icon?, phones: { name?, number }[], title? }`.
21
- - `emails` (optional): JSON string — `{ icon?, emails: { label?, address, name? }[], title? }`.
22
- - `websites` (optional): JSON string — `{ icon?, websites: { label?, url, name? }[], title? }`.
23
- - `model` (optional): `"big"` | `"small"`.
18
+ **Default:** If you omit `model`, the implementation defaults to **`small`**.
24
19
 
25
- ### Events
20
+ **Invalid values:** Any `model` other than `small` or `big` renders the fallback text `wrong model provided` plus the value you passed (still inside the shadow tree).
26
21
 
27
- - `event`: `{ test: boolean }` (integration hook per typings).
22
+ > The metadata description mentions “auto” layouts; the current Svelte implementation only supports **`big`** and **`small`**. Omitting `model` is the same as **`small`**, not a separate adaptive mode.
28
23
 
29
- ### Usage notes
24
+ ## Attributes (HTML)
30
25
 
31
- - No named slots in `extra/docs.ts`. Pass complex blocks as JSON attributes or bind after custom element upgrade.
26
+ Use **snake_case** attribute names. From plain HTML, pass **objects as JSON strings** (single-quoted in HTML, escaped quotes inside JSON).
32
27
 
33
- ### Minimal HTML example
28
+ | Attribute | Required | Description |
29
+ | --- | --- | --- |
30
+ | `id` | No | Optional host element id (forwarded as a normal attribute / prop). |
31
+ | `style` | No | Present in the TypeScript `Component` shape; **not** wired into the template in the current implementation. |
32
+ | `model` | No | `"small"` \| `"big"`. Defaults to `"small"`. |
33
+ | `addresses` | No | JSON: `{ "icon"?: string, "title"?: string, "addresses": Address[] }`. |
34
+ | `phones` | No | JSON: `{ "icon"?: string, "title"?: string, "phones": Phone[] }`. |
35
+ | `emails` | No | JSON: `{ "icon"?: string, "title"?: string, "emails": Email[] }`. |
36
+ | `websites` | No | JSON: `{ "icon"?: string, "title"?: string, "websites": Website[] }`. |
37
+ | `availability` | No | JSON: `{ "icon"?: string, "title"?: string, "times": string[], "appointment"?: boolean }`. |
38
+
39
+ ### JSON shapes (TypeScript reference)
40
+
41
+ ```ts
42
+ type Address = {
43
+ address: string;
44
+ latLng?: number[]; // [lat, lng] → Google Maps link when no `link`
45
+ link?: string; // external URL; takes precedence over `latLng`
46
+ name?: string; // shown as a prefix in `big` mode only
47
+ };
48
+
49
+ type Phone = {
50
+ number: string;
51
+ name?: string; // prefix in `big` mode only
52
+ };
53
+
54
+ type Email = {
55
+ address: string;
56
+ label?: string; // link text in `small`; in `big`, link text vs address
57
+ name?: string; // prefix in `big` mode only
58
+ };
59
+
60
+ type Website = {
61
+ url: string;
62
+ label?: string;
63
+ name?: string; // prefix in `big` mode only
64
+ };
65
+ ```
66
+
67
+ **Parsing:** When any of `addresses`, `phones`, `emails`, `websites`, or `availability` arrives as a **string**, the component attempts `JSON.parse` inside an effect. Malformed JSON is logged to the console and leaves the previous value behavior up to the runtime.
68
+
69
+ ### Icons
70
+
71
+ Each block accepts an optional `icon` string: the **Bootstrap Icons** short name **without** the `bi-` prefix (the markup adds `class="bi bi-{icon}"`). Defaults if omitted:
72
+
73
+ | Block | Default icon |
74
+ | --- | --- |
75
+ | addresses | `geo-alt` |
76
+ | phones | `telephone` |
77
+ | emails | `envelope` |
78
+ | websites | `globe` |
79
+ | availability | `clock` |
80
+
81
+ ### Addresses: links
82
+
83
+ For each address with non-empty `address`:
84
+
85
+ 1. If `link` is set → `<a href="{link}" target="_blank">`.
86
+ 2. Else if `latLng` has length → Google Maps URL `https://www.google.com/maps/@{lat},{lng},15z` in a new tab.
87
+ 3. Else → plain text.
88
+
89
+ ### Emails and websites
90
+
91
+ - **Emails:** `mailto:` links. In **`small`** mode, the list shows `label` as the link text when set, otherwise the address. In **`big`** mode, optional `name:` prefix, then a single mailto link using `label` or the address as visible text.
92
+ - **Websites:** External `<a href="{url}">` with `label` or URL as text, with the same `small` / `big` differences as emails for prefixes.
93
+
94
+ ### Availability
95
+
96
+ - Renders when `availability.times` is a non-empty array; each string is one list item.
97
+ - When `availability.appointment` is truthy, an extra line is shown **in Italian** (implementation detail): `*riceve per appuntamento` in `small` mode and `riceve per appuntamento` in `big` mode.
98
+
99
+ ## Events
100
+
101
+ `types/webcomponent.type.d.ts` declares an `Events` map with a generic `event` payload `{ test: boolean }`. The current `component.wc.svelte` **does not call** the local `dispatch` helper, so **no custom events are emitted** from this revision of the component. Keep the typings in mind if you extend the implementation.
102
+
103
+ ## Styling
104
+
105
+ The component forwards **`styles/bulma.scss`** (Bulma 1.x CSS variables on `:host`) and **`styles/webcomponent.scss`**.
106
+
107
+ ### CSS custom properties (`:host`)
108
+
109
+ | Variable | Role |
110
+ | --- | --- |
111
+ | `--bulma-text` | Body copy in lists and labels. |
112
+ | `--bulma-link` | Linked addresses, phones, emails, and websites. |
113
+ | `--bulma-block-spacing` | Vertical rhythm between stacked blocks and icon sizing. |
114
+ | `--bulma-column-gap` | Inline gaps in rows and list spacing. |
115
+ | `--bulma-size-small` | Appointment line and small meta text. |
116
+ | `--bulma-weight-bold` | Section titles and appointment emphasis. |
117
+
118
+ See Bulma’s [CSS variables](https://bulma.io/documentation/features/css-variables/) documentation for value types and inheritance.
119
+
120
+ ### CSS parts
121
+
122
+ | Part | Description |
123
+ | --- | --- |
124
+ | `container` | Root `columns is-multiline` wrapper (`part="container"`). Use for layout, max-width, or background overrides. |
125
+
126
+ ### Slots
127
+
128
+ None. All content is supplied via JSON attributes.
129
+
130
+ ## Minimal example
34
131
 
35
132
  ```html
36
133
  <hb-site-contacts-row
@@ -38,3 +135,18 @@ Contact strip for addresses (with optional `latLng`), phones, emails, websites,
38
135
  emails='{"emails":[{"label":"Info","address":"info@example.com","name":"main"}]}'
39
136
  ></hb-site-contacts-row>
40
137
  ```
138
+
139
+ ### Example with multiple groups
140
+
141
+ ```html
142
+ <hb-site-contacts-row
143
+ model="big"
144
+ addresses='{"title":"Locations","addresses":[{"address":"1 Example Rd","latLng":[51.5,-0.12],"name":"HQ"}]}'
145
+ phones='{"phones":[{"name":"Desk","number":"+1 555 0100"}]}'
146
+ availability='{"times":["Mon–Fri 9–18"],"appointment":true}'
147
+ ></hb-site-contacts-row>
148
+ ```
149
+
150
+ ## Authoring types
151
+
152
+ For Svelte or TypeScript consumers, see `types/webcomponent.type.d.ts` for the full `Component`, `Address`, `Phone`, `Email`, `Website`, and `Events` definitions.
package/manifest.json CHANGED
@@ -270,8 +270,50 @@
270
270
  }
271
271
  },
272
272
  "styleSetup": {
273
- "vars": [],
274
- "parts": []
273
+ "vars": [
274
+ {
275
+ "name": "--bulma-text",
276
+ "valueType": "color",
277
+ "defaultValue": "",
278
+ "description": "Default body copy in list blocks and labels."
279
+ },
280
+ {
281
+ "name": "--bulma-link",
282
+ "valueType": "color",
283
+ "defaultValue": "",
284
+ "description": "Linked addresses, phones, emails, and websites."
285
+ },
286
+ {
287
+ "name": "--bulma-block-spacing",
288
+ "valueType": "number",
289
+ "defaultValue": "",
290
+ "description": "Vertical rhythm between stacked blocks and icon sizing."
291
+ },
292
+ {
293
+ "name": "--bulma-column-gap",
294
+ "valueType": "number",
295
+ "defaultValue": "",
296
+ "description": "Inline gaps in inline rows and list item spacing."
297
+ },
298
+ {
299
+ "name": "--bulma-size-small",
300
+ "valueType": "number",
301
+ "defaultValue": "",
302
+ "description": "Appointment line and small meta text."
303
+ },
304
+ {
305
+ "name": "--bulma-weight-bold",
306
+ "valueType": "number",
307
+ "defaultValue": "",
308
+ "description": "Section titles and appointment emphasis."
309
+ }
310
+ ],
311
+ "parts": [
312
+ {
313
+ "name": "container",
314
+ "description": "Root `columns is-multiline` wrapper; target for layout, max-width, or background overrides."
315
+ }
316
+ ]
275
317
  },
276
318
  "contributors": [],
277
319
  "htmlSlots": [],
@@ -692,5 +734,5 @@
692
734
  "size": {},
693
735
  "iifePath": "main.iife.js",
694
736
  "repoName": "@htmlbricks/hb-site-contacts-row",
695
- "version": "0.71.35"
737
+ "version": "0.71.36"
696
738
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htmlbricks/hb-site-contacts-row",
3
- "version": "0.71.35",
3
+ "version": "0.71.36",
4
4
  "contributors": [],
5
5
  "description": "Contact strip for addresses (with optional `latLng`), phones, emails, websites, and `availability` (times, appointment flag). `model` `big` / `small` or omit for auto layouts that adapt to which fields you pass.",
6
6
  "licenses": [