@lit-material/navigation 0.0.1 → 0.1.0

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,9 +1,9 @@
1
1
  # @lit-material/navigation
2
2
 
3
- Material Design 3 navigation drawer and navigation rail web components built with
3
+ Material Design 3 navigation drawer, navigation rail, and navigation bar web components built with
4
4
  [Lit](https://lit.dev/). Part of [lit-material](https://github.com/bohdaq/lit-material).
5
5
 
6
- ![lit-material navigation drawer (standard, with a modal-drawer trigger button) and navigation rail, both showing their first destination selected](./screenshot.png)
6
+ ![lit-material navigation drawer (standard, with a modal-drawer trigger button), navigation rail, and navigation bar, all showing their first destination selected](./screenshot.png)
7
7
 
8
8
  ## Install
9
9
 
@@ -42,6 +42,18 @@ npm install @lit-material/navigation @lit-material/tokens
42
42
  Videos
43
43
  </lit-material-navigation-rail-item>
44
44
  </lit-material-navigation-rail>
45
+
46
+ <!-- Navigation bar: a row of destinations sharing a bar's width equally, typically docked to the bottom. -->
47
+ <lit-material-navigation-bar selected="0">
48
+ <lit-material-navigation-bar-item>
49
+ <svg slot="icon">…</svg>
50
+ Music
51
+ </lit-material-navigation-bar-item>
52
+ <lit-material-navigation-bar-item>
53
+ <svg slot="icon">…</svg>
54
+ Videos
55
+ </lit-material-navigation-bar-item>
56
+ </lit-material-navigation-bar>
45
57
  ```
46
58
 
47
59
  Listen for `change` to react to the selection:
@@ -109,19 +121,71 @@ Slots: default (label text, shown below the icon), `icon`, `badge` (positioned o
109
121
  top-right corner). The ripple/focus-ring are scoped to the icon's pill-shaped active indicator,
110
122
  not the whole item, matching the MD3 spec.
111
123
 
124
+ ### `lit-material-navigation-bar`
125
+
126
+ | Property | Attribute | Type | Default |
127
+ | ---------- | ---------- | -------- | ------- |
128
+ | `selected` | `selected` | `number` | `-1` |
129
+
130
+ Slots: default (`lit-material-navigation-bar-item` elements). Unlike `lit-material-navigation-rail`,
131
+ there's no `alignment` property or `fab` slot — a bottom bar is a single row of equally-shared
132
+ destinations, not a strip with room to position things along its length.
133
+
134
+ ### `lit-material-navigation-bar-item`
135
+
136
+ | Property | Attribute | Type | Default |
137
+ | ---------- | ---------- | --------- | ------- |
138
+ | `selected` | `selected` | `boolean` | `false` |
139
+ | `disabled` | `disabled` | `boolean` | `false` |
140
+ | `href` | `href` | `string` | `""` |
141
+ | `target` | `target` | `string` | `""` |
142
+
143
+ Slots: default (label text, shown below the icon), `icon`, `badge` (positioned over the icon's
144
+ top-right corner). Almost identical to `lit-material-navigation-rail-item` (same icon-pill +
145
+ label-below layout) — it shares the bar's width equally with its siblings instead of filling a
146
+ narrow vertical rail, and its indicator is 64px wide (the MD3 bar spec) rather than the rail's 56px.
147
+
112
148
  ## Behavior
113
149
 
114
- Both `lit-material-navigation-drawer` and `lit-material-navigation-rail` manage selection the
115
- same way `lit-material-tabs` does: set `selected` (an index) to reflect your current route or
116
- section, and each item's own `selected` is kept in sync automatically. Clicking an item updates
117
- `selected` and fires `change` — items don't manage selection themselves, so binding `selected` to
118
- your router state (rather than reading it back out) is the expected integration point for SPA
119
- navigation.
150
+ `lit-material-navigation-drawer`, `lit-material-navigation-rail`, and `lit-material-navigation-bar`
151
+ all manage selection the same way `lit-material-tabs` does: set `selected` (an index) to reflect
152
+ your current route or section, and each item's own `selected` is kept in sync automatically.
153
+ Clicking an item updates `selected` and fires `change` — items don't manage selection themselves,
154
+ so binding `selected` to your router state (rather than reading it back out) is the expected
155
+ integration point for SPA navigation.
120
156
 
121
157
  Fully out of scope for this first pass: responsive breakpoint switching (automatically swapping
122
158
  between rail/drawer/bottom-navigation based on window size) — that's an app-level layout decision
123
159
  this library doesn't make on your behalf.
124
160
 
161
+ ## Adaptive navigation
162
+
163
+ `lit-material-adaptive-navigation` takes one list of destinations and shows the form M3
164
+ prescribes for the window: a navigation bar under 600px, a rail from 600px, and a drawer (or a
165
+ rail, with `expanded="rail"`) from 840px. All three are rendered and CSS shows one, so it needs no
166
+ script to pick and server-rendered markup is already right.
167
+
168
+ ```html
169
+ <lit-material-adaptive-navigation id="nav" label="Sections"></lit-material-adaptive-navigation>
170
+ <script type="module">
171
+ const nav = document.querySelector("#nav");
172
+ nav.destinations = [{ label: "Overview", icon: "◎" }, { label: "Logs", icon: "≡", href: "/logs" }];
173
+ nav.selected = 0;
174
+ nav.addEventListener("change", () => console.log(nav.selected));
175
+ </script>
176
+ ```
177
+
178
+ | Property | Attribute | Type | Default |
179
+ | -------- | --------- | ---- | ------- |
180
+ | `destinations` | — | `{ label; icon?; href?; disabled? }[]` | `[]` |
181
+ | `selected` | — | `number` | `-1` |
182
+ | `expanded` | `expanded` (reflected) | `"drawer" \| "rail"` | `"drawer"` |
183
+ | `label` | `label` | `string` | `"Main"` |
184
+
185
+ The selection is shared and `change` fires whichever form was used. It's one `<nav>` landmark
186
+ named by `label`; the hidden forms are out of the accessibility tree. Place it yourself (the bar
187
+ sits where the element is).
188
+
125
189
  ## License
126
190
 
127
191
  MIT