Skip to content

Commit 76c015e

Browse files
committed
Initial commit
0 parents  commit 76c015e

18 files changed

+7120
-0
lines changed

Diff for: .babelrc

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"env": {
3+
"esm": {
4+
"presets": ["github"]
5+
},
6+
"umd": {
7+
"plugins": [
8+
"@babel/plugin-transform-modules-umd"
9+
],
10+
"presets": ["github"]
11+
}
12+
}
13+
}

Diff for: .eslintrc.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"extends": [
3+
"plugin:github/browser",
4+
"plugin:github/es6",
5+
"plugin:github/flow"
6+
],
7+
"parser": "babel-eslint",
8+
"overrides": [
9+
{
10+
"files": "test/**/*.js",
11+
"rules": {
12+
"flowtype/require-valid-file-annotation": "off",
13+
"github/unescaped-html-literal": "off"
14+
}
15+
}
16+
]
17+
}

Diff for: .flowconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[ignore]
2+
3+
[include]
4+
5+
[libs]
6+
7+
[options]
8+
9+
[lints]

Diff for: .github/workflows/nodejs.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Node CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
jobs:
8+
build:
9+
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
matrix:
14+
node-version: [8.x, 10.x, 12.x]
15+
16+
steps:
17+
- uses: actions/checkout@v1
18+
- name: Use Node.js ${{ matrix.node-version }}
19+
uses: actions/setup-node@v1
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
- name: npm install, build, and test
23+
run: |
24+
npm install
25+
npm run build --if-present
26+
npm test
27+
env:
28+
CI: true

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
node_modules

Diff for: .travis.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
language: node_js
2+
sudo: required
3+
node_js:
4+
- "node"
5+
addons:
6+
chrome: stable
7+
cache:
8+
directories:
9+
- node_modules

Diff for: LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2019 GitHub, Inc.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Diff for: README.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# <custom-element> element
2+
3+
Boilerplate for creating a custom element.
4+
5+
## Installation
6+
7+
```
8+
$ npm install @github/custom-element-element
9+
```
10+
11+
## Usage
12+
13+
```js
14+
import '@github/custom-element-element'
15+
```
16+
17+
```html
18+
<custom-element></custom-element>
19+
```
20+
21+
## Browser support
22+
23+
Browsers without native [custom element support][support] require a [polyfill][].
24+
25+
- Chrome
26+
- Firefox
27+
- Safari
28+
- Microsoft Edge
29+
30+
[support]: https://caniuse.com/#feat=custom-elementsv1
31+
[polyfill]: https://github.com/webcomponents/custom-elements
32+
33+
## Development
34+
35+
```
36+
npm install
37+
npm test
38+
```
39+
40+
## License
41+
42+
Distributed under the MIT license. See LICENSE for details.

Diff for: examples/index.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>custom-element demo</title>
6+
</head>
7+
<body>
8+
<custom-element></custom-element>
9+
10+
<script>
11+
const script = document.createElement('script')
12+
if (window.location.hostname.endsWith('github.io')) {
13+
script.src = "https://unpkg.com/@github/custom-element-boilerplate@latest/dist/index.umd.js"
14+
} else {
15+
script.src = "../dist/index.umd.js"
16+
}
17+
document.body.appendChild(script)
18+
</script>
19+
</body>
20+
</html>

Diff for: index.d.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default class CustomElementElement extends HTMLElement { }
2+
3+
declare global {
4+
interface Window {
5+
CustomElementElement: typeof CustomElementElement
6+
}
7+
}

Diff for: index.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* @flow strict */
2+
3+
class CustomElementElement extends HTMLElement {
4+
constructor() {
5+
super()
6+
}
7+
8+
connectedCallback() {
9+
this.textContent = ':wave:'
10+
}
11+
12+
disconnectedCallback() {}
13+
}
14+
15+
export default CustomElementElement
16+
17+
if (!window.customElements.get('custom-element')) {
18+
window.CustomElementElement = CustomElementElement
19+
window.customElements.define('custom-element', CustomElementElement)
20+
}

Diff for: index.js.flow

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* @flow strict */
2+
3+
declare module '@github/custom-element-element' {
4+
declare export default class CustomElementElement extends HTMLElement { }
5+
}

0 commit comments

Comments
 (0)