Skip to content

Final JS docs fixes and launch #501

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 0 additions & 114 deletions packages/lit-dev-content/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions packages/lit-dev-content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@
"@material/mwc-button": "^0.22.1",
"@material/mwc-dialog": "^0.23.0",
"@material/mwc-drawer": "^0.22.1",
"@material/mwc-formfield": "^0.22.1",
"@material/mwc-icon-button": "^0.22.1",
"@material/mwc-icon-button-toggle": "^0.22.1",
"@material/mwc-snackbar": "^0.22.1",
"@material/mwc-switch": "^0.22.1",
"lit": "^2.0.0-pre.1",
"lit-element": "^2.3.1",
"lit-html": "^1.2.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ class MyElement extends LitElement {
${this.show ? html`
<ul>${this.todos.map(i => html`<li>${i}</li>`)}</ul>
` : ''}`;
}
/* playground-fold */
}/* playground-fold */
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* playground-fold */
import {LitElement, html} from 'lit';

class MyElement extends LitElement {
/* playground-fold-end */

static properties = {
colors: {},
};

constructor() {
super();
this.colors = ['red', 'green', 'blue'];
}

render() {
return html`<p>Colors: ${this.colors}</p>`;
}
/* playground-fold */

}
customElements.define('my-element', MyElement);
/* playground-fold-end */
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* playground-fold */
import {LitElement, html} from 'lit';

class MyElement extends LitElement {
/* playground-fold-end */

static properties = {
colors: {},
};

constructor() {
super();
this.colors = ['red', 'green', 'blue'];
}

render() {
return html`
<ul>
${this.colors.map((color) =>
html`<li style="color: ${color}">${color}</li>`
)}
</ul>
`;
}
/* playground-fold */

}
customElements.define('my-element', MyElement);
/* playground-fold-end */

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "/samples/base.json",
"title": "Hello World (TypeScript)",
"description": "Basic example of a Lit component using TypeScript.",
"title": "Hello World",
"description": "Basic example of a Lit component.",
"section": "Basics",
"files": {
"simple-greeting.ts": {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export class SimpleGreeting extends LitElement {
static styles = css`p { color: blue }`;

static properties = {
name: {type: String}
name: {type: String},
};

constructor() {
Expand All @@ -16,5 +16,4 @@ export class SimpleGreeting extends LitElement {
return html`<p>Hello, ${this.name}!</p>`;
}
}

customElements.define('simple-greeting', SimpleGreeting);
9 changes: 8 additions & 1 deletion packages/lit-dev-content/samples/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
"exclude": [
// Intentionally contains unused imports. This one's .js output is
// hand-rolled becuase TypeScript will elide imports.
"tutorial/02-define/before/my-element.ts"
"tutorial/02-define/before/my-element.ts",
// Position of static properties block is imperfect, and this example is
// prominent on the homepage. See https://github.com/lit/lit/issues/2159.
"examples/hello-world/simple-greeting.ts",
// Comments in some locations get lost by TypeScript. See
// https://github.com/lit/lit/issues/2158.
"docs/templates/lists-arrays/my-element.ts",
"docs/templates/lists-map/my-element.ts"
]
}
1 change: 1 addition & 0 deletions packages/lit-dev-content/site/_includes/blog-post.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

{% block head %}
{% inlinecss "blog-post.css" %}
<script type="module" src="{{ site.baseurl }}/js/components/litdev-switchable-sample.js"></script>
{% endblock %}

{% block drawer %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ LitElement uses lit-html to render components and adds APIs to declare reactive
properties and attributes. Elements update automatically when their properties
change. And they update _fast_, without diffing.

Here's a simple LitElement component in TypeScript:
Here's a simple LitElement component:

{% switchable-sample %}

```ts
@customElement('name-tag')
Expand All @@ -104,7 +106,25 @@ class NameTag extends LitElement {
}
```

(We have a great vanilla JavaScript API also.)
```js
class NameTag extends LitElement {
static properties = {
name: {},
};

constructor() {
super();
this.name = 'a secret';
}

render() {
return html`<p>Hi, my name is ${this.name}!</p>`;
}
}
customElements.define('name-tag', NameTag);
```

{% endswitchable-sample %}

This creates an element you can use anywhere you'd use a regular HTML element:

Expand Down
Loading