This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| lit-it-up [2026/04/04 10:33] – created admin | lit-it-up [2026/04/04 12:05] (current) – admin | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| ====== Lit it up! ====== | ====== Lit it up! ====== | ||
| - | Use JavaScript | + | Re-use WebComponents and JS libraries |
| + | {{ :: | ||
| + | |||
| + | ====== What is Lit? ====== | ||
| + | |||
| + | * A small wrapper around the WebComponents standard | ||
| + | * Lit enables you to write WebComponents in a convenient and productive way | ||
| + | |||
| + | ====== ... and what are WebComponents? | ||
| + | |||
| + | **In short:** | ||
| + | |||
| + | WebComponents allow you to define/ | ||
| + | |||
| + | |||
| + | **For example:** | ||
| + | |||
| + | <code html> | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | ====== WebComponent example ====== | ||
| + | |||
| + | <code JavaScript> | ||
| + | import {LitElement, | ||
| + | |||
| + | export class Typo3Surfcamp extends LitElement { | ||
| + | static properties = { | ||
| + | year: {type: Number, attribute: ' | ||
| + | }; | ||
| + | |||
| + | constructor() { | ||
| + | super(); | ||
| + | this.year = 0; | ||
| + | } | ||
| + | |||
| + | render() { | ||
| + | return html`< | ||
| + | } | ||
| + | } | ||
| + | |||
| + | customElements.define(' | ||
| + | </ | ||
| + | |||
| + | ====== Load the WebComponent ====== | ||
| + | |||
| + | |||
| + | Load a single component: | ||
| + | |||
| + | <code php> | ||
| + | $this-> | ||
| + | </ | ||
| + | |||
| + | Load multiple components with a single entry point: | ||
| + | <code php> | ||
| + | $this-> | ||
| + | </ | ||