Skip to content

Commit fad036c

Browse files
committed
Update Readme with better usage instructions
1 parent 36673bb commit fad036c

8 files changed

+53
-90
lines changed

README.md

+26-32
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,38 @@
1-
***UPDATE BADGE URLS BELOW***
1+
[![Build Status](https://travis-ci.com/internetarchive/iaux-your-webcomponent.svg?branch=master)](https://travis-ci.com/internetarchive/iaux-your-webcomponent) [![codecov](https://codecov.io/gh/internetarchive/iaux-your-webcomponent/branch/master/graph/badge.svg)](https://codecov.io/gh/internetarchive/iaux-your-webcomponent)
22

3-
[![Build Status](https://travis-ci.com/internetarchive/iaux-typescript-wc-template.svg?branch=master)](https://travis-ci.com/internetarchive/iaux-typescript-wc-template)
3+
# Internet Archive Typescript WebComponent Template
44

5-
[![codecov](https://codecov.io/gh/internetarchive/iaux-typescript-wc-template/branch/master/graph/badge.svg)](https://codecov.io/gh/internetarchive/iaux-typescript-wc-template)
5+
This is a base template for creating Typescript WebComponents. It is based off of the [Open WebComponents generator](https://open-wc.org/docs/development/generator/) with some IA-specific customizations and some development niceities.
66

7-
# \<typescript-template>
7+
## Usage
8+
9+
1. Click the "Use this Template" button in GitHub to create a new repository based on this one.
10+
2. Clone your new repo and update the things below:
811

9-
This webcomponent follows the [open-wc](https://github.com/open-wc/open-wc) recommendation.
12+
### Things to update in your copy
13+
1. Remove this section
14+
2. Search for the strings `your-webcomponent` and `YourWebComponent` and those are most of the spots that need to be updated.
15+
3. `README.md` (this file). Update the readme in general, but also the badge URLs
16+
4. `package.json` Update the name and description
17+
5. Rename the `your-webcomponent.ts` and its associated `.test` file
18+
6. Update `.travis.yml` with the proper secure key. See the [Travis docs](https://blog.travis-ci.com/2014-03-13-slack-notifications/) for more information.
1019

11-
## Installation
20+
## Local Demo with `web-dev-server`
1221
```bash
13-
yarn add typescript-template
22+
yarn start
1423
```
24+
To run a local development server that serves the basic demo located in `demo/index.html`
1525

16-
## Usage
17-
```html
18-
<script type="module">
19-
import 'typescript-template/typescript-template.js';
20-
</script>
26+
## Testing with Web Test Runner
27+
To run the suite of Web Test Runner tests, run
28+
```bash
29+
yarn run test
30+
```
31+
32+
To run the tests in watch mode (for &lt;abbr title=&#34;test driven development&#34;&gt;TDD&lt;/abbr&gt;, for example), run
2133

22-
<typescript-template></typescript-template>
34+
```bash
35+
yarn run test:watch
2336
```
2437

2538
## Linting with ESLint, Prettier, and Types
@@ -49,27 +62,8 @@ yarn run format:eslint
4962
yarn run format:prettier
5063
```
5164

52-
## Testing with Web Test Runner
53-
To run the suite of Web Test Runner tests, run
54-
```bash
55-
yarn run test
56-
```
57-
58-
To run the tests in watch mode (for &lt;abbr title=&#34;test driven development&#34;&gt;TDD&lt;/abbr&gt;, for example), run
59-
60-
```bash
61-
yarn run test:watch
62-
```
63-
64-
6565
## Tooling configs
6666

6767
For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
6868

6969
If you customize the configuration a lot, you can consider moving them to individual files.
70-
71-
## Local Demo with `web-dev-server`
72-
```bash
73-
yarn start
74-
```
75-
To run a local development server that serves the basic demo located in `demo/index.html`

custom-elements.json

-32
This file was deleted.

demo/index.html

+6-4
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@
1717

1818
<script type="module">
1919
import { html, render } from 'lit-html';
20-
import '../dist/typescript-template.js';
20+
import '../dist/index.js';
2121

2222
const title = 'Hello owc World!';
2323
render(
2424
html`
25-
<typescript-template .title=${title}>
26-
some more light-dom
27-
</typescript-template>
25+
<your-webcomponent .title=${title}>
26+
<div slot="my-slot">
27+
Some lightDOM slotted content
28+
</div>
29+
</your-webcomponent>
2830
`,
2931
document.querySelector('#demo')
3032
);

index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { TypescriptTemplate } from './src/typescript-template';
1+
export { YourWebComponent } from './src/your-webcomponent';

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "@internetarchive/typescript-wc-template",
2+
"name": "@internetarchive/your-webcomponent",
33
"version": "0.0.0",
4-
"description": "Internet Archive Typescript WebComponent template. It is based on the @open-wc base template.",
5-
"author": "typescript-template",
4+
"description": "The Internet Archive Typescript WebComponent template. It is based on the @open-wc template.",
5+
"author": "Internet Archive",
66
"license": "AGPL-3.0-only",
77
"main": "dist/index.js",
88
"module": "dist/index.js",

src/typescript-template.ts renamed to src/your-webcomponent.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { html, css, LitElement, property } from 'lit-element';
1+
import { html, css, LitElement, property, customElement } from 'lit-element';
22

3-
export class TypescriptTemplate extends LitElement {
3+
@customElement('your-webcomponent')
4+
export class YourWebComponent extends LitElement {
45
static styles = css`
56
:host {
67
display: block;
78
padding: 25px;
8-
color: var(--typescript-template-text-color, #000);
9+
color: var(--your-webcomponent-text-color, #000);
910
}
1011
`;
1112

@@ -19,8 +20,9 @@ export class TypescriptTemplate extends LitElement {
1920

2021
render() {
2122
return html`
22-
<h2>${this.title} Nr. ${this.counter}!</h2>
23+
<h2>${this.title}, Number: ${this.counter}!</h2>
2324
<button @click=${this.__increment}>increment</button>
25+
<slot name="my-slot"> </slot>
2426
`;
2527
}
2628
}

test/typescript-template.test.ts renamed to test/your-webcomponent.test.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
import { html, fixture, expect } from '@open-wc/testing';
22

3-
import { TypescriptTemplate } from '../src/typescript-template';
4-
import '../typescript-template';
3+
import type { YourWebComponent } from '../src/your-webcomponent';
4+
import '../src/your-webcomponent';
55

6-
describe('TypescriptTemplate', () => {
6+
describe('YourWebComponent', () => {
77
it('has a default title "Hey there" and counter 5', async () => {
8-
const el = await fixture<TypescriptTemplate>(
9-
html`<typescript-template></typescript-template>`
8+
const el = await fixture<YourWebComponent>(
9+
html`<your-webcomponent></your-webcomponent>`
1010
);
1111

1212
expect(el.title).to.equal('Hey there');
1313
expect(el.counter).to.equal(5);
1414
});
1515

1616
it('increases the counter on button click', async () => {
17-
const el = await fixture<TypescriptTemplate>(
18-
html`<typescript-template></typescript-template>`
17+
const el = await fixture<YourWebComponent>(
18+
html`<your-webcomponent></your-webcomponent>`
1919
);
2020
el.shadowRoot!.querySelector('button')!.click();
2121

2222
expect(el.counter).to.equal(6);
2323
});
2424

2525
it('can override the title via attribute', async () => {
26-
const el = await fixture<TypescriptTemplate>(
27-
html`<typescript-template title="attribute title"></typescript-template>`
26+
const el = await fixture<YourWebComponent>(
27+
html`<your-webcomponent title="attribute title"></your-webcomponent>`
2828
);
2929

3030
expect(el.title).to.equal('attribute title');
3131
});
3232

3333
it('passes the a11y audit', async () => {
34-
const el = await fixture<TypescriptTemplate>(
35-
html`<typescript-template></typescript-template>`
34+
const el = await fixture<YourWebComponent>(
35+
html`<your-webcomponent></your-webcomponent>`
3636
);
3737

3838
await expect(el).shadowDom.to.be.accessible();

typescript-template.ts

-3
This file was deleted.

0 commit comments

Comments
 (0)