@blockquote/create-wc 1.1.0 → 1.4.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/README.md +53 -50
- package/package.json +20 -20
- package/src/Generator.js +3 -1
- package/src/app/gatherMixins.js +26 -9
- package/src/app/index.js +10 -1
- package/src/common-linting/index.js +18 -0
- package/src/common-linting/templates/package.json +41 -0
- package/src/common-repo/index.js +7 -0
- package/src/common-repo/templates/gitignore +1 -0
- package/src/common-repo/templates/package.json +18 -16
- package/src/{wc-lit-element → common-repo}/templates/static/index.html +1 -1
- package/src/{wc-lit-element → common-repo}/templates/static/vite.config.js +28 -24
- package/src/{wc-lit-element → common-repo}/templates/static/web-dev-server.config.mjs +0 -0
- package/src/{wc-lit-element → common-repo}/templates/styles/MyEl.scss +1 -0
- package/src/common-testing-wtr/index.js +14 -0
- package/src/common-testing-wtr/templates/static/web-test-runner.config.mjs +69 -0
- package/src/linting/index.js +27 -0
- package/src/linting/templates/package.json +1 -0
- package/src/linting-eslint/index.js +17 -0
- package/src/linting-eslint/templates/package.json +1 -0
- package/src/linting-eslint-ts/index.js +17 -0
- package/src/linting-eslint-ts/templates/package.json +17 -0
- package/src/linting-prettier/index.js +17 -0
- package/src/linting-prettier/templates/package.json +1 -0
- package/src/linting-prettier-ts/index.js +17 -0
- package/src/linting-prettier-ts/templates/package.json +1 -0
- package/src/linting-ts/index.js +21 -0
- package/src/linting-ts/templates/package.json +1 -0
- package/src/testing/templates/my-el.test.js +1 -1
- package/src/testing/templates/package.json +2 -1
- package/src/testing-ts/index.js +32 -0
- package/src/testing-ts/templates/my-el.test.ts +62 -0
- package/src/testing-ts/templates/package.json +6 -0
- package/src/testing-wtr/index.js +1 -1
- package/src/testing-wtr/templates/package.json +3 -6
- package/src/testing-wtr/templates/static/{web-test-runner.config.mjs → _web-test-runner.config.mjs} +0 -0
- package/src/testing-wtr-ts/index.js +19 -0
- package/src/testing-wtr-ts/templates/package.json +6 -0
- package/src/testing-wtr-ts/templates/static/_web-test-runner.config.mjs +67 -0
- package/src/wc-lit-element/index.js +0 -6
- package/src/wc-lit-element/templates/MyEl.js +27 -8
- package/src/wc-lit-element/templates/my-el.js +1 -1
- package/src/wc-lit-element/templates/package.json +5 -12
- package/src/wc-lit-element/templates/static/README.md +3 -3
- package/src/wc-lit-element/templates/static/demo/index.html +21 -25
- package/src/wc-lit-element/templates/styles/MyEl-styles.js +15 -11
- package/src/wc-lit-element-ts/index.js +91 -0
- package/src/wc-lit-element-ts/templates/MyEl.ts +46 -0
- package/src/wc-lit-element-ts/templates/my-el.ts +3 -0
- package/src/wc-lit-element-ts/templates/package.json +24 -0
- package/src/wc-lit-element-ts/templates/partials/README.demoing.md +13 -0
- package/src/wc-lit-element-ts/templates/partials/README.linting.md +13 -0
- package/src/wc-lit-element-ts/templates/partials/README.testing.md +13 -0
- package/src/wc-lit-element-ts/templates/static/README.md +35 -0
- package/src/wc-lit-element-ts/templates/static/demo/index.html +25 -0
- package/src/wc-lit-element-ts/templates/static/index.ts +1 -0
- package/src/wc-lit-element-ts/templates/styles/MyEl-styles.ts +20 -0
- package/src/wc-lit-element-ts/templates/tsconfig.json +27 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
+
/* process.env.npm_lifecycle_event, process.env.npm_lifecycle_script, process.env.OUTDIR; */
|
|
3
|
+
|
|
4
|
+
// import { playwrightLauncher } from '@web/test-runner-playwright';
|
|
5
|
+
import { defaultReporter } from '@web/test-runner';
|
|
6
|
+
import { mochaStyleReporter } from '@blockquote/test-runner-mocha-style-reporter';
|
|
7
|
+
|
|
8
|
+
const filteredLogs = ['in dev mode'];
|
|
9
|
+
const outDir = process.env.OUTDIR || '.';
|
|
10
|
+
|
|
11
|
+
export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
|
|
12
|
+
/** Test files to run */
|
|
13
|
+
files: [`${outDir}/test/**/*.test.js`],
|
|
14
|
+
|
|
15
|
+
/** Resolve bare module imports */
|
|
16
|
+
nodeResolve: {
|
|
17
|
+
exportConditions: ['browser', 'development'],
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
reporters: [
|
|
21
|
+
defaultReporter(),
|
|
22
|
+
mochaStyleReporter(),
|
|
23
|
+
],
|
|
24
|
+
|
|
25
|
+
coverageConfig: {
|
|
26
|
+
report: true,
|
|
27
|
+
reportDir: `${outDir}/test/coverage`,
|
|
28
|
+
threshold: {
|
|
29
|
+
statements: 80,
|
|
30
|
+
branches: 80,
|
|
31
|
+
functions: 80,
|
|
32
|
+
lines: 80,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
testFramework: {
|
|
37
|
+
config: {
|
|
38
|
+
ui: 'tdd',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
/** Filter out lit dev mode logs */
|
|
43
|
+
filterBrowserLogs(log) {
|
|
44
|
+
for (const arg of log.args) {
|
|
45
|
+
if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
53
|
+
// esbuildTarget: 'auto',
|
|
54
|
+
|
|
55
|
+
/** Amount of browsers to run concurrently */
|
|
56
|
+
// concurrentBrowsers: 2,
|
|
57
|
+
|
|
58
|
+
/** Amount of test files per browser to test concurrently */
|
|
59
|
+
// concurrency: 1,
|
|
60
|
+
|
|
61
|
+
/** Browsers to run tests on */
|
|
62
|
+
// browsers: [
|
|
63
|
+
// playwrightLauncher({ product: 'chromium' }),
|
|
64
|
+
// playwrightLauncher({ product: 'firefox' }),
|
|
65
|
+
// playwrightLauncher({ product: 'webkit' }),
|
|
66
|
+
// ],
|
|
67
|
+
|
|
68
|
+
// See documentation for all available options
|
|
69
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { dirname } from 'path';
|
|
4
|
+
import { LintingEsLintMixin } from '../linting-eslint/index.js';
|
|
5
|
+
import { LintingPrettierMixin } from '../linting-prettier/index.js';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
|
|
10
|
+
export const LintingMixin = subclass =>
|
|
11
|
+
class extends LintingPrettierMixin(LintingEsLintMixin(subclass)) {
|
|
12
|
+
async execute() {
|
|
13
|
+
await super.execute();
|
|
14
|
+
|
|
15
|
+
// extend package.json
|
|
16
|
+
this.copyTemplateJsonInto(
|
|
17
|
+
`${__dirname}/templates/package.json`,
|
|
18
|
+
this.destinationPath('package.json'),
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { fileURLToPath } from 'url';
|
|
2
|
+
import { dirname } from 'path';
|
|
3
|
+
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = dirname(__filename);
|
|
6
|
+
|
|
7
|
+
export const LintingEsLintMixin = subclass =>
|
|
8
|
+
class extends subclass {
|
|
9
|
+
async execute() {
|
|
10
|
+
await super.execute();
|
|
11
|
+
|
|
12
|
+
this.copyTemplateJsonInto(
|
|
13
|
+
`${__dirname}/templates/package.json`,
|
|
14
|
+
this.destinationPath('package.json'),
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { fileURLToPath } from 'url';
|
|
2
|
+
import { dirname } from 'path';
|
|
3
|
+
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = dirname(__filename);
|
|
6
|
+
|
|
7
|
+
export const TsLintingEsLintMixin = subclass =>
|
|
8
|
+
class extends subclass {
|
|
9
|
+
async execute() {
|
|
10
|
+
await super.execute();
|
|
11
|
+
|
|
12
|
+
this.copyTemplateJsonInto(
|
|
13
|
+
`${__dirname}/templates/package.json`,
|
|
14
|
+
this.destinationPath('package.json'),
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"devDependencies": {
|
|
3
|
+
"@typescript-eslint/parser": "^5.0.0",
|
|
4
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0"
|
|
5
|
+
},
|
|
6
|
+
"eslintConfig": {
|
|
7
|
+
"parser": "@typescript-eslint/parser",
|
|
8
|
+
"plugins": [
|
|
9
|
+
"@typescript-eslint"
|
|
10
|
+
],
|
|
11
|
+
"rules": {
|
|
12
|
+
"indent": ["error", 2, { "SwitchCase": 1, "ignoredNodes": ["PropertyDefinition"] }],
|
|
13
|
+
"no-unused-vars": "off",
|
|
14
|
+
"@typescript-eslint/no-unused-vars": ["error"]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { fileURLToPath } from 'url';
|
|
2
|
+
import { dirname } from 'path';
|
|
3
|
+
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = dirname(__filename);
|
|
6
|
+
|
|
7
|
+
export const LintingPrettierMixin = subclass =>
|
|
8
|
+
class extends subclass {
|
|
9
|
+
async execute() {
|
|
10
|
+
await super.execute();
|
|
11
|
+
|
|
12
|
+
this.copyTemplateJsonInto(
|
|
13
|
+
`${__dirname}/templates/package.json`,
|
|
14
|
+
this.destinationPath('package.json'),
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { fileURLToPath } from 'url';
|
|
2
|
+
import { dirname } from 'path';
|
|
3
|
+
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = dirname(__filename);
|
|
6
|
+
|
|
7
|
+
export const TsLintingPrettierMixin = subclass =>
|
|
8
|
+
class extends subclass {
|
|
9
|
+
async execute() {
|
|
10
|
+
await super.execute();
|
|
11
|
+
|
|
12
|
+
this.copyTemplateJsonInto(
|
|
13
|
+
`${__dirname}/templates/package.json`,
|
|
14
|
+
this.destinationPath('package.json'),
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { dirname } from 'path';
|
|
4
|
+
import { TsLintingEsLintMixin } from '../linting-eslint-ts/index.js';
|
|
5
|
+
import { TsLintingPrettierMixin } from '../linting-prettier-ts/index.js';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
|
|
10
|
+
export const TsLintingMixin = subclass =>
|
|
11
|
+
class extends TsLintingPrettierMixin(TsLintingEsLintMixin(subclass)) {
|
|
12
|
+
async execute() {
|
|
13
|
+
await super.execute();
|
|
14
|
+
|
|
15
|
+
// extend package.json
|
|
16
|
+
this.copyTemplateJsonInto(
|
|
17
|
+
`${__dirname}/templates/package.json`,
|
|
18
|
+
this.destinationPath('package.json'),
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* eslint-disable max-classes-per-file */
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { dirname } from 'path';
|
|
4
|
+
import { TsTestingWebTestRunnerMixin } from '../testing-wtr-ts/index.js';
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = dirname(__filename);
|
|
8
|
+
|
|
9
|
+
export const TsTestingMixin = subclass =>
|
|
10
|
+
class extends TsTestingWebTestRunnerMixin(subclass) {
|
|
11
|
+
async execute() {
|
|
12
|
+
await super.execute();
|
|
13
|
+
|
|
14
|
+
this.copyTemplateJsonInto(
|
|
15
|
+
`${__dirname}/templates/package.json`,
|
|
16
|
+
this.destinationPath('package.json'),
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const TsTestingScaffoldMixin = subclass =>
|
|
22
|
+
class extends subclass {
|
|
23
|
+
async execute() {
|
|
24
|
+
await super.execute();
|
|
25
|
+
|
|
26
|
+
const { tagName } = this.templateData;
|
|
27
|
+
this.copyTemplate(
|
|
28
|
+
`${__dirname}/templates/my-el.test.ts`,
|
|
29
|
+
this.destinationPath(`test/${tagName}.test.ts`),
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { html, fixture, assert, fixtureCleanup } from '@open-wc/testing';
|
|
2
|
+
|
|
3
|
+
import { <%= className %> } from '../src/<%= className %>.js';
|
|
4
|
+
|
|
5
|
+
import '../define/<%= tagName %>.js';
|
|
6
|
+
|
|
7
|
+
suite('<%= className %>', () => {
|
|
8
|
+
let el: <%= className %>;
|
|
9
|
+
|
|
10
|
+
teardown(() => fixtureCleanup());
|
|
11
|
+
|
|
12
|
+
suite('Default', () => {
|
|
13
|
+
setup(async () => {
|
|
14
|
+
el = (await fixture(html` <<%= tagName %>></<%= tagName %>> `)) as <%= className %>;
|
|
15
|
+
await el.updateComplete;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('has a default heading "Hey there" and counter 5', async () => {
|
|
19
|
+
assert.equal(el.heading, 'Hey there');
|
|
20
|
+
assert.equal(el.counter, 5);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
suite('Semantic Dom and a11y', () => {
|
|
24
|
+
test('SHADOW DOM - Structure test', () => {
|
|
25
|
+
assert.shadowDom.equalSnapshot(el);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('LIGHT DOM - Structure test', () => {
|
|
29
|
+
assert.lightDom.equalSnapshot(el);
|
|
30
|
+
});
|
|
31
|
+
test('a11y', async () => {
|
|
32
|
+
await assert.isAccessible(el);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
suite('Events ', () => {
|
|
38
|
+
setup(async () => {
|
|
39
|
+
el = (await fixture(html` <<%= tagName %>></<%= tagName %>> `)) as <%= className %>;
|
|
40
|
+
await el.updateComplete;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('increases the counter on button click', async () => {
|
|
44
|
+
const button = el.shadowRoot!.querySelector('button')!;
|
|
45
|
+
button.click();
|
|
46
|
+
assert.equal(el.counter, 6);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
suite('Override ', () => {
|
|
51
|
+
setup(async () => {
|
|
52
|
+
el = (await fixture(
|
|
53
|
+
html` <<%= tagName %> heading="attribute heading"></<%= tagName %>> `,
|
|
54
|
+
)) as <%= className %>;
|
|
55
|
+
await el.updateComplete;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('can override the heading via attribute', async () => {
|
|
59
|
+
assert.equal(el.heading, 'attribute heading');
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
package/src/testing-wtr/index.js
CHANGED
package/src/testing-wtr/templates/static/{web-test-runner.config.mjs → _web-test-runner.config.mjs}
RENAMED
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { fileURLToPath } from 'url';
|
|
2
|
+
import { dirname } from 'path';
|
|
3
|
+
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = dirname(__filename);
|
|
6
|
+
|
|
7
|
+
export const TsTestingWebTestRunnerMixin = subclass =>
|
|
8
|
+
class extends subclass {
|
|
9
|
+
async execute() {
|
|
10
|
+
await super.execute();
|
|
11
|
+
|
|
12
|
+
this.copyTemplateJsonInto(
|
|
13
|
+
`${__dirname}/templates/package.json`,
|
|
14
|
+
this.destinationPath('package.json'),
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
// await this.copyTemplates(`${__dirname}/templates/static/**/*`);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
+
|
|
3
|
+
// import { playwrightLauncher } from '@web/test-runner-playwright';
|
|
4
|
+
import { defaultReporter } from '@web/test-runner';
|
|
5
|
+
import { mochaStyleReporter } from '@blockquote/test-runner-mocha-style-reporter';
|
|
6
|
+
|
|
7
|
+
const filteredLogs = ['in dev mode'];
|
|
8
|
+
|
|
9
|
+
export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
|
|
10
|
+
/** Test files to run */
|
|
11
|
+
files: 'dist/test/**/*.test.js',
|
|
12
|
+
|
|
13
|
+
/** Resolve bare module imports */
|
|
14
|
+
nodeResolve: {
|
|
15
|
+
exportConditions: ['browser', 'development'],
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
reporters: [
|
|
19
|
+
defaultReporter(),
|
|
20
|
+
mochaStyleReporter(),
|
|
21
|
+
],
|
|
22
|
+
|
|
23
|
+
coverageConfig: {
|
|
24
|
+
report: true,
|
|
25
|
+
reportDir: 'dist/test/coverage',
|
|
26
|
+
threshold: {
|
|
27
|
+
statements: 80,
|
|
28
|
+
branches: 80,
|
|
29
|
+
functions: 80,
|
|
30
|
+
lines: 80,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
testFramework: {
|
|
35
|
+
config: {
|
|
36
|
+
ui: 'tdd',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
/** Filter out lit dev mode logs */
|
|
41
|
+
filterBrowserLogs(log) {
|
|
42
|
+
for (const arg of log.args) {
|
|
43
|
+
if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
51
|
+
// esbuildTarget: 'auto',
|
|
52
|
+
|
|
53
|
+
/** Amount of browsers to run concurrently */
|
|
54
|
+
// concurrentBrowsers: 2,
|
|
55
|
+
|
|
56
|
+
/** Amount of test files per browser to test concurrently */
|
|
57
|
+
// concurrency: 1,
|
|
58
|
+
|
|
59
|
+
/** Browsers to run tests on */
|
|
60
|
+
// browsers: [
|
|
61
|
+
// playwrightLauncher({ product: 'chromium' }),
|
|
62
|
+
// playwrightLauncher({ product: 'firefox' }),
|
|
63
|
+
// playwrightLauncher({ product: 'webkit' }),
|
|
64
|
+
// ],
|
|
65
|
+
|
|
66
|
+
// See documentation for all available options
|
|
67
|
+
});
|
|
@@ -38,12 +38,6 @@ export const WcLitElementMixin = (subclass) =>
|
|
|
38
38
|
this.destinationPath(`src/${className}.js`),
|
|
39
39
|
);
|
|
40
40
|
|
|
41
|
-
// write & rename el scss template
|
|
42
|
-
this.copyTemplate(
|
|
43
|
-
`${__dirname}/templates/styles/MyEl.scss`,
|
|
44
|
-
this.destinationPath(`src/styles/${className}.scss`),
|
|
45
|
-
);
|
|
46
|
-
|
|
47
41
|
// write & rename el styles template
|
|
48
42
|
this.copyTemplate(
|
|
49
43
|
`${__dirname}/templates/styles/MyEl-styles.js`,
|
|
@@ -12,7 +12,16 @@ export class <%= className %> extends LitElement {
|
|
|
12
12
|
|
|
13
13
|
static get properties() {
|
|
14
14
|
return {
|
|
15
|
+
/**
|
|
16
|
+
* The heading to say "Hello" to.
|
|
17
|
+
* @type {string}
|
|
18
|
+
*/
|
|
15
19
|
heading: { type: String },
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The number of times the button has been clicked.
|
|
23
|
+
* @type {number}
|
|
24
|
+
*/
|
|
16
25
|
counter: { type: Number },
|
|
17
26
|
};
|
|
18
27
|
}
|
|
@@ -23,16 +32,26 @@ export class <%= className %> extends LitElement {
|
|
|
23
32
|
this.counter = 5;
|
|
24
33
|
}
|
|
25
34
|
|
|
26
|
-
__increment() {
|
|
27
|
-
this.counter += 1;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
35
|
render() {
|
|
31
36
|
return html`
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
<
|
|
37
|
+
<h1>${this.sayHello(this.heading)}!</h1>
|
|
38
|
+
<button @click=${this._onClick}>Counter: ${this.counter}</button>
|
|
39
|
+
<hr />
|
|
40
|
+
<slot></slot>
|
|
36
41
|
`;
|
|
37
42
|
}
|
|
43
|
+
|
|
44
|
+
_onClick() {
|
|
45
|
+
this.counter += 1;
|
|
46
|
+
this.dispatchEvent(new CustomEvent('counter-changed'));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Formats a greeting
|
|
51
|
+
* @param heading {string} The heading to say "Hello" to
|
|
52
|
+
* @returns {string} A greeting directed at `heading`
|
|
53
|
+
*/
|
|
54
|
+
sayHello(heading) {
|
|
55
|
+
return `Hello, ${heading}`;
|
|
56
|
+
}
|
|
38
57
|
}
|
|
@@ -5,19 +5,12 @@
|
|
|
5
5
|
"/define/",
|
|
6
6
|
"/src/",
|
|
7
7
|
"index.js",
|
|
8
|
-
"
|
|
8
|
+
"!/**/*.scss"
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
|
-
"start": "concurrently -k -r \"npm:sass:watch\" \"npm:
|
|
11
|
+
"start:wds": "concurrently -k -r \"npm:sass:watch\" \"npm:wds\"",
|
|
12
|
+
"wds": "web-dev-server",
|
|
12
13
|
"sass:watch": "sass-style-template",
|
|
13
|
-
"
|
|
14
|
-
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"lit": "^2.0.2"
|
|
17
|
-
},
|
|
18
|
-
"devDependencies": {
|
|
19
|
-
"vite": "^2.6.7",
|
|
20
|
-
"@web/dev-server": "^0.1.25"
|
|
21
|
-
|
|
14
|
+
"build": "echo \"This is not a TypeScript project, so no need to build.\""
|
|
22
15
|
}
|
|
23
|
-
}
|
|
16
|
+
}
|
|
@@ -20,11 +20,9 @@ npm i <%= tagName %>
|
|
|
20
20
|
<<%= tagName %>></<%= tagName %>>
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
<%= featureReadmes %>
|
|
24
|
-
|
|
25
23
|
## Tooling configs
|
|
26
24
|
|
|
27
|
-
For most of the tools, the configuration is in the `package.json` to
|
|
25
|
+
For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
|
|
28
26
|
|
|
29
27
|
If you customize the configuration a lot, you can consider moving them to individual files.
|
|
30
28
|
|
|
@@ -33,3 +31,5 @@ If you customize the configuration a lot, you can consider moving them to indivi
|
|
|
33
31
|
```bash
|
|
34
32
|
npm start
|
|
35
33
|
```
|
|
34
|
+
|
|
35
|
+
To run a local development server that serves the basic demo located in demo/index.html
|
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
<!
|
|
1
|
+
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
</head>
|
|
11
|
-
<body>
|
|
12
|
-
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<style>
|
|
6
|
+
body {
|
|
7
|
+
background: #fafafa;
|
|
8
|
+
}
|
|
9
|
+
</style>
|
|
10
|
+
</head>
|
|
11
|
+
<body>
|
|
12
|
+
<div id="demo"></div>
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
<script type="module">
|
|
15
|
+
import { html, render } from 'lit';
|
|
16
|
+
import '../define/<%= tagName %>.js';
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
document.querySelector('#demo')
|
|
26
|
-
);
|
|
27
|
-
</script>
|
|
28
|
-
</body>
|
|
18
|
+
const heading = 'World!';
|
|
19
|
+
render(
|
|
20
|
+
html`<<%= tagName %> .heading=${heading}>some light-dom</<%= tagName %>>`,
|
|
21
|
+
document.querySelector('#demo'),
|
|
22
|
+
);
|
|
23
|
+
</script>
|
|
24
|
+
</body>
|
|
29
25
|
</html>
|