Skip to content

Commit 47f1b3e

Browse files
committed
Add 'packages/lit-starter-js/' from commit '9328167fb10b3d7d59aa3fa98a4025208d991b38'
git-subtree-dir: packages/lit-starter-js git-subtree-mainline: 4cf616c git-subtree-split: 9328167
2 parents 4cf616c + 9328167 commit 47f1b3e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+15137
-0
lines changed

packages/lit-starter-js/.eleventy.cjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
2+
3+
module.exports = function(eleventyConfig) {
4+
eleventyConfig.addPlugin(syntaxHighlight);
5+
eleventyConfig.addPassthroughCopy("docs-src/docs.css");
6+
eleventyConfig.addPassthroughCopy("docs-src/.nojekyll");
7+
return {
8+
dir: {
9+
input: "docs-src",
10+
output: "docs"
11+
},
12+
templateExtensionAliases: {
13+
"11ty.cjs": "11ty.js",
14+
"11tydata.cjs": "11tydata.js"
15+
}
16+
};
17+
};

packages/lit-starter-js/.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/*
2+
docs/*
3+
docs-src/*
4+
rollup-config.js
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"extends": [
3+
"eslint:recommended"
4+
],
5+
"env": {
6+
"browser": true,
7+
"mocha": true
8+
},
9+
"globals": {
10+
"chai": "readonly"
11+
},
12+
"parser": "babel-eslint",
13+
"parserOptions": {
14+
"sourceType": "module"
15+
},
16+
"rules": {
17+
"no-unexpected-multiline": "off"
18+
}
19+
}

packages/lit-starter-js/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/node_modules/
2+
3+
# only generated for size check
4+
my-element.bundled.js
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"bracketSpacing": false
4+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3+
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4+
5+
// List of extensions which should be recommended for users of this workspace.
6+
"recommendations": [
7+
"runem.lit-plugin"
8+
],
9+
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
10+
"unwantedRecommendations": [
11+
12+
]
13+
}

packages/lit-starter-js/LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2019, The Polymer Authors. All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
* Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

packages/lit-starter-js/README.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# LitElement JavaScript starter
2+
3+
This project includes a sample component using LitElement with JavaScript.
4+
5+
## Setup
6+
7+
Install dependencies:
8+
9+
```bash
10+
npm i
11+
```
12+
13+
## Testing
14+
15+
This sample uses Karma, Chai, Mocha, and the open-wc test helpers for testing. See the [open-wc testing documentation](https://open-wc.org/testing/testing.html) for more information.
16+
17+
Tests can be run with the `test` script:
18+
19+
```bash
20+
npm test
21+
```
22+
23+
## Dev Server
24+
25+
This sample uses open-wc's [es-dev-server](https://github.com/open-wc/open-wc/tree/master/packages/es-dev-server) for previewing the project without additional build steps. ES dev server handles resolving Node-style "bare" import specifiers, which aren't supported in browsers. It also automatically transpiles JavaScript and adds polyfills to support older browsers.
26+
27+
To run the dev server and open the project in a new browser tab:
28+
29+
```bash
30+
npm run serve
31+
```
32+
33+
There is a development HTML file located at `/dev/index.html` that you can view at http://localhost:8000/dev/index.html.
34+
35+
## Editing
36+
37+
If you use VS Code, we highly reccomend the [lit-plugin extension](https://marketplace.visualstudio.com/items?itemName=runem.lit-plugin), which enables some extremely useful features for lit-html templates:
38+
- Syntax highlighting
39+
- Type-checking
40+
- Code completion
41+
- Hover-over docs
42+
- Jump to definition
43+
- Linting
44+
- Quick Fixes
45+
46+
The project is setup to reccomend lit-plugin to VS Code users if they don't already have it installed.
47+
48+
## Linting
49+
50+
Linting of JavaScript files is provided by [ESLint](eslint.org). In addition, [lit-analyzer](https://www.npmjs.com/package/lit-analyzer) is used to type-check and lint lit-html templates with the same engine and rules as lit-plugin.
51+
52+
The rules are mostly the recommended rules from each project, but some have been turned off to make LitElement usage easier. The recommended rules are pretty strict, so you may want to relax them by editing `.eslintrc.json`.
53+
54+
To lint the project run:
55+
56+
```bash
57+
npm run lint
58+
```
59+
60+
## Formatting
61+
62+
[Prettier](https://prettier.io/) is used for code formatting. It has been pre-configured according to the Polymer Project's style. You can change this in `.prettierrc.json`.
63+
64+
Prettier has not been configured to run when commiting files, but this can be added with Husky and and `pretty-quick`. See the [prettier.io](https://prettier.io/) site for instructions.
65+
66+
## Static Site
67+
68+
This project includes a simple website generated with the [eleventy](11ty.dev) static site generator and the templates and pages in `/docs-src`. The site is generated to `/docs` and intended to be checked in so that GitHub pages can serve the site [from `/docs` on the master branch](https://help.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site).
69+
70+
To enable the site go to the GitHub settings and change the GitHub Pages &quot;Source&quot; setting to &quot;master branch /docs folder&quot;.</p>
71+
72+
To build the site, run:
73+
74+
```bash
75+
npm run docs
76+
```
77+
78+
To serve the site locally, run:
79+
80+
```bash
81+
npm run docs:serve
82+
```
83+
84+
To watch the site files, and re-build automatically, run:
85+
86+
```bash
87+
npm run docs:watch
88+
```
89+
90+
The site will usually be served at http://localhost:8000.
91+
92+
## Bundling and minification
93+
94+
This starter project doesn't include any build-time optimizations like bundling or minification. We recommend publishing components as unoptimized JavaScript modules, and performing build-time optimizations at the application level. This gives build tools the best chance to deduplicate code, remove dead code, and so on.
95+
96+
For information on building application projects that include LitElement components, see [Build for production](https://lit-element.polymer-project.org/guide/build) on the LitElement site.
97+
98+
99+
## More information
100+
101+
See [Get started](https://lit-element.polymer-project.org/guide/start) on the LitElement site for more information.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"version": "experimental",
3+
"tags": [
4+
{
5+
"name": "my-element",
6+
"path": "./my-element.js",
7+
"description": "An example element.",
8+
"attributes": [
9+
{
10+
"name": "name",
11+
"description": "The name to say \"Hello\" to.",
12+
"type": "string",
13+
"default": "\"World\""
14+
},
15+
{
16+
"name": "count",
17+
"description": "The number of times the button has been clicked.",
18+
"type": "number",
19+
"default": "0"
20+
}
21+
],
22+
"properties": [
23+
{
24+
"name": "name",
25+
"attribute": "name",
26+
"description": "The name to say \"Hello\" to.",
27+
"type": "string",
28+
"default": "\"World\""
29+
},
30+
{
31+
"name": "count",
32+
"attribute": "count",
33+
"description": "The number of times the button has been clicked.",
34+
"type": "number",
35+
"default": "0"
36+
}
37+
],
38+
"slots": [
39+
{
40+
"name": "",
41+
"description": "This element has a slot"
42+
}
43+
],
44+
"cssParts": [
45+
{
46+
"name": "button",
47+
"description": "The button"
48+
}
49+
]
50+
},
51+
{
52+
"name": "my-element",
53+
"path": "./docs-/my-element.bundled.js",
54+
"attributes": [
55+
{
56+
"name": "name",
57+
"type": "string"
58+
},
59+
{
60+
"name": "count",
61+
"type": "number"
62+
}
63+
],
64+
"properties": [
65+
{
66+
"name": "name",
67+
"attribute": "name",
68+
"type": "string"
69+
},
70+
{
71+
"name": "count",
72+
"attribute": "count",
73+
"type": "number"
74+
},
75+
{
76+
"name": "hasUpdated",
77+
"type": "number"
78+
},
79+
{
80+
"name": "updateComplete",
81+
"type": "Promise<any>"
82+
}
83+
]
84+
}
85+
]
86+
}

packages/lit-starter-js/dev/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
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.

0 commit comments

Comments
 (0)