Skip to content

Commit 60451ec

Browse files
committed
npx @krhkt/custom-element-boilerplate-setup@latest
1 parent 0a63540 commit 60451ec

File tree

8 files changed

+56
-56
lines changed

8 files changed

+56
-56
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
"custom-elements/tag-name-matches-class": ["error", {"suffix": "Element"}]
1313
},
1414
"globals": {
15-
"CustomElementElement": "readonly"
15+
"OverflowMenuElement": "readonly"
1616
}
1717
}

custom-elements.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
"modules": [
55
{
66
"kind": "javascript-module",
7-
"path": "src/custom-element.ts",
7+
"path": "src/overflow-menu-element.ts",
88
"declarations": [
99
{
1010
"kind": "class",
11-
"description": "An example Custom Element. This documentation ends up in the\nREADME so describe how this elements works here.\n\nYou can event add examples on the element is used with Markdown.\n\n```\n<custom-element></custom-element>\n```",
12-
"name": "CustomElementElement",
11+
"description": "An example Custom Element. This documentation ends up in the\nREADME so describe how this elements works here.\n\nYou can event add examples on the element is used with Markdown.\n\n```\n<overflow-menu></overflow-menu>\n```",
12+
"name": "OverflowMenuElement",
1313
"superclass": {
1414
"name": "HTMLElement"
1515
},
16-
"tagName": "custom-element",
16+
"tagName": "overflow-menu",
1717
"customElement": true
1818
}
1919
],
@@ -22,16 +22,16 @@
2222
"kind": "js",
2323
"name": "default",
2424
"declaration": {
25-
"name": "CustomElementElement",
26-
"module": "src/custom-element.ts"
25+
"name": "OverflowMenuElement",
26+
"module": "src/overflow-menu-element.ts"
2727
}
2828
},
2929
{
3030
"kind": "custom-element-definition",
31-
"name": "custom-element",
31+
"name": "overflow-menu",
3232
"declaration": {
33-
"name": "CustomElementElement",
34-
"module": "src/custom-element.ts"
33+
"name": "OverflowMenuElement",
34+
"module": "src/overflow-menu-element.ts"
3535
}
3636
}
3737
]

examples/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<title>custom-element demo</title>
5+
<title>overflow-menu demo</title>
66
</head>
77
<body>
8-
<custom-element></custom-element>
8+
<overflow-menu></overflow-menu>
99

1010
<script type="module">
1111
// import 'https://unpkg.com/@github/custom-element-boilerplate@latest/dist/custom-element.js'
12-
import '../src/custom-element.ts'
12+
import '../src/overflow-menu-element.ts'
1313
</script>
1414
</body>
1515
</html>

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"name": "@github/custom-element-element",
2+
"name": "overflow-menu-element",
33
"version": "0.0.1",
44
"description": "Boilerplate for creating a custom element.",
5-
"main": "dist/custom-element.js",
6-
"module": "dist/custom-element.js",
5+
"main": "dist/overflow-menu-element.js",
6+
"module": "dist/overflow-menu-element.js",
77
"type": "module",
8-
"types": "dist/custom-elements.d.ts",
8+
"types": "dist/overflow-menu-element.d.ts",
99
"license": "MIT",
10-
"repository": "github/custom-element-boilerplate",
10+
"repository": "github/overflow-menu-element",
1111
"files": [
1212
"dist"
1313
],

src/custom-element.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/overflow-menu-element.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* An example Custom Element. This documentation ends up in the
3+
* README so describe how this elements works here.
4+
*
5+
* You can event add examples on the element is used with Markdown.
6+
*
7+
* ```
8+
* <overflow-menu></overflow-menu>
9+
* ```
10+
*/
11+
class OverflowMenuElement extends HTMLElement {
12+
connectedCallback(): void {
13+
this.textContent = ':wave:'
14+
}
15+
}
16+
17+
declare global {
18+
interface Window {
19+
OverflowMenuElement: typeof OverflowMenuElement
20+
}
21+
}
22+
23+
export default OverflowMenuElement
24+
25+
if (!window.customElements.get('overflow-menu')) {
26+
window.OverflowMenuElement = OverflowMenuElement
27+
window.customElements.define('overflow-menu', OverflowMenuElement)
28+
}

test/test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
import {assert, fixture, html} from '@open-wc/testing'
2-
import '../src/custom-element'
2+
import '../src/overflow-menu-element'
33

4-
describe('custom-element', function () {
4+
describe('overflow-menu', function () {
55
describe('element creation', function () {
66
it('creates from document.createElement', function () {
7-
const el = document.createElement('custom-element')
8-
assert.equal('CUSTOM-ELEMENT', el.nodeName)
7+
const el = document.createElement('overflow-menu')
8+
assert.equal('OVERFLOW-MENU', el.nodeName)
99
})
1010

1111
it('creates from constructor', function () {
12-
const el = new window.CustomElementElement()
13-
assert.equal('CUSTOM-ELEMENT', el.nodeName)
12+
const el = new window.OverflowMenuElement()
13+
assert.equal('OVERFLOW-MENU', el.nodeName)
1414
})
1515
})
1616

1717
describe('after tree insertion', function () {
1818
beforeEach(async function () {
19-
await fixture(html` <custom-element></custom-element>`)
19+
await fixture(html` <overflow-menu></overflow-menu>`)
2020
})
2121

2222
it('initiates', function () {
23-
const ce = document.querySelector('custom-element')
23+
const ce = document.querySelector('overflow-menu')
2424
assert.equal(ce?.textContent, ':wave:')
2525
})
2626
})

vscode.html-custom-data.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"tags": [
33
{
4-
"name": "custom-element",
5-
"description": "An example Custom Element. This documentation ends up in the\nREADME so describe how this elements works here.\n\nYou can event add examples on the element is used with Markdown.\n\n```\n<custom-element></custom-element>\n```",
4+
"name": "overflow-menu",
5+
"description": "An example Custom Element. This documentation ends up in the\nREADME so describe how this elements works here.\n\nYou can event add examples on the element is used with Markdown.\n\n```\n<overflow-menu></overflow-menu>\n```",
66
"attributes": []
77
}
88
]

0 commit comments

Comments
 (0)