@m3e/heading 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,109 @@
1
+ # @m3e/heading
2
+
3
+ The `m3e-heading` component provides expressive, accessible headings for pages and sections, supporting display, headline, title, and label variants in multiple sizes. It applies Material 3 typographic tokens for font size, weight, line height, and letter spacing, ensuring visual hierarchy and clarity.
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/heading
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/heading`, 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/heading/dist/html-custom-data.json"],
27
+ "css.customData": ["./node_modules/@m3e/heading/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/heading/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
+ }
48
+ }
49
+ </script>
50
+ ```
51
+
52
+ > For production, use index.min.js for faster load times.
53
+
54
+ ## ๐Ÿ—‚๏ธ Elements
55
+
56
+ - `m3e-heading` โ€” A heading to a page or section.
57
+
58
+ ## ๐Ÿงช Examples
59
+
60
+ The following example illustrates use of the `m3e-heading` to present each variant and size.
61
+
62
+ ```html
63
+ <m3e-heading variant="display" size="large">Display Large</m3e-heading>
64
+ <m3e-heading variant="display" size="medium">Display Medium</m3e-heading>
65
+ <m3e-heading variant="display" size="small">Display Small</m3e-heading>
66
+ <m3e-heading variant="headline" size="large">Headline Large</m3e-heading>
67
+ <m3e-heading variant="headline" size="medium">Headline Medium</m3e-heading>
68
+ <m3e-heading variant="headline" size="small">Headline Small</m3e-heading>
69
+ <m3e-heading variant="title" size="large">Title Large</m3e-heading>
70
+ <m3e-heading variant="title" size="medium">Title Medium</m3e-heading>
71
+ <m3e-heading variant="title" size="small">Title Small</m3e-heading>
72
+ <m3e-heading variant="label" size="large">Label Large</m3e-heading>
73
+ <m3e-heading variant="label" size="medium">Label Medium</m3e-heading>
74
+ <m3e-heading variant="label" size="small">Label Small</m3e-heading>
75
+ ```
76
+
77
+ The next example illustrates use of the `level` attribute to designate the accessibility level of a heading.
78
+ When specified, ARIA `role="heading"` is applied and the `level` is propagated to `aria-level`.
79
+
80
+ ```html
81
+ <m3e-heading variant="headline" size="large" level="1">Page title</m3e-heading>
82
+ ```
83
+
84
+ ## ๐Ÿ“– API Reference
85
+
86
+ This section details the attributes and slots available for the `m3e-heading` component.
87
+
88
+ ### โš™๏ธ Attributes
89
+
90
+ | Attribute | Type | Default | Description |
91
+ | ------------ | ----------------------------------------------------- | ----------- | ------------------------------------------------- |
92
+ | `emphasized` | `boolean` | `false` | Whether the heading uses an emphasized typescale. |
93
+ | `variant` | `"display"` \| `"headline"` \| `"title"` \| `"label"` | `"display"` | The appearance variant of the heading. |
94
+ | `size` | `"small"` \| `"medium"` \| `"large"` | "medium" | The size of the heading. |
95
+ | `level` | `1` \| `2` \| `3` \| `4` \| `5` \| `6` | | The accessibility level of the heading. |
96
+
97
+ ### ๐Ÿงฉ Slots
98
+
99
+ | Slot | Description |
100
+ | ----------- | ----------------------------------- |
101
+ | _(default)_ | Renders the content of the heading. |
102
+
103
+ ## ๐Ÿค Contributing
104
+
105
+ See the root monorepo `CONTRIBUTING.md` for guidelines on contributing to this package.
106
+
107
+ ## ๐Ÿ“„ License
108
+
109
+ 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,54 @@
1
+ <!doctype html>
2
+ <html lang="en" style="overflow-y: auto">
3
+ <head>
4
+ <title>Heading for M3E</title>
5
+ <meta charset="utf-8" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <meta name="description" content="Heading 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
+ }
25
+ }
26
+ </script>
27
+ <script type="module" src="../../theme/dist/index.min.js"></script>
28
+ <script type="module" src="../dist/index.min.js"></script>
29
+ <style>
30
+ body {
31
+ font-family: "Roboto";
32
+ }
33
+ *:not(:defined) {
34
+ display: none;
35
+ }
36
+ </style>
37
+ </head>
38
+ <body>
39
+ <m3e-theme strong-focus>
40
+ <m3e-heading variant="display" size="large">Display Large</m3e-heading>
41
+ <m3e-heading variant="display" size="medium">Display Medium</m3e-heading>
42
+ <m3e-heading variant="display" size="small">Display Small</m3e-heading>
43
+ <m3e-heading variant="headline" size="large">Headline Large</m3e-heading>
44
+ <m3e-heading variant="headline" size="medium">Headline Medium</m3e-heading>
45
+ <m3e-heading variant="headline" size="small">Headline Small</m3e-heading>
46
+ <m3e-heading variant="title" size="large">Title Large</m3e-heading>
47
+ <m3e-heading variant="title" size="medium">Title Medium</m3e-heading>
48
+ <m3e-heading variant="title" size="small">Title Small</m3e-heading>
49
+ <m3e-heading variant="label" size="large">Label Large</m3e-heading>
50
+ <m3e-heading variant="label" size="medium">Label Medium</m3e-heading>
51
+ <m3e-heading variant="label" size="small">Label Small</m3e-heading>
52
+ </m3e-theme>
53
+ </body>
54
+ </html>
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/microsoft/vscode-css-languageservice/main/docs/customData.schema.json",
3
+ "version": 1.1,
4
+ "properties": [],
5
+ "pseudoElements": []
6
+ }
@@ -0,0 +1,194 @@
1
+ {
2
+ "schemaVersion": "1.0.0",
3
+ "readme": "",
4
+ "modules": [
5
+ {
6
+ "kind": "javascript-module",
7
+ "path": "src/HeadingElement.ts",
8
+ "declarations": [
9
+ {
10
+ "kind": "class",
11
+ "description": "",
12
+ "name": "M3eHeadingElement",
13
+ "slots": [
14
+ {
15
+ "description": "Renders the content of the heading.",
16
+ "name": ""
17
+ }
18
+ ],
19
+ "members": [
20
+ {
21
+ "kind": "field",
22
+ "name": "emphasized",
23
+ "type": {
24
+ "text": "boolean"
25
+ },
26
+ "default": "false",
27
+ "description": "Whether the heading uses an emphasized typescale.",
28
+ "attribute": "emphasized",
29
+ "reflects": true
30
+ },
31
+ {
32
+ "kind": "field",
33
+ "name": "variant",
34
+ "type": {
35
+ "text": "HeadingVariant"
36
+ },
37
+ "default": "\"display\"",
38
+ "description": "The appearance variant of the heading.",
39
+ "attribute": "variant",
40
+ "reflects": true
41
+ },
42
+ {
43
+ "kind": "field",
44
+ "name": "size",
45
+ "type": {
46
+ "text": "HeadingSize"
47
+ },
48
+ "default": "\"medium\"",
49
+ "description": "The size of the heading.",
50
+ "attribute": "size",
51
+ "reflects": true
52
+ },
53
+ {
54
+ "kind": "field",
55
+ "name": "level",
56
+ "type": {
57
+ "text": "HeadingLevel | undefined"
58
+ },
59
+ "description": "The accessibility level of the heading.",
60
+ "default": "undefined",
61
+ "attribute": "level"
62
+ }
63
+ ],
64
+ "attributes": [
65
+ {
66
+ "description": "Whether the heading uses an emphasized typescale.",
67
+ "name": "emphasized",
68
+ "type": {
69
+ "text": "boolean"
70
+ },
71
+ "default": "false",
72
+ "fieldName": "emphasized"
73
+ },
74
+ {
75
+ "description": "The accessibility level of the heading.",
76
+ "name": "level",
77
+ "type": {
78
+ "text": "HeadingLevel | undefined"
79
+ },
80
+ "default": "undefined",
81
+ "fieldName": "level"
82
+ },
83
+ {
84
+ "description": "The size of the heading.",
85
+ "name": "size",
86
+ "type": {
87
+ "text": "HeadingSize"
88
+ },
89
+ "default": "\"medium\"",
90
+ "fieldName": "size"
91
+ },
92
+ {
93
+ "description": "The appearance variant of the heading.",
94
+ "name": "variant",
95
+ "type": {
96
+ "text": "HeadingVariant"
97
+ },
98
+ "default": "\"display\"",
99
+ "fieldName": "variant"
100
+ }
101
+ ],
102
+ "mixins": [
103
+ {
104
+ "name": "Role",
105
+ "package": "@m3e/core"
106
+ }
107
+ ],
108
+ "superclass": {
109
+ "name": "LitElement",
110
+ "package": "lit"
111
+ },
112
+ "tagName": "m3e-heading",
113
+ "customElement": true,
114
+ "summary": "A heading to a page or section."
115
+ }
116
+ ],
117
+ "exports": [
118
+ {
119
+ "kind": "js",
120
+ "name": "M3eHeadingElement",
121
+ "declaration": {
122
+ "name": "M3eHeadingElement",
123
+ "module": "src/HeadingElement.ts"
124
+ }
125
+ },
126
+ {
127
+ "kind": "custom-element-definition",
128
+ "name": "m3e-heading",
129
+ "declaration": {
130
+ "name": "M3eHeadingElement",
131
+ "module": "src/HeadingElement.ts"
132
+ }
133
+ }
134
+ ]
135
+ },
136
+ {
137
+ "kind": "javascript-module",
138
+ "path": "src/HeadingLevel.ts",
139
+ "declarations": [],
140
+ "exports": []
141
+ },
142
+ {
143
+ "kind": "javascript-module",
144
+ "path": "src/HeadingSize.ts",
145
+ "declarations": [],
146
+ "exports": []
147
+ },
148
+ {
149
+ "kind": "javascript-module",
150
+ "path": "src/HeadingVariant.ts",
151
+ "declarations": [],
152
+ "exports": []
153
+ },
154
+ {
155
+ "kind": "javascript-module",
156
+ "path": "src/index.ts",
157
+ "declarations": [],
158
+ "exports": [
159
+ {
160
+ "kind": "js",
161
+ "name": "*",
162
+ "declaration": {
163
+ "name": "*",
164
+ "package": "\"./HeadingElement\""
165
+ }
166
+ },
167
+ {
168
+ "kind": "js",
169
+ "name": "*",
170
+ "declaration": {
171
+ "name": "*",
172
+ "package": "\"./HeadingLevel\""
173
+ }
174
+ },
175
+ {
176
+ "kind": "js",
177
+ "name": "*",
178
+ "declaration": {
179
+ "name": "*",
180
+ "package": "\"./HeadingSize\""
181
+ }
182
+ },
183
+ {
184
+ "kind": "js",
185
+ "name": "*",
186
+ "declaration": {
187
+ "name": "*",
188
+ "package": "\"./HeadingVariant\""
189
+ }
190
+ }
191
+ ]
192
+ }
193
+ ]
194
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/microsoft/vscode-html-languageservice/main/docs/customData.schema.json",
3
+ "version": 1.1,
4
+ "tags": [
5
+ {
6
+ "name": "m3e-heading",
7
+ "description": "A heading to a page or section.\n---\n\n\n### **Slots:**\n - _default_ - Renders the content of the heading.",
8
+ "attributes": [
9
+ {
10
+ "name": "emphasized",
11
+ "description": "Whether the heading uses an emphasized typescale.",
12
+ "values": []
13
+ },
14
+ {
15
+ "name": "level",
16
+ "description": "The accessibility level of the heading.",
17
+ "values": [{ "name": "HeadingLevel" }]
18
+ },
19
+ {
20
+ "name": "size",
21
+ "description": "The size of the heading.",
22
+ "values": [{ "name": "HeadingSize" }]
23
+ },
24
+ {
25
+ "name": "variant",
26
+ "description": "The appearance variant of the heading.",
27
+ "values": [{ "name": "HeadingVariant" }]
28
+ }
29
+ ],
30
+ "references": []
31
+ }
32
+ ]
33
+ }