@htmlbricks/hb-sidenav-link 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.
- package/README.md +143 -19
- package/manifest.json +32 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,35 +1,124 @@
|
|
|
1
|
-
|
|
1
|
+
# hb-sidenav-link
|
|
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-link` is a single sidebar navigation row for hierarchical menus. It renders a Bootstrap Icons label row, an optional Bulma-style tag badge (outlined pill: transparent fill, border and text from the tag color), and either:
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
- a **leaf** link that dispatches `pageChange` when the user activates it, or
|
|
10
|
+
- a **parent** row with `subLinks` that expands to show nested links.
|
|
11
|
+
|
|
12
|
+
Active styling applies when the current page key (`navpage`) matches a link key, or when the `selected` flag is enabled. The component is intended for use inside `hb-sidebar-desktop` lists (and shares the `INavLink` shape with related layout components).
|
|
13
|
+
|
|
14
|
+
Bootstrap Icons are loaded from the component (`bootstrap-icons` CSS on jsDelivr). Icon names are the `bi-*` suffix only (for example `house-door` → `bi-house-door`).
|
|
15
|
+
|
|
16
|
+
## Custom element
|
|
11
17
|
|
|
12
18
|
`hb-sidenav-link`
|
|
13
19
|
|
|
14
|
-
|
|
20
|
+
## Props (TypeScript `Component`)
|
|
21
|
+
|
|
22
|
+
| Property | Type | Required | Notes |
|
|
23
|
+
|------------|-------------|----------|--------|
|
|
24
|
+
| `navlink` | `INavLink` | yes | From HTML, pass a **JSON string** (see below). |
|
|
25
|
+
| `navpage` | `string` | no | Current page key; drives active row and expanded groups. |
|
|
26
|
+
| `selected` | `boolean` | no | When true, forces the “current page” appearance. From HTML use string encodings (see [Attributes](#attributes-snake_case-string-values-in-html)). |
|
|
27
|
+
| `id` | `string` | no | Optional identifier (typed on the component API). |
|
|
28
|
+
| `style` | `string` | no | Optional inline style (typed on the component API). |
|
|
29
|
+
|
|
30
|
+
## `INavLink` shape
|
|
31
|
+
|
|
32
|
+
Used for the root `navlink` and, recursively, for each entry in `subLinks`.
|
|
33
|
+
|
|
34
|
+
| Field | Type | Required | Description |
|
|
35
|
+
|------------|----------------|----------|-------------|
|
|
36
|
+
| `key` | `string` | yes | Stable id for the link; sent as `page` in `pageChange` for leaf clicks. |
|
|
37
|
+
| `label` | `string` | yes | Visible label. |
|
|
38
|
+
| `icon` | `string` | no | Bootstrap Icons name without the `bi-` prefix. |
|
|
39
|
+
| `group` | `string` | no | Present in the shared nav typings for interoperability. |
|
|
40
|
+
| `badge` | object | no | `text` (string), optional Bulma modifier classes `class` and `classcolor` (for example `is-rounded`, `is-light`). |
|
|
41
|
+
| `subLinks` | `INavLink[]` | no | If non-empty, the row becomes an expandable group instead of a single leaf. |
|
|
42
|
+
| `active` | `boolean` | no | Present on the shared type; not read by this component’s markup. |
|
|
43
|
+
| `open` | `boolean` | no | When `navlink` is provided as a JSON string, `open: true` initializes the group as expanded. |
|
|
44
|
+
|
|
45
|
+
### Badges
|
|
46
|
+
|
|
47
|
+
`badge` supports:
|
|
48
|
+
|
|
49
|
+
- `text` — badge label.
|
|
50
|
+
- `class` — optional Bulma tag class (defaults to `is-rounded` in the template).
|
|
51
|
+
- `classcolor` — optional color modifier (defaults to `is-light`).
|
|
52
|
+
|
|
53
|
+
## Attributes (snake_case; string values in HTML)
|
|
54
|
+
|
|
55
|
+
Reflects the web component contract: attributes are strings.
|
|
56
|
+
|
|
57
|
+
| Attribute | Required | Description |
|
|
58
|
+
|------------|----------|-------------|
|
|
59
|
+
| `navlink` | yes | JSON string representing `INavLink`. |
|
|
60
|
+
| `navpage` | no | Current page key string. |
|
|
61
|
+
| `selected` | no | Boolean-as-string: `yes` / `no` per project conventions. The implementation also treats the literal strings `true` / `yes` as true, **and treats an empty string as true**; any other value becomes false unless already boolean true inside the app. Prefer explicit `yes` or `no` from HTML. |
|
|
62
|
+
| `id` | no | String. |
|
|
63
|
+
| `style` | no | String. |
|
|
64
|
+
|
|
65
|
+
If `navlink` arrives as a string, the component parses it as JSON and applies `open` from the parsed object when `open === true`.
|
|
66
|
+
|
|
67
|
+
## Events
|
|
68
|
+
|
|
69
|
+
| Event | `detail` | When it fires |
|
|
70
|
+
|-------------|------------------------|----------------|
|
|
71
|
+
| `pageChange` | `{ page: string }` | User activates a **non-active** leaf: either the root row (no `subLinks`) or a sub-link whose `key` does not match `navpage` and is not forced selected. **Active** rows (matching `navpage` or `selected`) are static for accessibility (`aria-current="page"`) and do **not** dispatch `pageChange` on click. |
|
|
72
|
+
|
|
73
|
+
Listen in plain DOM:
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
document.querySelector('hb-sidenav-link').addEventListener('pageChange', (e) => {
|
|
77
|
+
console.log(e.detail.page);
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Behavior
|
|
82
|
+
|
|
83
|
+
### Leaf row (no `subLinks`)
|
|
84
|
+
|
|
85
|
+
- If `navlink.key === navpage` **or** `selected` is true: one full-width “current” button (link styling), no click navigation event.
|
|
86
|
+
- Otherwise: ghost button; click dispatches `pageChange` with `detail.page === navlink.key`.
|
|
87
|
+
|
|
88
|
+
### Parent row (non-empty `subLinks`)
|
|
89
|
+
|
|
90
|
+
- The parent row is a control that toggles expand/collapse and shows **▼** when open or when any child `key` equals `navpage`, otherwise **►**.
|
|
91
|
+
- The nested list is shown when the group is open **or** when some child has `key === navpage`.
|
|
92
|
+
- Each child follows the same active vs ghost rules as a leaf; inactive children dispatch `pageChange` with `detail.page ===` that child’s `key`.
|
|
93
|
+
|
|
94
|
+
### Layout
|
|
95
|
+
|
|
96
|
+
Labels use a flexible middle column; a fixed-width trail column (`--hb-sidenav-trail-width`) keeps titles aligned when some rows omit a badge or use the expand chevron. Long badge text is truncated with an ellipsis in the component styles.
|
|
15
97
|
|
|
16
|
-
|
|
17
|
-
- `navlink` (required): JSON string — `INavLink` (`label`, `key`, optional `icon`, `group`, `badge`, `subLinks`, `active`, `open`).
|
|
18
|
-
- `navpage` (optional): string — current app page key for active styling.
|
|
19
|
-
- `selected` (optional): boolean string — force selected appearance.
|
|
98
|
+
## Styling (Bulma and component variables)
|
|
20
99
|
|
|
21
|
-
|
|
100
|
+
Buttons and tags live in the **shadow root**. Theme with public **`--bulma-*`** variables on `body`, `:root`, or an ancestor; see [Bulma CSS variables](https://bulma.io/documentation/features/css-variables/). Additional tokens are listed in `extra/docs.ts`.
|
|
22
101
|
|
|
23
|
-
|
|
102
|
+
| CSS custom property | Default (from docs) | Purpose |
|
|
103
|
+
|--------------------|---------------------|---------|
|
|
104
|
+
| `--bulma-link` | `#485fc7` | Active row stripe, chevrons, and interactive accents. |
|
|
105
|
+
| `--bulma-link-text` | `#ffffff` | Text color on the active row background mix. |
|
|
106
|
+
| `--bulma-text` | `#363636` | Default label color for inactive rows. |
|
|
107
|
+
| `--bulma-scheme-main` | `#ffffff` | Row surface behind ghost buttons. |
|
|
108
|
+
| `--bulma-radius` | `0.375rem` | Row rounding for list items. |
|
|
109
|
+
| `--hb-sidenav-trail-width` | `3.5rem` | Width of the right column (badges / expand chevron); keeps labels aligned when some rows omit a badge. |
|
|
24
110
|
|
|
25
|
-
###
|
|
111
|
+
### CSS parts
|
|
26
112
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
- Export type `INavLink` is shared with `hb-offcanvas` / `hb-sidebar-desktop` `navlinks` arrays.
|
|
113
|
+
| Part | Description |
|
|
114
|
+
|------|-------------|
|
|
115
|
+
| `li` | Bulma menu list row (`li`) wrapping the ghost or link button, label column, badge or chevron trail, and nested sub-links. |
|
|
31
116
|
|
|
32
|
-
|
|
117
|
+
**Slots:** none (`htmlSlots` is empty).
|
|
118
|
+
|
|
119
|
+
## Examples
|
|
120
|
+
|
|
121
|
+
### Simple leaf
|
|
33
122
|
|
|
34
123
|
```html
|
|
35
124
|
<hb-sidenav-link
|
|
@@ -37,3 +126,38 @@ Sidebar nav item: Bootstrap Icons (`bi-*`), label, optional Bulma `tag` badge (`
|
|
|
37
126
|
navlink='{"label":"Home","key":"home","icon":"house-door"}'
|
|
38
127
|
></hb-sidenav-link>
|
|
39
128
|
```
|
|
129
|
+
|
|
130
|
+
### Leaf with badge
|
|
131
|
+
|
|
132
|
+
```html
|
|
133
|
+
<hb-sidenav-link
|
|
134
|
+
navlink='{"label":"Home","key":"home","icon":"house-door","badge":{"text":"3","classcolor":"is-danger"}}'
|
|
135
|
+
></hb-sidenav-link>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Expandable group with sub-links
|
|
139
|
+
|
|
140
|
+
```html
|
|
141
|
+
<hb-sidenav-link
|
|
142
|
+
navpage="dash"
|
|
143
|
+
navlink='{"label":"Workspace","key":"workspace","icon":"folder2-open","subLinks":[{"label":"Dashboard","key":"dash","icon":"speedometer2"},{"label":"Projects","key":"projects","icon":"kanban"}]}'
|
|
144
|
+
></hb-sidenav-link>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Force selected appearance
|
|
148
|
+
|
|
149
|
+
```html
|
|
150
|
+
<hb-sidenav-link
|
|
151
|
+
selected="yes"
|
|
152
|
+
navlink='{"label":"Home","key":"home","icon":"house-door"}'
|
|
153
|
+
></hb-sidenav-link>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Related types
|
|
157
|
+
|
|
158
|
+
`INavLink` matches the structure used by **`hb-offcanvas`** and **`hb-sidebar-desktop`** for `navlinks` arrays, so the same serialized objects can be reused across layout components.
|
|
159
|
+
|
|
160
|
+
## Package metadata
|
|
161
|
+
|
|
162
|
+
- **npm:** `@htmlbricks/hb-sidenav-link`
|
|
163
|
+
- **License:** Apache-2.0 (see package `LICENSE.md` in distribution)
|
package/manifest.json
CHANGED
|
@@ -133,6 +133,36 @@
|
|
|
133
133
|
},
|
|
134
134
|
"styleSetup": {
|
|
135
135
|
"vars": [
|
|
136
|
+
{
|
|
137
|
+
"name": "--bulma-link",
|
|
138
|
+
"valueType": "color",
|
|
139
|
+
"defaultValue": "#485fc7",
|
|
140
|
+
"description": "Active row stripe, chevrons, and interactive accents."
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"name": "--bulma-link-text",
|
|
144
|
+
"valueType": "color",
|
|
145
|
+
"defaultValue": "#ffffff",
|
|
146
|
+
"description": "Text color on the active row background mix."
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"name": "--bulma-text",
|
|
150
|
+
"valueType": "color",
|
|
151
|
+
"defaultValue": "#363636",
|
|
152
|
+
"description": "Default label color for inactive rows."
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"name": "--bulma-scheme-main",
|
|
156
|
+
"valueType": "color",
|
|
157
|
+
"defaultValue": "#ffffff",
|
|
158
|
+
"description": "Row surface behind ghost buttons."
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"name": "--bulma-radius",
|
|
162
|
+
"valueType": "number",
|
|
163
|
+
"defaultValue": "0.375rem",
|
|
164
|
+
"description": "Row rounding for list items."
|
|
165
|
+
},
|
|
136
166
|
{
|
|
137
167
|
"name": "--hb-sidenav-trail-width",
|
|
138
168
|
"valueType": "number",
|
|
@@ -143,7 +173,7 @@
|
|
|
143
173
|
"parts": [
|
|
144
174
|
{
|
|
145
175
|
"name": "li",
|
|
146
|
-
"description": "list
|
|
176
|
+
"description": "Bulma menu list row (`li`) wrapping the ghost button, label column, badge or chevron trail, and nested sub-links."
|
|
147
177
|
}
|
|
148
178
|
]
|
|
149
179
|
},
|
|
@@ -243,5 +273,5 @@
|
|
|
243
273
|
"size": {},
|
|
244
274
|
"iifePath": "main.iife.js",
|
|
245
275
|
"repoName": "@htmlbricks/hb-sidenav-link",
|
|
246
|
-
"version": "0.71.
|
|
276
|
+
"version": "0.71.36"
|
|
247
277
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htmlbricks/hb-sidenav-link",
|
|
3
|
-
"version": "0.71.
|
|
3
|
+
"version": "0.71.36",
|
|
4
4
|
"contributors": [],
|
|
5
5
|
"description": "Sidebar nav item: Bootstrap Icons (bi-*), label, optional Bulma-style tag badge (outlined pill: transparent fill, border uses tag foreground color), and either a flat button that dispatches pageChange on click or an expandable group of subLinks with active state when navpage or selected matches. Intended for use inside sidebar-desktop lists.",
|
|
6
6
|
"licenses": [
|