@m3e/nav-bar 1.0.0-rc.1

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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 matraic
4
+ Contact: matraic@yahoo.com
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,175 @@
1
+ # @m3e/nav-bar
2
+
3
+ The `m3e-nav-bar` and `m3e-nav-item` components provide a navigation bar and interactive items for switching between primary destinations in your application. Designed for smaller devices, they support 3-5 interactive items, orientation, selection, and extensive theming via CSS custom properties.
4
+
5
+ > **Part of the [M3E](../../README.md) monorepo**
6
+ > This package is maintained within the unified M3E repository, which provides a suite of Material 3 web components.
7
+
8
+ ## ๐Ÿ“ฆ Installation
9
+
10
+ ```bash
11
+ npm install @m3e/nav-bar
12
+ ```
13
+
14
+ ## ๐Ÿ’ป Editor Integration
15
+
16
+ This package includes a [Custom Elements Manifest](https://github.com/webcomponents/custom-elements-manifest) to support enhanced editor tooling and developer experience.
17
+
18
+ ### Visual Studio Code
19
+
20
+ To enable autocomplete and hover documentation for `@m3e/nav-bar`, install the [Custom Elements Manifest Language Server](https://marketplace.visualstudio.com/items?itemName=pwrs.cem-language-server-vscode) extension. It will automatically detect the manifest bundled with this package and surface tag names, attributes, slots, and events in supported files.
21
+
22
+ Alternately, you can explicitly reference the `html-custom-data.json` and `css-custom-data.json` in your workspace settings:
23
+
24
+ ```json
25
+ {
26
+ "html.customData": ["./node_modules/@m3e/nav-bar/dist/html-custom-data.json"],
27
+ "css.customData": ["./node_modules/@m3e/nav-bar/dist/css-custom-data.json"]
28
+ }
29
+ ```
30
+
31
+ ## ๐Ÿš€ Browser Usage
32
+
33
+ This package uses [JavaScript Modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#module_specifiers). To use it directly in a browser without a bundler, use a module script similar to the following.
34
+
35
+ ```html
36
+ <script type="module" src="/node_modules/@m3e/nav-bar/dist/index.js"></script>
37
+ ```
38
+
39
+ In addition, you must use an [import map](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap) to include dependencies.
40
+
41
+ ```html
42
+ <script type="importmap">
43
+ {
44
+ "imports": {
45
+ "lit": "https://cdn.jsdelivr.net/npm/lit@3.3.0/+esm",
46
+ "@m3e/core": "/node_modules/@m3e/core/dist/index.js",
47
+ "@m3e/core/a11y": "/node_modules/@m3e/core/dist/a11y.js",
48
+ "@m3e/core/layout": "/node_modules/@m3e/core/dist/layout.js"
49
+ }
50
+ }
51
+ </script>
52
+ ```
53
+
54
+ > For production, use index.min.js, a11y.min.js, and layout.min.js for faster load times.
55
+
56
+ ## ๐Ÿ—‚๏ธ Elements
57
+
58
+ - `m3e-nav-bar` โ€” A horizontal bar, typically used on smaller devices, that allows a user to switch between 3-5 views.
59
+ - `m3e-nav-item` โ€” An item, placed in a navigation bar or rail, used to navigate to destinations in an application.
60
+
61
+ ## ๐Ÿงช Example
62
+
63
+ ```html
64
+ <m3e-nav-bar>
65
+ <m3e-nav-item><m3e-icon slot="icon" name="news"></m3e-icon>News</m3e-nav-item>
66
+ <m3e-nav-item><m3e-icon slot="icon" name="globe"></m3e-icon>Global</m3e-nav-item>
67
+ <m3e-nav-item><m3e-icon slot="icon" name="star"></m3e-icon>For you</m3e-nav-item>
68
+ <m3e-nav-item><m3e-icon slot="icon" name="newsstand"></m3e-icon>Trending</m3e-nav-item>
69
+ </m3e-nav-bar>
70
+ ```
71
+
72
+ ## ๐Ÿ“– API Reference
73
+
74
+ ### ๐Ÿ—‚๏ธ m3e-nav-bar
75
+
76
+ This section details the attributes, slots, events and CSS custom properties available for the `m3e-nav-bar` component.
77
+
78
+ #### โš™๏ธ Attributes
79
+
80
+ | Attribute | Type | Default | Description |
81
+ | --------- | --------------------------------------- | ----------- | ------------------------------------------------- |
82
+ | `mode` | `"compact"` \| `"expanded"` \| `"auto"` | `"compact"` | The mode in which items in the bar are presented. |
83
+
84
+ #### ๐Ÿ”” Events
85
+
86
+ | Event | Description |
87
+ | -------- | -------------------------------------------------- |
88
+ | `change` | Emitted when the selected state of an item changes |
89
+
90
+ #### ๐Ÿงฉ Slots
91
+
92
+ | Slot | Description |
93
+ | ----------- | ----------------------------- |
94
+ | _(default)_ | Renders the items of the bar. |
95
+
96
+ #### ๐ŸŽ›๏ธ CSS Custom Properties
97
+
98
+ | Property | Description |
99
+ | ----------------------------------- | --------------------------------------- |
100
+ | `--m3e-nav-bar-height` | Height of the navigation bar. |
101
+ | `--m3e-nav-bar-container-color` | Background color of the navigation bar. |
102
+ | `--m3e-nav-bar-vertical-item-width` | Minimum width of vertical nav items. |
103
+
104
+ ### ๐Ÿ—‚๏ธ m3e-nav-item
105
+
106
+ This section details the attributes, slots, events and CSS custom properties available for the `m3e-nav-item` component.
107
+
108
+ #### โš™๏ธ Attributes
109
+
110
+ | Attribute | Type | Default | Description |
111
+ | ---------------------- | ------------------------------ | ------------ | -------------------------------------------- |
112
+ | `disabled` | `boolean` | `false` | Whether the item is disabled. |
113
+ | `disabled-interactive` | `boolean` | `false` | Whether the item is disabled and interactive |
114
+ | `download` | `string` | | Download target for link button. |
115
+ | `href` | `string` | | URL for the link button. |
116
+ | `orientation` | `"vertical"` \| `"horizontal"` | `"vertical"` | The layout orientation of the item. |
117
+ | `rel` | `string` | | Relationship for the link button. |
118
+ | `selected` | `boolean` | `false` | Whether the item is selected. |
119
+ | `target` | `string` | | Target for the link button. |
120
+
121
+ #### ๐Ÿ”” Events
122
+
123
+ | Event | Description |
124
+ | -------- | ---------------------------------------- |
125
+ | `input` | Emitted when the selected state changes. |
126
+ | `change` | Emitted when the selected state changes. |
127
+
128
+ #### ๐Ÿงฉ Slots
129
+
130
+ | Slot | Description |
131
+ | --------------- | ------------------------------------------- |
132
+ | _(default)_ | Renders the label of the item. |
133
+ | `icon` | Renders the icon of the item. |
134
+ | `selected-icon` | Renders the icon when the item is selected. |
135
+
136
+ #### ๐ŸŽ›๏ธ CSS Custom Properties
137
+
138
+ | Property | Description |
139
+ | --------------------------------------------------- | -------------------------------------------- |
140
+ | `--m3e-nav-item-label-text-font-size` | Font size for the label text. |
141
+ | `--m3e-nav-item-label-text-font-weight` | Font weight for the label text. |
142
+ | `--m3e-nav-item-label-text-line-height` | Line height for the label text. |
143
+ | `--m3e-nav-item-label-text-tracking` | Letter spacing for the label text. |
144
+ | `--m3e-nav-item-shape` | Border radius of the nav item. |
145
+ | `--m3e-nav-item-icon-size` | Size of the icon. |
146
+ | `--m3e-nav-item-spacing` | Spacing between icon and label. |
147
+ | `--m3e-nav-item-inactive-label-text-color` | Color of the label text when inactive. |
148
+ | `--m3e-nav-item-inactive-icon-color` | Color of the icon when inactive. |
149
+ | `--m3e-nav-item-inactive-hover-state-layer-color` | State layer color on hover when inactive. |
150
+ | `--m3e-nav-item-inactive-focus-state-layer-color` | State layer color on focus when inactive. |
151
+ | `--m3e-nav-item-inactive-pressed-state-layer-color` | State layer color on press when inactive. |
152
+ | `--m3e-nav-item-active-label-text-color` | Color of the label text when active. |
153
+ | `--m3e-nav-item-active-icon-color` | Color of the icon when active. |
154
+ | `--m3e-nav-item-active-container-color` | Container color when active. |
155
+ | `--m3e-nav-item-active-hover-state-layer-color` | State layer color on hover when active. |
156
+ | `--m3e-nav-item-active-focus-state-layer-color` | State layer color on focus when active. |
157
+ | `--m3e-nav-item-active-pressed-state-layer-color` | State layer color on press when active. |
158
+ | `--m3e-nav-item-focus-ring-shape` | Border radius for the focus ring. |
159
+ | `--m3e-nav-item-disabled-label-text-color` | Color of the label text when disabled. |
160
+ | `--m3e-nav-item-disabled-label-text-opacity` | Opacity of the label text when disabled. |
161
+ | `--m3e-nav-item-disabled-icon-color` | Color of the icon when disabled. |
162
+ | `--m3e-nav-item-disabled-icon-opacity` | Opacity of the icon when disabled. |
163
+ | `--m3e-horizontal-nav-item-padding` | Padding for horizontal orientation. |
164
+ | `--m3e-horizontal-nav-item-active-indicator-height` | Height of the active indicator (horizontal). |
165
+ | `--m3e-vertical-nav-item-active-indicator-width` | Width of the active indicator (vertical). |
166
+ | `--m3e-vertical-nav-item-active-indicator-height` | Height of the active indicator (vertical). |
167
+ | `--m3e-vertical-nav-item-active-indicator-margin` | Margin for the active indicator (vertical). |
168
+
169
+ ## ๐Ÿค Contributing
170
+
171
+ See the root monorepo `CONTRIBUTING.md` for guidelines on contributing to this package.
172
+
173
+ ## ๐Ÿ“„ License
174
+
175
+ This package is licensed under the MIT License.
package/cem.config.mjs ADDED
@@ -0,0 +1,16 @@
1
+ import { customElementVsCodePlugin } from "custom-element-vs-code-integration";
2
+
3
+ export default {
4
+ globs: ["src/**/*.ts"],
5
+ exclude: ["src/**/*.spec.ts"],
6
+ packagejson: true,
7
+ outdir: "dist",
8
+ litelement: true,
9
+ plugins: [
10
+ customElementVsCodePlugin({
11
+ outdir: "dist",
12
+ htmlFileName: "html-custom-data.json",
13
+ cssFileName: "css-custom-data.json",
14
+ }),
15
+ ],
16
+ };
@@ -0,0 +1,65 @@
1
+ <!doctype html>
2
+ <html lang="en" style="overflow-y: auto">
3
+ <head>
4
+ <title>Navigation Bar for M3E</title>
5
+ <meta charset="utf-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <meta name="description" content="Navigation Bar for M3E" />
8
+ <base href="./" />
9
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
10
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
11
+ <link
12
+ href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&display=swap"
13
+ rel="stylesheet"
14
+ />
15
+ <link
16
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0..1,0"
17
+ rel="stylesheet"
18
+ />
19
+ <script type="importmap">
20
+ {
21
+ "imports": {
22
+ "lit": "https://cdn.jsdelivr.net/npm/lit@3.3.0/+esm",
23
+ "@m3e/core": "../../core/dist/index.min.js",
24
+ "@m3e/core/a11y": "../../core/dist/a11y.min.js",
25
+ "@m3e/core/layout": "../../core/dist/layout.min.js"
26
+ }
27
+ }
28
+ </script>
29
+ <script type="module" src="../../icon/dist/index.min.js"></script>
30
+ <script type="module" src="../../theme/dist/index.min.js"></script>
31
+ <script type="module" src="../dist/index.min.js"></script>
32
+ <style>
33
+ body {
34
+ font-family: "Roboto";
35
+ }
36
+ *:not(:defined) {
37
+ display: none;
38
+ }
39
+ </style>
40
+ </head>
41
+ <body>
42
+ <m3e-theme strong-focus>
43
+ <m3e-nav-bar onchange="console.log(this.selected)">
44
+ <m3e-nav-item><m3e-icon slot="icon" filled name="news"></m3e-icon>News</m3e-nav-item>
45
+ <m3e-nav-item disabled><m3e-icon slot="icon" name="globe"></m3e-icon>Global</m3e-nav-item>
46
+ <m3e-nav-item><m3e-icon slot="icon" name="star"></m3e-icon>For you</m3e-nav-item>
47
+ <m3e-nav-item><m3e-icon slot="icon" name="newsstand"></m3e-icon>Trending</m3e-nav-item>
48
+ </m3e-nav-bar>
49
+ <br /><br />
50
+ <m3e-nav-bar mode="expanded" onchange="console.log(this.selected)">
51
+ <m3e-nav-item><m3e-icon slot="icon" filled name="news"></m3e-icon>News</m3e-nav-item>
52
+ <m3e-nav-item disabled><m3e-icon slot="icon" name="globe"></m3e-icon>Global</m3e-nav-item>
53
+ <m3e-nav-item><m3e-icon slot="icon" name="star"></m3e-icon>For you</m3e-nav-item>
54
+ <m3e-nav-item><m3e-icon slot="icon" name="newsstand"></m3e-icon>Trending</m3e-nav-item>
55
+ </m3e-nav-bar>
56
+ <br /><br />
57
+ <m3e-nav-bar mode="auto" onchange="console.log(this.selected)">
58
+ <m3e-nav-item><m3e-icon slot="icon" filled name="news"></m3e-icon>News</m3e-nav-item>
59
+ <m3e-nav-item><m3e-icon slot="icon" name="globe"></m3e-icon>Global</m3e-nav-item>
60
+ <m3e-nav-item><m3e-icon slot="icon" name="star"></m3e-icon>For you</m3e-nav-item>
61
+ <m3e-nav-item><m3e-icon slot="icon" name="newsstand"></m3e-icon>Trending</m3e-nav-item>
62
+ </m3e-nav-bar>
63
+ </m3e-theme>
64
+ </body>
65
+ </html>
@@ -0,0 +1,162 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/microsoft/vscode-css-languageservice/main/docs/customData.schema.json",
3
+ "version": 1.1,
4
+ "properties": [
5
+ {
6
+ "name": "--m3e-nav-bar-height",
7
+ "description": "Height of the navigation bar.",
8
+ "values": []
9
+ },
10
+ {
11
+ "name": "--m3e-nav-bar-container-color",
12
+ "description": "Background color of the navigation bar container.",
13
+ "values": []
14
+ },
15
+ {
16
+ "name": "--m3e-nav-bar-vertical-item-width",
17
+ "description": "Minimum width of vertical nav items.",
18
+ "values": []
19
+ },
20
+ {
21
+ "name": "--m3e-nav-item-label-text-font-size",
22
+ "description": "Font size for the label text.",
23
+ "values": []
24
+ },
25
+ {
26
+ "name": "--m3e-nav-item-label-text-font-weight",
27
+ "description": "Font weight for the label text.",
28
+ "values": []
29
+ },
30
+ {
31
+ "name": "--m3e-nav-item-label-text-line-height",
32
+ "description": "Line height for the label text.",
33
+ "values": []
34
+ },
35
+ {
36
+ "name": "--m3e-nav-item-label-text-tracking",
37
+ "description": "Letter spacing for the label text.",
38
+ "values": []
39
+ },
40
+ {
41
+ "name": "--m3e-nav-item-shape",
42
+ "description": "Border radius of the nav item.",
43
+ "values": []
44
+ },
45
+ {
46
+ "name": "--m3e-nav-item-icon-size",
47
+ "description": "Size of the icon.",
48
+ "values": []
49
+ },
50
+ {
51
+ "name": "--m3e-nav-item-spacing",
52
+ "description": "Spacing between icon and label.",
53
+ "values": []
54
+ },
55
+ {
56
+ "name": "--m3e-nav-item-inactive-label-text-color",
57
+ "description": "Color of the label text when inactive.",
58
+ "values": []
59
+ },
60
+ {
61
+ "name": "--m3e-nav-item-inactive-icon-color",
62
+ "description": "Color of the icon when inactive.",
63
+ "values": []
64
+ },
65
+ {
66
+ "name": "--m3e-nav-item-inactive-hover-state-layer-color",
67
+ "description": "State layer color on hover when inactive.",
68
+ "values": []
69
+ },
70
+ {
71
+ "name": "--m3e-nav-item-inactive-focus-state-layer-color",
72
+ "description": "State layer color on focus when inactive.",
73
+ "values": []
74
+ },
75
+ {
76
+ "name": "--m3e-nav-item-inactive-pressed-state-layer-color",
77
+ "description": "State layer color on press when inactive.",
78
+ "values": []
79
+ },
80
+ {
81
+ "name": "--m3e-nav-item-active-label-text-color",
82
+ "description": "Color of the label text when active/selected.",
83
+ "values": []
84
+ },
85
+ {
86
+ "name": "--m3e-nav-item-active-icon-color",
87
+ "description": "Color of the icon when active/selected.",
88
+ "values": []
89
+ },
90
+ {
91
+ "name": "--m3e-nav-item-active-container-color",
92
+ "description": "Container color when active/selected.",
93
+ "values": []
94
+ },
95
+ {
96
+ "name": "--m3e-nav-item-active-hover-state-layer-color",
97
+ "description": "State layer color on hover when active.",
98
+ "values": []
99
+ },
100
+ {
101
+ "name": "--m3e-nav-item-active-focus-state-layer-color",
102
+ "description": "State layer color on focus when active.",
103
+ "values": []
104
+ },
105
+ {
106
+ "name": "--m3e-nav-item-active-pressed-state-layer-color",
107
+ "description": "State layer color on press when active.",
108
+ "values": []
109
+ },
110
+ {
111
+ "name": "--m3e-nav-item-focus-ring-shape",
112
+ "description": "Border radius for the focus ring.",
113
+ "values": []
114
+ },
115
+ {
116
+ "name": "--m3e-nav-item-disabled-label-text-color",
117
+ "description": "Color of the label text when disabled.",
118
+ "values": []
119
+ },
120
+ {
121
+ "name": "--m3e-nav-item-disabled-label-text-opacity",
122
+ "description": "Opacity of the label text when disabled.",
123
+ "values": []
124
+ },
125
+ {
126
+ "name": "--m3e-nav-item-disabled-icon-color",
127
+ "description": "Color of the icon when disabled.",
128
+ "values": []
129
+ },
130
+ {
131
+ "name": "--m3e-nav-item-disabled-icon-opacity",
132
+ "description": "Opacity of the icon when disabled.",
133
+ "values": []
134
+ },
135
+ {
136
+ "name": "--m3e-horizontal-nav-item-padding",
137
+ "description": "Padding for horizontal orientation.",
138
+ "values": []
139
+ },
140
+ {
141
+ "name": "--m3e-horizontal-nav-item-active-indicator-height",
142
+ "description": "Height of the active indicator in horizontal orientation.",
143
+ "values": []
144
+ },
145
+ {
146
+ "name": "--m3e-vertical-nav-item-active-indicator-width",
147
+ "description": "Width of the active indicator in vertical orientation.",
148
+ "values": []
149
+ },
150
+ {
151
+ "name": "--m3e-vertical-nav-item-active-indicator-height",
152
+ "description": "Height of the active indicator in vertical orientation.",
153
+ "values": []
154
+ },
155
+ {
156
+ "name": "--m3e-vertical-nav-item-active-indicator-margin",
157
+ "description": "Margin for the active indicator in vertical orientation.",
158
+ "values": []
159
+ }
160
+ ],
161
+ "pseudoElements": []
162
+ }