-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathdemo-lit.html
50 lines (37 loc) · 1.52 KB
/
demo-lit.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
layout: layout.html
title: Lit Islands
showImportMaps: true
---
<h1><a href="/">is-land</a> using <img src="https://v1.indieweb-avatar.11ty.dev/https%3A%2F%2Flit.dev%2F/" alt="IndieWeb avatar for https://lit.dev/" width="28" height="28" decoding="async" loading="lazy"> Lit</h1>
{% include "import-map-warning.liquid" %}
<h2>Scroll down</h2>
<hr style="height: 100vh">
<h2>Client-rendered Lit</h2>
<p>You can use `import="./lit-component.js"` or `<template data-island> with <script type="module">`:</p>
<is-land on:visible import="./lib/lit/lit-component-client.js">
This is a lit component:
<lit-component-client class="demo-component" name="World">Fallback content!</lit-web-component>
</is-land>
<is-land on:visible id="lit-test">
This is a lit component: <lit-other-web-component class="demo-component" name="World">Fallback content!</lit-other-web-component>
<template data-island>
<script type="module">
import {html, css, LitElement} from "lit";
class LitComponent extends LitElement {
// encapsulated styles!
static styles = css`p { color: blue; margin: 0; }`;
static properties = {
name: {type: String},
};
render() {
this.classList.add("test-c-finish");
return html`<p>Hello, ${this.name || "Stranger"}!</p>`;
}
}
customElements.define('lit-other-web-component', LitComponent);
</script>
</template>
</is-land>
<h2>Server-rendered Lit (SSR)</h2>
<p>Use the <a href="https://lit.dev/blog/2022-02-07-eleventy/"><code>@lit-labs/eleventy-plugin-lit</code></a> plugin.</p>