├── docs-src
├── .nojekyll
├── package.json
├── .eleventyignore
├── _includes
│ ├── header.11ty.cjs
│ ├── footer.11ty.cjs
│ ├── relative-path.cjs
│ ├── nav.11ty.cjs
│ ├── example.11ty.cjs
│ └── page.11ty.cjs
├── examples
│ ├── name-property.md
│ └── index.md
├── _data
│ └── api.11tydata.js
├── _README.md
├── install.md
├── index.md
├── docs.css
└── api.11ty.cjs
├── docs
├── .nojekyll
├── prism-okaidia.css
├── examples
│ ├── name-property
│ │ └── index.html
│ └── index.html
├── install
│ └── index.html
├── docs.css
├── api
│ └── index.html
└── index.html
├── .eslintignore
├── .prettierrc.json
├── dev
├── README.md
└── index.html
├── .gitignore
├── index.html
├── .vscode
└── extensions.json
├── web-dev-server.config.js
├── .eleventy.cjs
├── tsconfig.json
├── rollup.config.js
├── .eslintrc.json
├── LICENSE
├── src
├── my-element.ts
└── test
│ └── my-element_test.ts
├── package.json
├── web-test-runner.config.js
├── README.md
└── CHANGELOG.md
/docs-src/.nojekyll:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs/.nojekyll:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/docs-src/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "commonjs"
3 | }
4 |
--------------------------------------------------------------------------------
/docs-src/.eleventyignore:
--------------------------------------------------------------------------------
1 | # Ignore files with a leading underscore; useful for e.g. readmes in source documentation
2 | _*.md
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules/*
2 | docs/*
3 | docs-src/*
4 | rollup-config.js
5 | custom-elements.json
6 | web-dev-server.config.js
7 |
--------------------------------------------------------------------------------
/.prettierrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "trailingComma": "es5",
3 | "tabWidth": 2,
4 | "singleQuote": true,
5 | "bracketSpacing": false,
6 | "arrowParens": "always"
7 | }
8 |
--------------------------------------------------------------------------------
/dev/README.md:
--------------------------------------------------------------------------------
1 | This directory contains HTML files containing your element for development. By running `npm run build:watch` and `npm run serve` you can edit and see changes without bundling.
2 |
--------------------------------------------------------------------------------
/docs-src/_includes/header.11ty.cjs:
--------------------------------------------------------------------------------
1 | module.exports = function (data) {
2 | return `
3 | <my-element>
5 | A web component just for me.
6 |
This is child content
17 |This is child content
33 |This is child content
20 |<my-element name="Earth"></my-element>
51 |
52 | <my-element> is distributed on npm, so you can install it locally or use it via npm CDNs like unpkg.com.
npm i my-element
35 | npm CDNs like unpkg.com can directly serve files that have been published to npm. This works great for standard JavaScript modules that the browser can load natively.
37 |For this element to work from unpkg.com specifically, you need to include the ?module query parameter, which tells unpkg.com to rewrite "bare" module specifiers to full URLs.
<script type="module" src="https://unpkg.com/my-element?module"></script>
40 | import {MyElement} from 'https://unpkg.com/my-element?module';
42 |
43 | This is child content
56 |p {
border: solid 1px blue;
padding: 8px;
}
59 | <my-element>
<p>This is child content</p>
</my-element>
61 |
62 | | ${capitalize( 109 | (Array.isArray(p) ? p[0] : p).split('.')[0] 110 | )} | ` 111 | ) 112 | .join('')} 113 |
|---|
| ${get(i, p)} | `).join('')} 119 |
| Name | Description | Type | Default | 43 |
|---|---|---|---|
| name | The name to say "Hello" to. | string | 'World' | 47 |
| count | The number of times the button has been clicked. | number | 0 | 51 |
| Name | Attribute | Description | Type | Default | 60 |
|---|---|---|---|---|
| name | name | The name to say "Hello" to. | string | 'World' | 64 |
| count | count | The number of times the button has been clicked. | number | 0 | 68 |
| Name | Parameters | Description | Return | 77 |||||||
|---|---|---|---|---|---|---|---|---|---|
| sayHello |
81 |
82 |
| Formats a greeting | string | 93 |
| Name | Description | 102 |
|---|---|
| count-changed | Indicates when the count changes | 106 |
| Name | Description | 115 |
|---|---|
| (default) | This element has a slot | 119 |
| Name | Description | 128 |
|---|---|
| button | The button | 132 |
<my-element> is an awesome element. It's a great introduction to building web components with LitElement, with nice documentation site as well.
<my-element> is just an HTML element. You can it anywhere you can use HTML!
<my-element></my-element>
38 | <my-element> can be configured with attributed in plain HTML.
<my-element name="HTML"></my-element>
48 | <my-element> can be used with declarative rendering libraries like Angular, React, Vue, and lit-html
import {html, render} from 'lit-html';
const name = 'lit-html';
render(
html`
<h2>This is a <my-element></h2>
<my-element .name=${name}></my-element>
`,
document.body
);
58 |