@htmlbricks/hb-sidenav-button 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.
- package/README.md +111 -17
- package/manifest.json +34 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,36 +1,130 @@
|
|
|
1
|
-
|
|
1
|
+
# hb-sidenav-button
|
|
2
2
|
|
|
3
|
-
**Category:** layout
|
|
4
|
-
**Tags:** layout, navigation
|
|
3
|
+
**Category:** layout · **Tags:** layout, navigation
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
## Overview
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
`hb-sidenav-button` is a single **sidebar navigation row**: a full-width ghost Bulma button inside a list item (`<li>`). It is meant to be used in stacked menus (for example together with `hb-sidebar-cards-navigator`). Clicking the row dispatches a **`pageChange`** custom event whose detail is the link’s **`key`**, so the host can switch views or routes.
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
The row can show:
|
|
10
|
+
|
|
11
|
+
- a **Bootstrap Icons** glyph (when `bootstrapIcon` is set),
|
|
12
|
+
- a **Bulma tag** badge (when `badge` is set),
|
|
13
|
+
- or **control-style visuals** for `type` **`checkbox`**, **`radio`**, or **`switch`** (when there is no `badge`, using icon state from `value`).
|
|
14
|
+
|
|
15
|
+
Optional **`selected`** sets `aria-current="page"` and Bulma “selected” styling for the active row.
|
|
16
|
+
|
|
17
|
+
## Custom element
|
|
11
18
|
|
|
12
19
|
`hb-sidenav-button`
|
|
13
20
|
|
|
14
|
-
|
|
21
|
+
## Props / attributes
|
|
22
|
+
|
|
23
|
+
Web component **attributes are strings**. Pass complex data as a **JSON string** on `navlink`.
|
|
24
|
+
|
|
25
|
+
| Attribute | Required | Description |
|
|
26
|
+
|-----------|----------|-------------|
|
|
27
|
+
| `navlink` | yes | JSON string describing one navigation item (see **Navlink object** below). If the runtime binding delivers a string, the component attempts `JSON.parse` on it. |
|
|
28
|
+
|
|
29
|
+
The TypeScript **`Component`** type in `types/webcomponent.type.d.ts` also lists optional **`id`** and **`style`**. Rendering is driven by **`navlink`**; you can still set a normal HTML **`id`** on `<hb-sidenav-button>` in the document when useful.
|
|
15
30
|
|
|
16
|
-
|
|
17
|
-
- `navlink` (required): JSON string — `INavLink` (`key`, `text`, optional `bootstrapIcon`, `badge`, `value`, `type`, `selected`).
|
|
31
|
+
### Navlink object (`INavLink`)
|
|
18
32
|
|
|
19
|
-
|
|
33
|
+
All consumer-facing keys use the shape below (logical names; in JSON use these exact property names).
|
|
34
|
+
|
|
35
|
+
| Property | Type | Description |
|
|
36
|
+
|----------|------|-------------|
|
|
37
|
+
| `key` | string | Identifier for this row; sent as `pageChange` detail `page`. |
|
|
38
|
+
| `text` | string | Primary label (main text in the row). |
|
|
39
|
+
| `bootstrapIcon` | string (optional) | Bootstrap Icons name **without** the `bi-` prefix (for example `"house-door"` → `bi-house-door`). Shown when the row is not using the checkbox/radio-only layout, or as the leading icon for a generic row. |
|
|
40
|
+
| `subtext` | string (optional) | Present in typings for shared nav models; **this component does not render `subtext`**. |
|
|
41
|
+
| `badge` | object (optional) | `{ "text": string, "class"?: string, "classcolor"?: string }`. Renders a Bulma `tag` on the right. Bulma modifier classes can be passed via `class` (default-like behavior in markup uses `is-rounded`) and `classcolor` (defaults toward `is-light`). When `badge` is set, **`type`-based switch UI is not shown** (badge takes precedence for the trailing area). |
|
|
42
|
+
| `value` | string, number, or boolean (optional) | Drives **checkbox** / **radio** / **switch** visuals (`true` / filled vs off). |
|
|
43
|
+
| `selected` | boolean (optional) | When true, the row is styled as current and exposes `aria-current="page"`. |
|
|
44
|
+
| `type` | string (optional) | One of `"switch"`, `"range"`, `"radio"`, `"checkbox"`, `"button"`. **Rendered behavior:** `checkbox` and `radio` show check/circle icons when there is **no** `badge`; `switch` shows a toggle icon when there is **no** `badge`; `"button"` and `"range"` do not add extra control icons beyond `bootstrapIcon` / text. |
|
|
45
|
+
|
|
46
|
+
## Events
|
|
47
|
+
|
|
48
|
+
| Event | Detail | When |
|
|
49
|
+
|-------|--------|------|
|
|
50
|
+
| `pageChange` | `{ page: string }` | Every click on the row button. `page` is the navlink **`key`**. |
|
|
51
|
+
|
|
52
|
+
Listen in the DOM:
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
el.addEventListener("pageChange", (e) => {
|
|
56
|
+
console.log(e.detail.page);
|
|
57
|
+
});
|
|
58
|
+
```
|
|
20
59
|
|
|
21
|
-
|
|
60
|
+
## Styling
|
|
22
61
|
|
|
23
|
-
|
|
62
|
+
Styles use **Bulma** inside the shadow root. Theme the host page with public **`--bulma-*`** variables (see [Bulma CSS variables](https://bulma.io/documentation/features/css-variables/)). Variables referenced by this component are documented in `extra/docs.ts`; the main ones are:
|
|
24
63
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
64
|
+
| Variable | Role |
|
|
65
|
+
|----------|------|
|
|
66
|
+
| `--bulma-link` | Left accent stripe and mixes for the selected (`aria-current`) row. |
|
|
67
|
+
| `--bulma-link-text` | Text color on the selected row background mix. |
|
|
68
|
+
| `--bulma-scheme-main-bis` | Hover wash for rows. |
|
|
69
|
+
| `--bulma-radius` | Corner rounding for each row. |
|
|
70
|
+
| `--bulma-text-weak` | Muted tone where weak contrast is used (for example badge-related styling). |
|
|
29
71
|
|
|
30
|
-
|
|
72
|
+
**CSS part:** `li` — the outer list item wrapper (`::part(li)` from the light DOM).
|
|
73
|
+
|
|
74
|
+
**Icons:** rows use **Bootstrap Icons** (`bi-*`). The component loads the icon font (see `component.wc.svelte` / styles). For predictable versions in production pages, prefer pinning a known **Bootstrap Icons** URL instead of relying only on `@latest` where you control the document.
|
|
75
|
+
|
|
76
|
+
## Slots
|
|
77
|
+
|
|
78
|
+
None (`htmlSlots` is empty in `extra/docs.ts`).
|
|
79
|
+
|
|
80
|
+
## Integration notes
|
|
81
|
+
|
|
82
|
+
- In Storybook, **`nav_type`** is a control helper for picking a `type` value; at runtime the field lives on **`navlink.type`** inside the JSON `navlink` string.
|
|
83
|
+
- Wrap multiple `hb-sidenav-button` elements in a `<ul class="...">` in the light DOM if you need a semantic list; each instance renders one `<li part="li">`.
|
|
84
|
+
|
|
85
|
+
## HTML examples
|
|
86
|
+
|
|
87
|
+
**Plain icon + label**
|
|
31
88
|
|
|
32
89
|
```html
|
|
33
90
|
<hb-sidenav-button
|
|
34
91
|
navlink='{"text":"Home","key":"home","bootstrapIcon":"house-door"}'
|
|
35
92
|
></hb-sidenav-button>
|
|
36
93
|
```
|
|
94
|
+
|
|
95
|
+
**Selected row**
|
|
96
|
+
|
|
97
|
+
```html
|
|
98
|
+
<hb-sidenav-button
|
|
99
|
+
navlink='{"text":"Home","key":"home","bootstrapIcon":"house-door","selected":true}'
|
|
100
|
+
></hb-sidenav-button>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Badge**
|
|
104
|
+
|
|
105
|
+
```html
|
|
106
|
+
<hb-sidenav-button
|
|
107
|
+
navlink='{"text":"Messages","key":"messages","bootstrapIcon":"envelope","badge":{"text":"3","classcolor":"is-danger"}}'
|
|
108
|
+
></hb-sidenav-button>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Switch (no badge)**
|
|
112
|
+
|
|
113
|
+
```html
|
|
114
|
+
<hb-sidenav-button
|
|
115
|
+
navlink='{"text":"Notifications","key":"notifications","bootstrapIcon":"bell","type":"switch","value":true}'
|
|
116
|
+
></hb-sidenav-button>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Checkbox / radio (no badge)**
|
|
120
|
+
|
|
121
|
+
```html
|
|
122
|
+
<hb-sidenav-button
|
|
123
|
+
navlink='{"text":"Option A","key":"a","type":"checkbox","value":true}'
|
|
124
|
+
></hb-sidenav-button>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Package metadata
|
|
128
|
+
|
|
129
|
+
- **Name:** `hb-sidenav-button` / `@htmlbricks/hb-sidenav-button`
|
|
130
|
+
- **License:** Apache-2.0 (see package `LICENSE.md` where distributed)
|
package/manifest.json
CHANGED
|
@@ -141,11 +141,42 @@
|
|
|
141
141
|
}
|
|
142
142
|
},
|
|
143
143
|
"styleSetup": {
|
|
144
|
-
"vars": [
|
|
144
|
+
"vars": [
|
|
145
|
+
{
|
|
146
|
+
"name": "--bulma-link",
|
|
147
|
+
"valueType": "color",
|
|
148
|
+
"defaultValue": "#485fc7",
|
|
149
|
+
"description": "Ghost button hover and `aria-current` row accent stripe."
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
"name": "--bulma-link-text",
|
|
153
|
+
"valueType": "color",
|
|
154
|
+
"defaultValue": "#ffffff",
|
|
155
|
+
"description": "Text on the selected (`aria-current`) row background mix."
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"name": "--bulma-scheme-main-bis",
|
|
159
|
+
"valueType": "color",
|
|
160
|
+
"defaultValue": "#f5f5f5",
|
|
161
|
+
"description": "Hover wash for sidenav rows."
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"name": "--bulma-radius",
|
|
165
|
+
"valueType": "number",
|
|
166
|
+
"defaultValue": "0.375rem",
|
|
167
|
+
"description": "Row pill rounding for each list item."
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"name": "--bulma-text-weak",
|
|
171
|
+
"valueType": "color",
|
|
172
|
+
"defaultValue": "#7a7a7a",
|
|
173
|
+
"description": "Muted badge text when tags use weak contrast."
|
|
174
|
+
}
|
|
175
|
+
],
|
|
145
176
|
"parts": [
|
|
146
177
|
{
|
|
147
178
|
"name": "li",
|
|
148
|
-
"description": "list
|
|
179
|
+
"description": "Outer list item wrapper for the row."
|
|
149
180
|
}
|
|
150
181
|
]
|
|
151
182
|
},
|
|
@@ -238,5 +269,5 @@
|
|
|
238
269
|
"size": {},
|
|
239
270
|
"iifePath": "main.iife.js",
|
|
240
271
|
"repoName": "@htmlbricks/hb-sidenav-button",
|
|
241
|
-
"version": "0.71.
|
|
272
|
+
"version": "0.71.36"
|
|
242
273
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htmlbricks/hb-sidenav-button",
|
|
3
|
-
"version": "0.71.
|
|
3
|
+
"version": "0.71.36",
|
|
4
4
|
"contributors": [],
|
|
5
5
|
"description": "Compact sidebar row as a nav button: optional Bootstrap Icons (bi-*) icon, Bulma tag badge, or visual types (switch, checkbox, radio) from navlink JSON; dispatches pageChange with the row key on click. Used by sidebar-cards-navigator and similar stacked menus.",
|
|
6
6
|
"licenses": [
|