diff --git a/.prettierignore b/.prettierignore index 41c915fed..e37db73b2 100644 --- a/.prettierignore +++ b/.prettierignore @@ -8,8 +8,5 @@ package-lock.json /packages/lit-dev-content/_dev/ /packages/lit-dev-content/_site/ /packages/lit-dev-content/rollupout/ -# TODO(aomarks) Would be nice to format samples, but Prettier doesn't always do -# a great job compared to our manual formatting. -/packages/lit-dev-content/samples/ .wireit diff --git a/lit-dev.code-workspace b/lit-dev.code-workspace index 70a44ab67..9b3af68c6 100644 --- a/lit-dev.code-workspace +++ b/lit-dev.code-workspace @@ -2,48 +2,48 @@ "folders": [ { "name": "lit-dev-content", - "path": "packages/lit-dev-content" + "path": "packages/lit-dev-content", }, { "name": "lit-dev-tools-cjs", - "path": "packages/lit-dev-tools-cjs" + "path": "packages/lit-dev-tools-cjs", }, { "name": "lit-dev-tools-esm", - "path": "packages/lit-dev-tools-esm" + "path": "packages/lit-dev-tools-esm", }, { "name": "lit-dev-tests", - "path": "packages/lit-dev-tests" + "path": "packages/lit-dev-tests", }, { "name": "lit-dev-api", - "path": "packages/lit-dev-api" + "path": "packages/lit-dev-api", }, { "name": "lit-dev-server", - "path": "packages/lit-dev-server" + "path": "packages/lit-dev-server", }, { "name": "lit-dev-discord-bot", - "path": "packages/lit-dev-discord-bot" + "path": "packages/lit-dev-discord-bot", }, { "name": "lit.dev", - "path": "." - } + "path": ".", + }, ], "settings": { "files.insertFinalNewline": true, "files.trimTrailingWhitespace": true, "[typescript]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" + "editor.defaultFormatter": "esbenp.prettier-vscode", }, "search.exclude": { - "api-data/*/repo": true + "api-data/*/repo": true, }, }, "extensions": { - "recommendations": ["esbenp.prettier-vscode"] - } + "recommendations": ["esbenp.prettier-vscode"], + }, } diff --git a/package-lock.json b/package-lock.json index 8652c0cd7..4d271beba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ ], "devDependencies": { "playground-elements": "^0.20.0", - "prettier": "^2.1.2", + "prettier": "^3.5.3", "typescript": "~4.7.4", "wireit": "^0.14.0" } @@ -6963,13 +6963,15 @@ } }, "node_modules/prettier": { - "version": "2.7.1", + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz", + "integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==", "license": "MIT", "bin": { - "prettier": "bin-prettier.js" + "prettier": "bin/prettier.cjs" }, "engines": { - "node": ">=10.13.0" + "node": ">=14" }, "funding": { "url": "https://github.com/prettier/prettier?sponsor=1" @@ -8982,7 +8984,7 @@ "fast-glob": "^3.2.9", "lit-dev-server": "^0.0.0", "lit-dev-tools-cjs": "^0.0.0", - "prettier": "^2.3.2" + "prettier": "^3.5.3" } } } diff --git a/package.json b/package.json index d3d67555b..86a55232b 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ }, "devDependencies": { "playground-elements": "^0.20.0", - "prettier": "^2.1.2", + "prettier": "^3.5.3", "typescript": "~4.7.4", "wireit": "^0.14.0" } diff --git a/packages/lit-dev-cloudbuild-cleanup/src/cleanup.ts b/packages/lit-dev-cloudbuild-cleanup/src/cleanup.ts index c4bcbe5cc..ca7b5249a 100644 --- a/packages/lit-dev-cloudbuild-cleanup/src/cleanup.ts +++ b/packages/lit-dev-cloudbuild-cleanup/src/cleanup.ts @@ -39,7 +39,7 @@ async function main() { if (!PROJECT_ID || !REPO_NAME || !_DEPLOY_REGION) { console.log({PROJECT_ID, REPO_NAME, _DEPLOY_REGION}); throw new Error( - 'Missing one or more required environment variables: PROJECT_ID, REPO_NAME, _DEPLOY_REGION' + 'Missing one or more required environment variables: PROJECT_ID, REPO_NAME, _DEPLOY_REGION', ); } @@ -98,7 +98,7 @@ async function main() { !rev.metadata.name ) { throw new Error( - `Found revision with missing necessary metadata: ${JSON.stringify(rev)}` + `Found revision with missing necessary metadata: ${JSON.stringify(rev)}`, ); } @@ -160,7 +160,7 @@ async function main() { } else if (!t.tag.startsWith('main')) { // Unrecognized tags are kept just in case console.log( - `Found unrecognized tag "${t.tag}". This will not be deleted.` + `Found unrecognized tag "${t.tag}". This will not be deleted.`, ); revisionsToKeep.add(t.revisionName); return true; diff --git a/packages/lit-dev-content/.eleventy.js b/packages/lit-dev-content/.eleventy.js index 3e575cec1..eef15d50a 100644 --- a/packages/lit-dev-content/.eleventy.js +++ b/packages/lit-dev-content/.eleventy.js @@ -71,7 +71,7 @@ module.exports = function (eleventyConfig) { eleventyConfig.addWatchTarget('../lit-dev-api/api-data/*/*.json'); eleventyConfig.addWatchTarget( - '../lit-dev-content/samples/tutorials/**/tutorial.json' + '../lit-dev-content/samples/tutorials/**/tutorial.json', ); eleventyConfig.addWatchTarget('../lit-dev-content/samples/tutorials/**/*.md'); eleventyConfig.addWatchTarget('../lit-dev-content/rollupout/server/*'); @@ -119,14 +119,14 @@ ${content} Object.assign(new state.Token('div_open', 'div', 1), { attrs: [['class', `heading ${headingTag}`]], block: true, - }) + }), ); state.tokens.splice( idx + 4, 0, Object.assign(new state.Token('div_close', 'div', -1), { block: true, - }) + }), ); linkAfterHeaderBase(slug, opts, state, idx + 1); }; @@ -165,16 +165,16 @@ ${content} function (url, latestVersion) { if (!latestVersion) { throw new Error( - `No latestVersion provided to 'removeLatestVersionFromUrl` + `No latestVersion provided to 'removeLatestVersionFromUrl`, ); } if (!url.includes(`/${latestVersion}/`)) { throw new Error( - `'${url}' does not include the latestVersion versioned path segment` + `'${url}' does not include the latestVersion versioned path segment`, ); } return url.replace(`/${latestVersion}/`, '/'); - } + }, ); /** @@ -191,11 +191,11 @@ ${content} } if (!latestVersion) { throw new Error( - `latestVersion not provided to 'fixUnversionedCrossLinks` + `latestVersion not provided to 'fixUnversionedCrossLinks`, ); } return content.replaceAll(`/docs/${latestVersion}/`, '/docs/'); - } + }, ); eleventyConfig.addFilter('removeExtension', function (url) { @@ -446,7 +446,7 @@ ${content} if (location === undefined) { throw new Error( `Ambiguous symbol ${symbol}. ` + - `Options: ${locations.map((l) => l.anchor).join(', ')}` + `Options: ${locations.map((l) => l.anchor).join(', ')}`, ); } @@ -459,8 +459,8 @@ ${content} 'api-v3', '/docs/v3/api', JSON.parse( - fsSync.readFileSync('../lit-dev-api/api-data/lit-3/symbols.json', 'utf8') - ) + fsSync.readFileSync('../lit-dev-api/api-data/lit-3/symbols.json', 'utf8'), + ), ); addApiShortcode( @@ -468,8 +468,8 @@ ${content} '/docs/v2/api', // Don't use require() because of Node caching in watch mode. JSON.parse( - fsSync.readFileSync('../lit-dev-api/api-data/lit-2/symbols.json', 'utf8') - ) + fsSync.readFileSync('../lit-dev-api/api-data/lit-2/symbols.json', 'utf8'), + ), ); addApiShortcode( @@ -478,9 +478,9 @@ ${content} JSON.parse( fsSync.readFileSync( '../lit-dev-api/api-data/lit-html-1/symbols.json', - 'utf8' - ) - ) + 'utf8', + ), + ), ); addApiShortcode( @@ -489,9 +489,9 @@ ${content} JSON.parse( fsSync.readFileSync( '../lit-dev-api/api-data/lit-element-2/symbols.json', - 'utf8' - ) - ) + 'utf8', + ), + ), ); /** @@ -520,7 +520,7 @@ ${content} `CleanCSS errors/warnings on file ${path}:\n\n${[ ...result.errors, ...result.warnings, - ].join('\n')}` + ].join('\n')}`, ); } return ``; @@ -554,14 +554,14 @@ ${content} // Source: https://github.com/11ty/eleventy-base-blog/blob/master/.eleventy.js eleventyConfig.addFilter('readableDate', (dateObj) => { return luxon.DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat( - 'LLL d, yyyy' + 'LLL d, yyyy', ); }); // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string eleventyConfig.addFilter('yyyymmdd', (dateObj) => { return luxon.DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat( - 'yyyy-LL-dd' + 'yyyy-LL-dd', ); }); @@ -587,7 +587,7 @@ ${content} ENV.eleventyOutDir + '/docs/v3/introduction.html', ENV.eleventyOutDir + '/docs/v3/*/index.html', ], - {ignore: ENV.eleventyOutDir + '/docs/(v1|v2|v3)/index.html'} + {ignore: ENV.eleventyOutDir + '/docs/(v1|v2|v3)/index.html'}, ) ).filter( // TODO(aomarks) This is brittle, we need a way to annotate inside an md @@ -595,7 +595,7 @@ ${content} (file) => !file.includes('why-lit') && !file.includes('getting-started') && - !file.includes('browser-support') + !file.includes('browser-support'), ); await Promise.all(emptyDocsIndexFiles.map((path) => fs.unlink(path))); @@ -611,32 +611,32 @@ ${content} // immediately, instead of triggering an Eleventy build. await symlinkForce( path.join(__dirname, 'site', 'css'), - path.join(__dirname, ENV.eleventyOutDir, 'css') + path.join(__dirname, ENV.eleventyOutDir, 'css'), ); await symlinkForce( path.join(__dirname, 'site', 'images'), - path.join(__dirname, ENV.eleventyOutDir, 'images') + path.join(__dirname, ENV.eleventyOutDir, 'images'), ); await symlinkForce( path.join(__dirname, 'site', 'fonts'), - path.join(__dirname, ENV.eleventyOutDir, 'fonts') + path.join(__dirname, ENV.eleventyOutDir, 'fonts'), ); await symlinkForce( path.join(__dirname, 'samples'), - path.join(__dirname, ENV.eleventyOutDir, 'samples') + path.join(__dirname, ENV.eleventyOutDir, 'samples'), ); // Symlink lib -> _dev/js. This lets us directly reference tsc outputs in // dev mode, instead of the Rollup bundles we use for production. await symlinkForce( path.join(__dirname, 'lib'), - path.join(__dirname, ENV.eleventyOutDir, 'js') + path.join(__dirname, ENV.eleventyOutDir, 'js'), ); } else { // Inline all Playground project files directly into their manifests, to // cut down on requests per project. await inlinePlaygroundFilesIntoManifests( - `${ENV.eleventyOutDir}/samples/**/project.json` + `${ENV.eleventyOutDir}/samples/**/project.json`, ); // Pre-compress all outputs as .br and .gz files so the server can read @@ -649,7 +649,7 @@ ${content} await fs.writeFile( path.join(ENV.eleventyOutDir, 'csp-inline-script-hashes.txt'), [...cspInlineScriptHashes].join('\n'), - 'utf8' + 'utf8', ); } }); @@ -676,7 +676,7 @@ ${content} // In prod SSR should use the lit templates run through the minifier. if (!DEV) { componentModules = componentModules.map((componentPath) => - componentPath.replace('lib/components', 'rollupout/server') + componentPath.replace('lib/components', 'rollupout/server'), ); } diff --git a/packages/lit-dev-content/samples/_check-code-helpers.ts b/packages/lit-dev-content/samples/_check-code-helpers.ts index e819a6a96..002cffc6b 100644 --- a/packages/lit-dev-content/samples/_check-code-helpers.ts +++ b/packages/lit-dev-content/samples/_check-code-helpers.ts @@ -1,6 +1,8 @@ import {PostDoc} from 'postdoc-lib'; -export const installCodeChecker = async (checkCode: () => Promise<{passed: boolean, message?: string}>) => { +export const installCodeChecker = async ( + checkCode: () => Promise<{passed: boolean; message?: string}>, +) => { const postDoc = new PostDoc({ messageTarget: window.top!, messageReceiver: window, @@ -15,9 +17,9 @@ export const installCodeChecker = async (checkCode: () => Promise<{passed: boole postDoc.postMessage({status, message}); break; } - } + }, }); await postDoc.handshake; postDoc.postMessage({status: 'READY'}); -} \ No newline at end of file +}; diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/add-styles/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/add-styles/index.html index 57a0c9aca..9a1b15c74 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/add-styles/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/add-styles/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/add-styles/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/add-styles/my-element.ts index 9fc3fecd0..36f084a1c 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/add-styles/my-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/add-styles/my-element.ts @@ -1,10 +1,11 @@ -import { html, LitElement, css } from 'lit'; -import { customElement } from 'lit/decorators.js'; +import {html, LitElement, css} from 'lit'; +import {customElement} from 'lit/decorators.js'; @customElement('my-element') export class MyElement extends LitElement { render() { - return html`

I'm blue

I'm red
`; + return html`

I'm blue

+
I'm red
`; } static styles = css` @@ -15,4 +16,4 @@ export class MyElement extends LitElement { color: red; } `; -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/index.html index 57a0c9aca..9a1b15c74 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/input-or-textfield.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/input-or-textfield.ts index 9078aee71..c9b34137e 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/input-or-textfield.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/input-or-textfield.ts @@ -1,30 +1,26 @@ -import { html, LitElement } from 'lit'; -import { customElement, property } from 'lit/decorators.js'; -import { html as staticHTML, StaticValue } from 'lit/static-html.js'; +import {html, LitElement} from 'lit'; +import {customElement, property} from 'lit/decorators.js'; +import {html as staticHTML, StaticValue} from 'lit/static-html.js'; @customElement('input-or-textfield') export class MyElement extends LitElement { // attribute is false because this is a value that can't be serialized to an // HTML attribute - @property({ attribute: false }) tagLiteral: StaticValue|null = null; + @property({attribute: false}) tagLiteral: StaticValue | null = null; @property() value = ''; render() { return html` - ${ - staticHTML` + ${staticHTML` <${this.tagLiteral} @input=${this.#onInput} .value=${this.value}> - ` - } -
- The value of the input is: ${this.value} -
+ `} +
The value of the input is: ${this.value}
`; } #onInput(e: InputEvent) { - this.value = (e.target as (HTMLInputElement | HTMLTextAreaElement)).value; + this.value = (e.target as HTMLInputElement | HTMLTextAreaElement).value; } } diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/my-element.ts index 8723151f8..86668941e 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/my-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/my-element.ts @@ -1,6 +1,6 @@ -import { css, html, LitElement } from 'lit'; -import { customElement, state } from 'lit/decorators.js'; -import { literal } from 'lit/static-html.js'; +import {css, html, LitElement} from 'lit'; +import {customElement, state} from 'lit/decorators.js'; +import {literal} from 'lit/static-html.js'; import './input-or-textfield.js'; @customElement('my-element') @@ -14,37 +14,49 @@ export class MyElement extends LitElement {
+ value="this is the default value" + .tagLiteral=${this.tagLiteral} + > `; } #onChange(e: InputEvent) { const target = e.target as HTMLInputElement; - this.tagLiteral = target.value === 'input' ? literal`input` : literal`textarea`; + this.tagLiteral = + target.value === 'input' ? literal`input` : literal`textarea`; } - static styles = css`/* playground-fold */:host { font-family: sans-serif; } :host > * { margin-block: .5em; }/* playground-fold-end */`; + static styles = css` + /* playground-fold */ + :host { + font-family: sans-serif; + } + :host > * { + margin-block: 0.5em; + } /* playground-fold-end */ + `; } diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/classes/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/classes/index.html index 57a0c9aca..9a1b15c74 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/classes/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/classes/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/classes/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/classes/my-element.ts index e31973473..fea57fa24 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/classes/my-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/classes/my-element.ts @@ -1,19 +1,19 @@ -import { html, LitElement, css } from 'lit'; -import { customElement, state } from 'lit/decorators.js'; -import { classMap } from 'lit/directives/class-map.js'; +import {html, LitElement, css} from 'lit'; +import {customElement, state} from 'lit/decorators.js'; +import {classMap} from 'lit/directives/class-map.js'; @customElement('my-element') export class MyElement extends LitElement { - @state() counter = 0 + @state() counter = 0; firstUpdated() { - setInterval(() => this.counter += 1 , 1000); + setInterval(() => (this.counter += 1), 1000); } render() { const classes = { red: this.counter % 2 === 0, - blue: this.counter % 2 === 1 + blue: this.counter % 2 === 1, }; return html`

Hello!

`; } @@ -26,4 +26,4 @@ export class MyElement extends LitElement { color: blue; } `; -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/conditionals/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/conditionals/index.html index 57a0c9aca..9a1b15c74 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/conditionals/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/conditionals/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/conditionals/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/conditionals/my-element.ts index 860091f41..5a2ab9e87 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/conditionals/my-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/conditionals/my-element.ts @@ -1,5 +1,5 @@ -import { html, LitElement } from 'lit'; -import { customElement, state } from 'lit/decorators.js'; +import {html, LitElement} from 'lit'; +import {customElement, state} from 'lit/decorators.js'; @customElement('my-element') export class MyElement extends LitElement { @@ -14,13 +14,18 @@ export class MyElement extends LitElement { return html`
This is an inline ternary conditional
- ${this.someBoolean ? html`

Some other text

` : html`

Some text

`} + ${this.someBoolean + ? html`

Some other text

` + : html`

Some text

`}
This is a variable conditional
${someText} `; } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/index.html index 57a0c9aca..9a1b15c74 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/my-element.ts index 8bd747eee..b003176c3 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/my-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/my-element.ts @@ -1,6 +1,9 @@ -import { html, LitElement } from 'lit'; -import { customElement } from 'lit/decorators.js'; -import { trustedStyles, type CSSStyleSheet } from './trusted-stringified-css-source.js'; +import {html, LitElement} from 'lit'; +import {customElement} from 'lit/decorators.js'; +import { + trustedStyles, + type CSSStyleSheet, +} from './trusted-stringified-css-source.js'; // Use constructable stylesheets on TRUSTED CSS strings to use them in a LitElement const styles = new CSSStyleSheet(); @@ -11,10 +14,6 @@ const styles = new CSSStyleSheet(); export class MyElement extends LitElement { static styles = styles; render() { - return html` -
- This should be red! -
- `; + return html`
This should be red!
`; } } diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/trusted-stringified-css-source.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/trusted-stringified-css-source.ts index fce4ea3be..9375f6e47 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/trusted-stringified-css-source.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/trusted-stringified-css-source.ts @@ -5,7 +5,7 @@ export const trustedStyles = ` `; // This may be needed for some older versions of TS -export type CSSStyleSheet = typeof globalThis['CSSStyleSheet'] & { +export type CSSStyleSheet = (typeof globalThis)['CSSStyleSheet'] & { replaceSync(cssText: string): void; replace(cssText: string): void; }; diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/css-shadow-parts/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/css-shadow-parts/index.html index 63ef6c4b2..18cbd2eb8 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/css-shadow-parts/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/css-shadow-parts/index.html @@ -21,4 +21,4 @@
-
\ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/css-shadow-parts/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/css-shadow-parts/my-element.ts index 6fac25d2d..177b8c074 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/css-shadow-parts/my-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/css-shadow-parts/my-element.ts @@ -1,5 +1,5 @@ -import { html, LitElement, css } from 'lit'; -import { customElement } from 'lit/decorators.js'; +import {html, LitElement, css} from 'lit'; +import {customElement} from 'lit/decorators.js'; @customElement('my-element') export class MyElement extends LitElement { @@ -15,4 +15,4 @@ export class MyElement extends LitElement { render() { return html`

This is in a shadow root!

`; } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/custom-attribute-converter/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/custom-attribute-converter/index.html index d0fdb30d1..fb29bb482 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/custom-attribute-converter/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/custom-attribute-converter/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/custom-attribute-converter/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/custom-attribute-converter/my-element.ts index 40810f9c3..2cbe7942d 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/custom-attribute-converter/my-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/custom-attribute-converter/my-element.ts @@ -1,5 +1,6 @@ -import { html, LitElement } from 'lit'; -import { customElement, property, state } from 'lit/decorators.js';import {ComplexAttributeConverter} from 'lit'; +import {html, LitElement} from 'lit'; +import {customElement, property, state} from 'lit/decorators.js'; +import {ComplexAttributeConverter} from 'lit'; /** * Bidirectionally converts an array from an attribute to a property of the @@ -17,17 +18,15 @@ export const arrayConverter: ComplexAttributeConverter> = { } catch { return []; } - } + }, }; @customElement('my-element') export class MyElement extends LitElement { - @property({ converter: arrayConverter, reflect: true }) - array: Array = []; + @property({converter: arrayConverter, reflect: true}) + array: Array = []; render() { - return this.array.map((item) => - html`
${typeof item}: ${item}
` - ); + return this.array.map((item) => html`
${typeof item}: ${item}
`); } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/game-player.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/game-player.ts index fdfdab6a8..cf8d0f3e4 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/game-player.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/game-player.ts @@ -1,5 +1,5 @@ -import { html, LitElement } from 'lit'; -import { customElement } from 'lit/decorators.js'; +import {html, LitElement} from 'lit'; +import {customElement} from 'lit/decorators.js'; export type ScoreEvent = CustomEvent; @@ -13,6 +13,8 @@ export class GamePlayer extends LitElement { } handleScore(points: number) { - this.dispatchEvent(new CustomEvent('score', { detail: points, bubbles: true })); + this.dispatchEvent( + new CustomEvent('score', {detail: points, bubbles: true}), + ); } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/index.html index 0e004d712..bffc611c4 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/score-board.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/score-board.ts index 6a8d3dd36..07a611d27 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/score-board.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/score-board.ts @@ -1,5 +1,5 @@ -import { html, LitElement } from 'lit'; -import { customElement, state } from 'lit/decorators.js'; +import {html, LitElement} from 'lit'; +import {customElement, state} from 'lit/decorators.js'; import './game-player.js'; import type {ScoreEvent} from './game-player.js'; @@ -12,9 +12,13 @@ export class ScoreBoard extends LitElement { return html`

${this.playerOneScore} - ${this.playerTwoScore}

Player 1

- this.playerOneScore += e.detail}> + (this.playerOneScore += e.detail)} + >

Player 2

- this.playerTwoScore += e.detail}> + (this.playerTwoScore += e.detail)} + > `; } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/define/hello-world.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/define/hello-world.ts index b4f5ba4d5..51799b93b 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/define/hello-world.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/define/hello-world.ts @@ -1,9 +1,9 @@ -import { html, LitElement } from 'lit'; -import { customElement } from 'lit/decorators.js'; +import {html, LitElement} from 'lit'; +import {customElement} from 'lit/decorators.js'; @customElement('hello-world') export class HelloWorld extends LitElement { render() { return html`

Hello, world!

`; } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/define/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/define/index.html index c53974764..be6dad253 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/define/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/define/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/derived-state/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/derived-state/index.html index 57a0c9aca..9a1b15c74 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/derived-state/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/derived-state/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/derived-state/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/derived-state/my-element.ts index 02705851a..437af20fc 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/derived-state/my-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/derived-state/my-element.ts @@ -1,5 +1,5 @@ -import { html, LitElement } from 'lit'; -import { customElement, state } from 'lit/decorators.js'; +import {html, LitElement} from 'lit'; +import {customElement, state} from 'lit/decorators.js'; @customElement('my-element') export class MyElement extends LitElement { diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-qae/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-qae/index.html index e44dfda1c..eac65a81c 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-qae/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-qae/index.html @@ -1,5 +1,5 @@ - + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-qae/my-pretty-input.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-qae/my-pretty-input.ts index 26ba98f12..96634823c 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-qae/my-pretty-input.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-qae/my-pretty-input.ts @@ -1,5 +1,10 @@ -import { html, LitElement, css } from 'lit'; -import { customElement, property, queryAssignedElements, state } from 'lit/decorators.js'; +import {html, LitElement, css} from 'lit'; +import { + customElement, + property, + queryAssignedElements, + state, +} from 'lit/decorators.js'; @customElement('my-pretty-input') export class MyPrettyInput extends LitElement { @@ -43,24 +48,28 @@ export class MyPrettyInput extends LitElement { // get the array of assigned elements and pick the first one const input = this.inputs[0]; - input?.animate?.([ - { 'transform': 'scale(1)', easing: 'ease-out' }, - { 'transform': 'scale(2)', easing: 'ease-in' }, - { 'transform': 'scale(1)' } - ], - 1000); + input?.animate?.( + [ + {transform: 'scale(1)', easing: 'ease-out'}, + {transform: 'scale(2)', easing: 'ease-in'}, + {transform: 'scale(1)'}, + ], + 1000, + ); }; #onInputBlur = () => { this.inputFocused = false; const input = this.inputs[0]; - input?.animate?.([ - { 'transform': 'scale(1)', easing: 'ease-out' }, - { 'transform': 'scale(.75)', easing: 'ease-in' }, - { 'transform': 'scale(1)' } - ], - 1000); + input?.animate?.( + [ + {transform: 'scale(1)', easing: 'ease-out'}, + {transform: 'scale(.75)', easing: 'ease-in'}, + {transform: 'scale(1)'}, + ], + 1000, + ); }; #clearListeners() { @@ -72,7 +81,8 @@ export class MyPrettyInput extends LitElement { this.#lastInput = null; } - static styles = css`/* playground-fold */ + static styles = css` + /* playground-fold */ canvas { border: 1px solid black; } @@ -81,5 +91,6 @@ export class MyPrettyInput extends LitElement { display: block; margin-block-start: 1em; } - /* playground-fold-end */`; + /* playground-fold-end */ + `; } diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query-async/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query-async/index.html index 57a0c9aca..9a1b15c74 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query-async/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query-async/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query-async/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query-async/my-element.ts index 13e84b3a0..23f7b3f42 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query-async/my-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query-async/my-element.ts @@ -1,12 +1,12 @@ -import { html, LitElement, css, PropertyValues } from 'lit'; -import { customElement, state, property, queryAsync } from 'lit/decorators.js'; +import {html, LitElement, css, PropertyValues} from 'lit'; +import {customElement, state, property, queryAsync} from 'lit/decorators.js'; @customElement('my-element') export class MyElement extends LitElement { @property({type: Boolean}) showCanvas = false; @state() private canvasText = 'Hello World!'; // You can use any querySelector selector - @queryAsync('#canvasId') private canvasEl!: Promise; + @queryAsync('#canvasId') private canvasEl!: Promise; protected update(changed: PropertyValues) { if (changed.has('showCanvas')) { @@ -19,14 +19,14 @@ export class MyElement extends LitElement { render() { return html` - ${ - this.showCanvas ? - html`` : - html`` - } + ${this.showCanvas + ? html`` + : html``} `; } @@ -40,22 +40,23 @@ export class MyElement extends LitElement { return; } - const ctx = canvasEl?.getContext("2d"); + const ctx = canvasEl?.getContext('2d'); if (!ctx) { return; } ctx.clearRect(0, 0, canvasEl.width, canvasEl.height); - ctx.font = "50px Arial"; - ctx.fillText(this.canvasText,10,80); + ctx.font = '50px Arial'; + ctx.fillText(this.canvasText, 10, 80); } private handleInput(event: Event) { this.setCanvasText((event.target as HTMLInputElement).value); } - static styles = css`/* playground-fold */ + static styles = css` + /* playground-fold */ canvas { border: 1px solid black; } @@ -64,5 +65,6 @@ export class MyElement extends LitElement { display: block; margin-block-start: 1em; } - /* playground-fold-end */`; + /* playground-fold-end */ + `; } diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query/index.html index 57a0c9aca..9a1b15c74 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query/my-element.ts index 94f5b06af..141a000da 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query/my-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query/my-element.ts @@ -1,5 +1,5 @@ -import { html, LitElement, css } from 'lit'; -import { customElement, state, query } from 'lit/decorators.js'; +import {html, LitElement, css} from 'lit'; +import {customElement, state, query} from 'lit/decorators.js'; @customElement('my-element') export class MyElement extends LitElement { @@ -12,7 +12,7 @@ export class MyElement extends LitElement { `; } @@ -20,15 +20,15 @@ export class MyElement extends LitElement { private setCanvasText(text: string) { this.canvasText = text; // Access the canvas element with this.canvasEl - const ctx = this.canvasEl.getContext("2d"); + const ctx = this.canvasEl.getContext('2d'); if (!ctx) { return; } ctx.clearRect(0, 0, this.canvasEl.width, this.canvasEl.height); - ctx.font = "50px Arial"; - ctx.fillText(this.canvasText,10,80); + ctx.font = '50px Arial'; + ctx.fillText(this.canvasText, 10, 80); } private handleInput(event: Event) { @@ -40,7 +40,8 @@ export class MyElement extends LitElement { this.setCanvasText(this.canvasText); } - static styles = css`/* playground-fold */ + static styles = css` + /* playground-fold */ canvas { border: 1px solid black; } @@ -49,5 +50,6 @@ export class MyElement extends LitElement { display: block; margin-block-start: 1em; } - /* playground-fold-end */`; + /* playground-fold-end */ + `; } diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-ref/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-ref/index.html index 57a0c9aca..9a1b15c74 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-ref/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-ref/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-ref/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-ref/my-element.ts index 398013904..08ead3187 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-ref/my-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-ref/my-element.ts @@ -1,6 +1,6 @@ -import { html, LitElement, css } from 'lit'; -import { customElement, state } from 'lit/decorators.js'; -import { ref, createRef } from 'lit/directives/ref.js'; +import {html, LitElement, css} from 'lit'; +import {customElement, state} from 'lit/decorators.js'; +import {ref, createRef} from 'lit/directives/ref.js'; @customElement('my-element') export class MyElement extends LitElement { @@ -12,7 +12,7 @@ export class MyElement extends LitElement { `; } @@ -23,15 +23,20 @@ export class MyElement extends LitElement { } this.canvasText = text; // Access the canvas element with this.canvasEl - const ctx = this.canvasRef.value.getContext("2d"); + const ctx = this.canvasRef.value.getContext('2d'); if (!ctx) { return; } - ctx.clearRect(0, 0, this.canvasRef.value.width, this.canvasRef.value.height); - ctx.font = "50px Arial"; - ctx.fillText(this.canvasText,10,80); + ctx.clearRect( + 0, + 0, + this.canvasRef.value.width, + this.canvasRef.value.height, + ); + ctx.font = '50px Arial'; + ctx.fillText(this.canvasText, 10, 80); } private handleInput(event: Event) { @@ -43,7 +48,8 @@ export class MyElement extends LitElement { this.setCanvasText(this.canvasText); } - static styles = css`/* playground-fold */ + static styles = css` + /* playground-fold */ canvas { border: 1px solid black; } @@ -52,5 +58,6 @@ export class MyElement extends LitElement { display: block; margin-block-start: 1em; } - /* playground-fold-end */`; + /* playground-fold-end */ + `; } diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/event-listeners/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/event-listeners/index.html index 57a0c9aca..9a1b15c74 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/event-listeners/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/event-listeners/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/event-listeners/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/event-listeners/my-element.ts index 33d8c1696..a04f3dcb9 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/event-listeners/my-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/event-listeners/my-element.ts @@ -1,5 +1,5 @@ -import { html, LitElement } from 'lit'; -import { customElement, query, state } from 'lit/decorators.js'; +import {html, LitElement} from 'lit'; +import {customElement, query, state} from 'lit/decorators.js'; @customElement('my-element') export class MyElement extends LitElement { diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/another-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/another-element.ts index 05456dd5d..890008c27 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/another-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/another-element.ts @@ -1,5 +1,5 @@ -import { html, LitElement, css } from 'lit'; -import { customElement } from 'lit/decorators.js'; +import {html, LitElement, css} from 'lit'; +import {customElement} from 'lit/decorators.js'; @customElement('another-element') export class AnotherElement extends LitElement { @@ -9,4 +9,4 @@ export class AnotherElement extends LitElement {
Part 2
`; } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/index.html index 09a583b4e..db7e424a3 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/index.html @@ -9,4 +9,4 @@ } - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/my-element.ts index f13ab63c8..ed21a7250 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/my-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/my-element.ts @@ -1,10 +1,12 @@ -import { html, LitElement, css } from 'lit'; -import { customElement } from 'lit/decorators.js'; +import {html, LitElement, css} from 'lit'; +import {customElement} from 'lit/decorators.js'; import './another-element.js'; @customElement('my-element') export class MyElement extends LitElement { render() { - return html``; + return html``; } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/expressions/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/expressions/index.html index 57a0c9aca..9a1b15c74 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/expressions/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/expressions/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/expressions/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/expressions/my-element.ts index 61e34ff7a..17e73eee7 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/expressions/my-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/expressions/my-element.ts @@ -1,5 +1,5 @@ -import { css, html, LitElement, PropertyValues } from 'lit'; -import { customElement, query, state } from 'lit/decorators.js'; +import {css, html, LitElement, PropertyValues} from 'lit'; +import {customElement, query, state} from 'lit/decorators.js'; @customElement('my-element') export class MyElement extends LitElement { @@ -14,7 +14,8 @@ export class MyElement extends LitElement { + .value=${this.value} + />
Renders to:
${this.htmlText}
@@ -25,20 +26,26 @@ export class MyElement extends LitElement { disabled: (this.disabled = (e.target as HTMLInputElement).checked)} - .checked=${this.disabled}> + @change=${(e: Event) => + (this.disabled = (e.target as HTMLInputElement).checked)} + .checked=${this.disabled} + />
@@ -52,10 +59,10 @@ export class MyElement extends LitElement { } static styles = css` - /* playground-fold */ + /* playground-fold */ label { display: block; } - /* playground-fold-end */ + /* playground-fold-end */ `; -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/global-listeners/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/global-listeners/index.html index f03ab07ca..3859cca22 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/global-listeners/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/global-listeners/index.html @@ -1,4 +1,4 @@

Click either inside or outside this component with a box border

- \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/global-listeners/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/global-listeners/my-element.ts index 5f575d42e..92d236477 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/global-listeners/my-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/global-listeners/my-element.ts @@ -1,5 +1,5 @@ -import { html, LitElement, isServer, css } from 'lit'; -import { customElement, state } from 'lit/decorators.js'; +import {html, LitElement, isServer, css} from 'lit'; +import {customElement, state} from 'lit/decorators.js'; @customElement('my-element') export class MyElement extends LitElement { @@ -7,8 +7,12 @@ export class MyElement extends LitElement { render() { return html` - ${!this.clickedOutside ? html`

Something was clicked INSIDE this component

` : ''} - ${this.clickedOutside ? html`

Something was clicked OUTSIDE this component

` : ''} + ${!this.clickedOutside + ? html`

Something was clicked INSIDE this component

` + : ''} + ${this.clickedOutside + ? html`

Something was clicked OUTSIDE this component

` + : ''} `; } @@ -38,11 +42,13 @@ export class MyElement extends LitElement { this.clickedOutside = !path.includes(this); }; - static styles = css`/* playground-fold */ + static styles = css` + /* playground-fold */ :host { display: inline-flex; border: 1px solid black; } - /* playground-fold-end */`; -} \ No newline at end of file + /* playground-fold-end */ + `; +} diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/host-listeners/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/host-listeners/index.html index 57a0c9aca..9a1b15c74 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/host-listeners/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/host-listeners/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/host-listeners/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/host-listeners/my-element.ts index e961fc484..f69bb69aa 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/host-listeners/my-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/host-listeners/my-element.ts @@ -1,5 +1,5 @@ -import { html, LitElement, isServer } from 'lit'; -import { customElement, state } from 'lit/decorators.js'; +import {html, LitElement, isServer} from 'lit'; +import {customElement, state} from 'lit/decorators.js'; @customElement('my-element') export class MyElement extends LitElement { @@ -8,7 +8,9 @@ export class MyElement extends LitElement { render() { return html` - ${this.focusedWithin ? html`

Something in this component was focused

` : ''} + ${this.focusedWithin + ? html`

Something in this component was focused

` + : ''} `; } @@ -30,4 +32,4 @@ export class MyElement extends LitElement { #onFocusout() { this.focusedWithin = false; } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import-attributes/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import-attributes/index.html index 57a0c9aca..9a1b15c74 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import-attributes/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import-attributes/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import-attributes/my-element.js b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import-attributes/my-element.js index 952c50945..ae778504a 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import-attributes/my-element.js +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import-attributes/my-element.js @@ -1,15 +1,11 @@ -import { html, LitElement } from 'lit'; -import styles from './styles.css' with { type: 'css' }; +import {html, LitElement} from 'lit'; +import styles from './styles.css' with {type: 'css'}; export class MyElement extends LitElement { static styles = styles; render() { - return html` -
- This should be red! -
- `; + return html`
This should be red!
`; } } diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/another-component.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/another-component.ts index 8e2671b95..30f7e44dd 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/another-component.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/another-component.ts @@ -1,9 +1,9 @@ -import { html, LitElement } from 'lit'; -import { customElement } from 'lit/decorators.js'; +import {html, LitElement} from 'lit'; +import {customElement} from 'lit/decorators.js'; @customElement('another-component') export class AnotherComponent extends LitElement { render() { return html`(I'm another component.)`; } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/hello-world.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/hello-world.ts index de5f2dccf..703e9859a 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/hello-world.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/hello-world.ts @@ -1,10 +1,10 @@ -import { html, LitElement } from 'lit'; -import { customElement } from 'lit/decorators.js'; -import './another-component.js' +import {html, LitElement} from 'lit'; +import {customElement} from 'lit/decorators.js'; +import './another-component.js'; @customElement('hello-world') export class HelloWorld extends LitElement { render() { return html`Hello, world! `; } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/index.html index c53974764..be6dad253 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/inheriting-custom-props/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/inheriting-custom-props/index.html index 5b273eb5d..af12c60f1 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/inheriting-custom-props/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/inheriting-custom-props/index.html @@ -18,4 +18,4 @@
-
\ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/inheriting-custom-props/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/inheriting-custom-props/my-element.ts index f6ed8d2d6..d5e60dadf 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/inheriting-custom-props/my-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/inheriting-custom-props/my-element.ts @@ -1,5 +1,5 @@ -import { html, LitElement, css } from 'lit'; -import { customElement } from 'lit/decorators.js'; +import {html, LitElement, css} from 'lit'; +import {customElement} from 'lit/decorators.js'; @customElement('my-element') export class MyElement extends LitElement { @@ -14,4 +14,4 @@ export class MyElement extends LitElement { render() { return html`

This is in a shadow root!

`; } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/id-card.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/id-card.ts index b7a427e95..d7270029a 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/id-card.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/id-card.ts @@ -1,20 +1,20 @@ -import { html, LitElement } from 'lit'; -import { customElement, property } from 'lit/decorators.js'; +import {html, LitElement} from 'lit'; +import {customElement, property} from 'lit/decorators.js'; @customElement('id-card') export class IdCard extends LitElement { @property() name = ''; - @property({ type: Number }) age = 0; - @property({ type: Boolean }) programmer = false; + @property({type: Number}) age = 0; + @property({type: Boolean}) programmer = false; render() { return html`

${this.name}

Age: ${this.age}

`; } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/index.html index d5f0f24d5..f07c80f59 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/my-wallet.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/my-wallet.ts index 0159d6911..e97a5cb10 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/my-wallet.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/my-wallet.ts @@ -1,12 +1,12 @@ -import { html, LitElement } from 'lit'; -import { customElement } from 'lit/decorators.js'; +import {html, LitElement} from 'lit'; +import {customElement} from 'lit/decorators.js'; import './id-card.js'; @customElement('my-wallet') export class MyWallet extends LitElement { render() { return html` - + `; } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/id-card.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/id-card.ts index 0feccc9d3..29cc9a9a9 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/id-card.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/id-card.ts @@ -1,30 +1,30 @@ -import { html, LitElement } from 'lit'; -import { customElement, property } from 'lit/decorators.js'; +import {html, LitElement} from 'lit'; +import {customElement, property} from 'lit/decorators.js'; @customElement('id-card') export class IdCard extends LitElement { // Default attribute converter is string @property() name = ''; // Number attribute converter converts attribtues to numbers - @property({ type: Number }) age = 0; + @property({type: Number}) age = 0; // Boolean attribute converter converts attribtues to boolean using // .hasAttribute(). NOTE: boolean-attribute="false" will result in `true` - @property({ type: Boolean }) programmer = false; + @property({type: Boolean}) programmer = false; // You can also specify the attribute name - @property({ type: Boolean, attribute: 'is-cool' }) isCool = false; + @property({type: Boolean, attribute: 'is-cool'}) isCool = false; render() { return html`

${this.name}

Age: ${this.age}

`; } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/index.html index d5f0f24d5..f07c80f59 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/my-wallet.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/my-wallet.ts index b88d3de0e..cacd8014d 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/my-wallet.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/my-wallet.ts @@ -1,12 +1,17 @@ -import { html, LitElement } from 'lit'; -import { customElement } from 'lit/decorators.js'; +import {html, LitElement} from 'lit'; +import {customElement} from 'lit/decorators.js'; import './id-card.js'; @customElement('my-wallet') export class MyWallet extends LitElement { render() { return html` - +
Toggle fancy button active state
@@ -35,10 +42,9 @@ export class MyButton extends LitElement { /* playground-fold */ #toggleActive(e: InputEvent) { - this.active = (e.target as HTMLInputElement).checked + this.active = (e.target as HTMLInputElement).checked; } - constructor() { super(); (MyButton.styles as any).replaceSync(getPluginStyles()); diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/update-complete/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/update-complete/index.html index 57a0c9aca..9a1b15c74 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/update-complete/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/update-complete/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/update-complete/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/update-complete/my-element.ts index 9a1cddb7d..7340838bd 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/update-complete/my-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/update-complete/my-element.ts @@ -1,5 +1,5 @@ -import { css, html, LitElement } from 'lit'; -import { customElement, query, state } from 'lit/decorators.js'; +import {css, html, LitElement} from 'lit'; +import {customElement, query, state} from 'lit/decorators.js'; import {styleMap} from 'lit/directives/style-map.js'; @customElement('my-element') diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/virtualizer/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/virtualizer/index.html index 57a0c9aca..9a1b15c74 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/virtualizer/index.html +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/virtualizer/index.html @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/virtualizer/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/virtualizer/my-element.ts index 8161cfaaf..dea9e13da 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/virtualizer/my-element.ts +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/virtualizer/my-element.ts @@ -14,8 +14,9 @@ export class MyItems extends LitElement { have the lit-virtualizer element as a wrapper --> html`
  • ${i.text}
  • `}> + .items=${this.data} + .renderItem=${(i: {text: string}) => html`
  • ${i.text}
  • `} + >
    `; diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/with-logger.json b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/with-logger.json index 20ba04f9a..802d336ab 100644 --- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/with-logger.json +++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/with-logger.json @@ -6,4 +6,4 @@ "content": "import {LitElement, html, css} from 'lit';\nimport {customElement} from 'lit/decorators.js';\nimport {SignalWatcher, signal, watch} from '@lit-labs/signals';\n\nconst log = signal([]);\n\nconst oldLog = window.console.log\nwindow.console.log = (...values: unknown[]) => {\n log.set([...log.get(), values]);\n oldLog(...values)\n};\n\nconst globalStyles = new CSSStyleSheet();\n\nglobalStyles.replaceSync(`body {\n display: flex;\n}\n \nbody > * {\n flex: 1\n}`)\n\ndocument.adoptedStyleSheets.push(globalStyles);\n\n@customElement('visual-logger')\nexport class MyElement extends SignalWatcher(LitElement) {\n render() {\n return html`\n
    \n Log:\n
    \n ${log.get().toReversed().map(val => html`

    ${val.join(' ')}

    `)}\n
    \n `;\n }\n \n static styles = css`\n #log {\n display: block;\n max-height: 100dvh;\n }\n \n p {\n margin: 0;\n font-family: monospace;\n }\n `;\n}" } } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/examples/async-task/index.html b/packages/lit-dev-content/samples/examples/async-task/index.html index 8099c92be..c1262ffc1 100644 --- a/packages/lit-dev-content/samples/examples/async-task/index.html +++ b/packages/lit-dev-content/samples/examples/async-task/index.html @@ -1,5 +1,7 @@ diff --git a/packages/lit-dev-content/samples/examples/async-task/npm-info.ts b/packages/lit-dev-content/samples/examples/async-task/npm-info.ts index 5175f0b5f..8da47aeff 100644 --- a/packages/lit-dev-content/samples/examples/async-task/npm-info.ts +++ b/packages/lit-dev-content/samples/examples/async-task/npm-info.ts @@ -54,13 +54,13 @@ export class NpmInfo extends LitElement {
      ${map( Object.entries(pkg['dist-tags']), - ([tag, version]) => html`
    • ${tag}: ${version}
    • ` + ([tag, version]) => + html`
    • ${tag}: ${version}
    • `, )}
    `, - error: (e) => html` - Error: ${(e as Error).message} - `, + error: (e) => + html` Error: ${(e as Error).message} `, })} `; diff --git a/packages/lit-dev-content/samples/examples/async-task/npm.ts b/packages/lit-dev-content/samples/examples/async-task/npm.ts index dc8311a73..57859d9a3 100644 --- a/packages/lit-dev-content/samples/examples/async-task/npm.ts +++ b/packages/lit-dev-content/samples/examples/async-task/npm.ts @@ -5,7 +5,7 @@ export interface NpmPackage { export const fetchPackageInfo = async ( pkgName: string, - signal: AbortSignal + signal: AbortSignal, ): Promise => { // Artificial delay for demo purposes await new Promise((r) => setTimeout(r, 1000)); diff --git a/packages/lit-dev-content/samples/examples/context-basics/index.html b/packages/lit-dev-content/samples/examples/context-basics/index.html index f67442dfe..6463c58f2 100644 --- a/packages/lit-dev-content/samples/examples/context-basics/index.html +++ b/packages/lit-dev-content/samples/examples/context-basics/index.html @@ -1,4 +1,4 @@ - + diff --git a/packages/lit-dev-content/samples/examples/directive-async-append/my-element.ts b/packages/lit-dev-content/samples/examples/directive-async-append/my-element.ts index 039c47be5..a7bedb929 100644 --- a/packages/lit-dev-content/samples/examples/directive-async-append/my-element.ts +++ b/packages/lit-dev-content/samples/examples/directive-async-append/my-element.ts @@ -2,8 +2,8 @@ import {LitElement, html} from 'lit'; import {customElement, state} from 'lit/decorators.js'; import {asyncAppend} from 'lit/directives/async-append.js'; -async function *tossCoins(count: number) { - for (let i=0; i 0.5 ? 'Heads' : 'Tails'; await new Promise((r) => setTimeout(r, 1000)); } @@ -11,12 +11,12 @@ async function *tossCoins(count: number) { @customElement('my-element') class MyElement extends LitElement { - @state() private tosses = tossCoins(10); render() { - return html` -
      ${asyncAppend(this.tosses, (v) => html`
    • ${v}
    • `)}
    `; + return html`
      + ${asyncAppend(this.tosses, (v) => html`
    • ${v}
    • `)} +
    `; } } diff --git a/packages/lit-dev-content/samples/examples/directive-async-replace/index.html b/packages/lit-dev-content/samples/examples/directive-async-replace/index.html index fe1517255..f149c266f 100644 --- a/packages/lit-dev-content/samples/examples/directive-async-replace/index.html +++ b/packages/lit-dev-content/samples/examples/directive-async-replace/index.html @@ -1,5 +1,7 @@ diff --git a/packages/lit-dev-content/samples/examples/directive-async-replace/my-element.ts b/packages/lit-dev-content/samples/examples/directive-async-replace/my-element.ts index 9b8f33cf7..54c30dfc5 100644 --- a/packages/lit-dev-content/samples/examples/directive-async-replace/my-element.ts +++ b/packages/lit-dev-content/samples/examples/directive-async-replace/my-element.ts @@ -2,7 +2,7 @@ import {LitElement, html} from 'lit'; import {customElement, state} from 'lit/decorators.js'; import {asyncReplace} from 'lit/directives/async-replace.js'; -async function *countDown(count: number) { +async function* countDown(count: number) { while (count > 0) { yield count--; await new Promise((r) => setTimeout(r, 1000)); @@ -11,7 +11,6 @@ async function *countDown(count: number) { @customElement('my-element') class MyElement extends LitElement { - @state() private timer = countDown(10); diff --git a/packages/lit-dev-content/samples/examples/directive-cache/index.html b/packages/lit-dev-content/samples/examples/directive-cache/index.html index fe1517255..f149c266f 100644 --- a/packages/lit-dev-content/samples/examples/directive-cache/index.html +++ b/packages/lit-dev-content/samples/examples/directive-cache/index.html @@ -1,5 +1,7 @@ diff --git a/packages/lit-dev-content/samples/examples/directive-cache/my-element.ts b/packages/lit-dev-content/samples/examples/directive-cache/my-element.ts index daa6e64ca..3ee0b1748 100644 --- a/packages/lit-dev-content/samples/examples/directive-cache/my-element.ts +++ b/packages/lit-dev-content/samples/examples/directive-cache/my-element.ts @@ -2,12 +2,11 @@ import {LitElement, html} from 'lit'; import {customElement, property} from 'lit/decorators.js'; import {cache} from 'lit/directives/cache.js'; -const view1 = () => html`View 1: `; -const view2 = () => html`View 2: `; +const view1 = () => html`View 1: `; +const view2 = () => html`View 2: `; @customElement('my-element') export class MyElement extends LitElement { - @property({type: Number}) selectedView = 1; @@ -15,12 +14,14 @@ export class MyElement extends LitElement { return html`

    cache directive example

    -
    + +
    - Un-cached (DOM re-created when template re-rendered):
    - ${this.selectedView == 1 ? view1() : view2()}
    + Un-cached (DOM re-created when template re-rendered):
    + ${this.selectedView == 1 ? view1() : view2()} +
    - Cached (DOM cached and re-used when template re-rendered):
    + Cached (DOM cached and re-used when template re-rendered):
    ${cache(this.selectedView == 1 ? view1() : view2())} `; } diff --git a/packages/lit-dev-content/samples/examples/directive-class-map/index.html b/packages/lit-dev-content/samples/examples/directive-class-map/index.html index fe1517255..f149c266f 100644 --- a/packages/lit-dev-content/samples/examples/directive-class-map/index.html +++ b/packages/lit-dev-content/samples/examples/directive-class-map/index.html @@ -1,5 +1,7 @@ diff --git a/packages/lit-dev-content/samples/examples/directive-class-map/my-element.ts b/packages/lit-dev-content/samples/examples/directive-class-map/my-element.ts index 0098c9539..1c4644e66 100644 --- a/packages/lit-dev-content/samples/examples/directive-class-map/my-element.ts +++ b/packages/lit-dev-content/samples/examples/directive-class-map/my-element.ts @@ -4,7 +4,6 @@ import {classMap} from 'lit/directives/class-map.js'; @customElement('my-element') export class MyElement extends LitElement { - static styles = css` .enabled { background: lightgreen; @@ -27,19 +26,27 @@ export class MyElement extends LitElement { const classes = { enabled: this.enabled, hidden: this.hidden, - padded: true + padded: true, }; return html`

    classMap directive example

    Classy text
    -
    +
    `; diff --git a/packages/lit-dev-content/samples/examples/directive-guard/calculate-sha.ts b/packages/lit-dev-content/samples/examples/directive-guard/calculate-sha.ts index 94a72ff04..b529b2fbd 100644 --- a/packages/lit-dev-content/samples/examples/directive-guard/calculate-sha.ts +++ b/packages/lit-dev-content/samples/examples/directive-guard/calculate-sha.ts @@ -5,7 +5,9 @@ async function sha256(message: string) { const msgBuffer = new TextEncoder().encode(message); const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer); const hashArray = Array.from(new Uint8Array(hashBuffer)); - const hashHex = hashArray.map(b => ('00' + b.toString(16)).slice(-2)).join(''); + const hashHex = hashArray + .map((b) => ('00' + b.toString(16)).slice(-2)) + .join(''); // Add some artificial delay for demo purposes... await new Promise((r) => setTimeout(() => r(), 1000)); return hashHex; @@ -13,4 +15,4 @@ async function sha256(message: string) { export const calculateSHA = (value: string) => { return until(sha256(value), 'Calculating sha...'); -} +}; diff --git a/packages/lit-dev-content/samples/examples/directive-guard/index.html b/packages/lit-dev-content/samples/examples/directive-guard/index.html index fe1517255..f149c266f 100644 --- a/packages/lit-dev-content/samples/examples/directive-guard/index.html +++ b/packages/lit-dev-content/samples/examples/directive-guard/index.html @@ -1,5 +1,7 @@ diff --git a/packages/lit-dev-content/samples/examples/directive-guard/my-element.ts b/packages/lit-dev-content/samples/examples/directive-guard/my-element.ts index ca0461a70..f3736f206 100644 --- a/packages/lit-dev-content/samples/examples/directive-guard/my-element.ts +++ b/packages/lit-dev-content/samples/examples/directive-guard/my-element.ts @@ -5,7 +5,6 @@ import {calculateSHA} from './calculate-sha.js'; @customElement('my-element') export class MyElement extends LitElement { - @state() private value: string = 'test string'; @@ -19,15 +18,17 @@ export class MyElement extends LitElement { return html`

    guard directive example

    - -
    + +
    The SHA for '${this.value}' is:
    ${guard([this.value], () => calculateSHA(this.value))}
    -
    +
    - Incrementing the counter does not recalculate SHA:
    - + Incrementing the counter does not recalculate SHA:
    + `; } diff --git a/packages/lit-dev-content/samples/examples/directive-if-defined/index.html b/packages/lit-dev-content/samples/examples/directive-if-defined/index.html index fe1517255..f149c266f 100644 --- a/packages/lit-dev-content/samples/examples/directive-if-defined/index.html +++ b/packages/lit-dev-content/samples/examples/directive-if-defined/index.html @@ -1,5 +1,7 @@ diff --git a/packages/lit-dev-content/samples/examples/directive-if-defined/my-element.ts b/packages/lit-dev-content/samples/examples/directive-if-defined/my-element.ts index 87d5e933b..153b711f4 100644 --- a/packages/lit-dev-content/samples/examples/directive-if-defined/my-element.ts +++ b/packages/lit-dev-content/samples/examples/directive-if-defined/my-element.ts @@ -3,16 +3,15 @@ import {customElement, state, query} from 'lit/decorators.js'; import {ifDefined} from 'lit/directives/if-defined.js'; const imageInfo = { - 'beach': { domain: 'picsum.photos', id: 100 }, - 'river': { domain: 'picsum.photos', id: 1015 }, - 'canyon': { domain: 'picsum.photos', id: 1016 }, + beach: {domain: 'picsum.photos', id: 100}, + river: {domain: 'picsum.photos', id: 1015}, + canyon: {domain: 'picsum.photos', id: 1016}, }; type ImageKey = keyof typeof imageInfo; @customElement('my-element') class MyElement extends LitElement { - @state() private imageName: ImageKey = 'beach'; @@ -26,14 +25,20 @@ class MyElement extends LitElement { return html`

    ifDefined directive example

    - Type one of 'beach', 'river', or 'canyon':
    -
    + Type one of 'beach', 'river', or 'canyon':
    + +
    - Using ifDefined (src removed when undefined):
    -
    + Using ifDefined (src removed when undefined):
    + +
    - Without ifDefined (will 404 when undefined):
    - + Without ifDefined (will 404 when undefined):
    + `; } diff --git a/packages/lit-dev-content/samples/examples/directive-live/index.html b/packages/lit-dev-content/samples/examples/directive-live/index.html index fe1517255..f149c266f 100644 --- a/packages/lit-dev-content/samples/examples/directive-live/index.html +++ b/packages/lit-dev-content/samples/examples/directive-live/index.html @@ -1,5 +1,7 @@ diff --git a/packages/lit-dev-content/samples/examples/directive-live/my-element.ts b/packages/lit-dev-content/samples/examples/directive-live/my-element.ts index 165ba2f2b..0b8e7595d 100644 --- a/packages/lit-dev-content/samples/examples/directive-live/my-element.ts +++ b/packages/lit-dev-content/samples/examples/directive-live/my-element.ts @@ -4,7 +4,6 @@ import {live} from 'lit/directives/live.js'; @customElement('my-element') class MyElement extends LitElement { - @state() private data = {value: 'test'}; @@ -12,19 +11,23 @@ class MyElement extends LitElement { private input!: HTMLInputElement; render() { - return html`

    live directive example

    - Set this value to the inputs below.
    - -
    + Set this value to the inputs below.
    + + +
    - With live: will update if out of sync with last rendered value
    -
    + With live: will update if out of sync with last rendered value
    + +
    - Without live: will not update if out of sync with last rendered value
    - + Without live: will not update if out of sync with last rendered value
    + `; } diff --git a/packages/lit-dev-content/samples/examples/directive-ref/index.html b/packages/lit-dev-content/samples/examples/directive-ref/index.html index fe1517255..f149c266f 100644 --- a/packages/lit-dev-content/samples/examples/directive-ref/index.html +++ b/packages/lit-dev-content/samples/examples/directive-ref/index.html @@ -1,5 +1,7 @@ diff --git a/packages/lit-dev-content/samples/examples/directive-ref/my-element.ts b/packages/lit-dev-content/samples/examples/directive-ref/my-element.ts index f4c9172e3..0ac1b866b 100644 --- a/packages/lit-dev-content/samples/examples/directive-ref/my-element.ts +++ b/packages/lit-dev-content/samples/examples/directive-ref/my-element.ts @@ -2,11 +2,13 @@ import {LitElement, html, css} from 'lit'; import {customElement} from 'lit/decorators.js'; import {ref, createRef} from 'lit/directives/ref.js'; -const loremIpsum = Array(100).fill(0).map(() => 'Lorem ipsum dolor sit amet.').join(' '); +const loremIpsum = Array(100) + .fill(0) + .map(() => 'Lorem ipsum dolor sit amet.') + .join(' '); @customElement('my-element') export class MyElement extends LitElement { - static styles = css` .scroll { height: 100px; @@ -20,10 +22,11 @@ export class MyElement extends LitElement { render() { return html` - Passing ref directive a Ref object that will hold the element in .value:
    - + Passing ref directive a Ref object that will hold the element in + .value:
    + -
    +
    Passing ref directive a change callback
    diff --git a/packages/lit-dev-content/samples/examples/directive-repeat/index.html b/packages/lit-dev-content/samples/examples/directive-repeat/index.html index fe1517255..f149c266f 100644 --- a/packages/lit-dev-content/samples/examples/directive-repeat/index.html +++ b/packages/lit-dev-content/samples/examples/directive-repeat/index.html @@ -1,5 +1,7 @@ diff --git a/packages/lit-dev-content/samples/examples/directive-repeat/my-element.ts b/packages/lit-dev-content/samples/examples/directive-repeat/my-element.ts index fe70722d3..dc7761c5f 100644 --- a/packages/lit-dev-content/samples/examples/directive-repeat/my-element.ts +++ b/packages/lit-dev-content/samples/examples/directive-repeat/my-element.ts @@ -4,15 +4,14 @@ import {repeat} from 'lit/directives/repeat.js'; @customElement('my-element') class MyElement extends LitElement { - @state() private items = [ - {id: 0, name: "Justin"}, - {id: 1, name: "Steve"}, - {id: 2, name: "Kevin"}, - {id: 3, name: "Russell"}, - {id: 4, name: "Liz"}, - {id: 5, name: "Peter"}, + {id: 0, name: 'Justin'}, + {id: 1, name: 'Steve'}, + {id: 2, name: 'Kevin'}, + {id: 3, name: 'Russell'}, + {id: 4, name: 'Liz'}, + {id: 5, name: 'Peter'}, ]; render() { @@ -20,24 +19,39 @@ class MyElement extends LitElement {

    repeat directive example

    -
    + +
    With keying (DOM including checkbox state moves with items):
      - ${repeat(this.items, (item) => item.id, (item, index) => html` -
    • ${index}:
    • `)} -

    + ${repeat( + this.items, + (item) => item.id, + (item, index) => + html`
  • + ${index}: +
  • `, + )} + +
    - Without keying (items are re-used in place, checkbox state does not change): + Without keying (items are re-used in place, checkbox state does not + change):
      - ${repeat(this.items, (item, index) => html` -
    • ${index}:
    • `)} + ${repeat( + this.items, + (item, index) => + html`
    • + ${index}: +
    • `, + )}
    - `; } private sort(dir: number) { - this.items = [...this.items.sort((a, b) => a.name.localeCompare(b.name) * dir)]; + this.items = [ + ...this.items.sort((a, b) => a.name.localeCompare(b.name) * dir), + ]; } } diff --git a/packages/lit-dev-content/samples/examples/directive-style-map/index.html b/packages/lit-dev-content/samples/examples/directive-style-map/index.html index fe1517255..f149c266f 100644 --- a/packages/lit-dev-content/samples/examples/directive-style-map/index.html +++ b/packages/lit-dev-content/samples/examples/directive-style-map/index.html @@ -1,5 +1,7 @@ diff --git a/packages/lit-dev-content/samples/examples/directive-style-map/my-element.ts b/packages/lit-dev-content/samples/examples/directive-style-map/my-element.ts index 15d04e340..a0d5690da 100644 --- a/packages/lit-dev-content/samples/examples/directive-style-map/my-element.ts +++ b/packages/lit-dev-content/samples/examples/directive-style-map/my-element.ts @@ -4,7 +4,6 @@ import {styleMap} from 'lit/directives/style-map.js'; @customElement('my-element') export class MyElement extends LitElement { - @property({type: Boolean}) enabled = true; @@ -15,19 +14,27 @@ export class MyElement extends LitElement { const styles = { backgroundColor: this.enabled ? 'lightgreen' : 'transparent', opacity: this.hidden ? '0.2' : '1', - padding: '10px' + padding: '10px', }; return html`

    styleMap directive example

    Hello style!

    -
    +
    `; diff --git a/packages/lit-dev-content/samples/examples/directive-template-content/index.html b/packages/lit-dev-content/samples/examples/directive-template-content/index.html index 557c74d07..c487c72a7 100644 --- a/packages/lit-dev-content/samples/examples/directive-template-content/index.html +++ b/packages/lit-dev-content/samples/examples/directive-template-content/index.html @@ -1,12 +1,14 @@ diff --git a/packages/lit-dev-content/samples/examples/directive-template-content/my-element.ts b/packages/lit-dev-content/samples/examples/directive-template-content/my-element.ts index 28a8f97d9..e8aaa7dff 100644 --- a/packages/lit-dev-content/samples/examples/directive-template-content/my-element.ts +++ b/packages/lit-dev-content/samples/examples/directive-template-content/my-element.ts @@ -3,13 +3,14 @@ import {customElement} from 'lit/decorators.js'; import {templateContent} from 'lit/directives/template-content.js'; // diff --git a/packages/lit-dev-content/samples/tutorials/wc-to-lit/07/before/rating-element.ts b/packages/lit-dev-content/samples/tutorials/wc-to-lit/07/before/rating-element.ts index 93a4a1cda..9451045d2 100644 --- a/packages/lit-dev-content/samples/tutorials/wc-to-lit/07/before/rating-element.ts +++ b/packages/lit-dev-content/samples/tutorials/wc-to-lit/07/before/rating-element.ts @@ -3,18 +3,25 @@ export class RatingElement extends HTMLElement { connectedCallback() { const shadowRoot = this.attachShadow({mode: 'open'}); - const templateContent = document.querySelector('#rating-element-template')!.content; + const templateContent = document.querySelector( + '#rating-element-template', + )!.content; const clonedContent = templateContent.cloneNode(true); shadowRoot.appendChild(clonedContent); - this.shadowRoot!.querySelector('.rating')!.innerText = `${this.rating}`; + this.shadowRoot!.querySelector('.rating')!.innerText = + `${this.rating}`; } static get observedAttributes() { return ['rating']; } - attributeChangedCallback(attributeName: string, _oldValue: string, newValue: string) { + attributeChangedCallback( + attributeName: string, + _oldValue: string, + newValue: string, + ) { if (attributeName === 'rating') { const newRating = Number(newValue); @@ -39,6 +46,6 @@ export class RatingElement extends HTMLElement { get rating() { return this._rating; } - } +} - customElements.define('rating-element', RatingElement); +customElements.define('rating-element', RatingElement); diff --git a/packages/lit-dev-content/samples/tutorials/wc-to-lit/08/before/index.html b/packages/lit-dev-content/samples/tutorials/wc-to-lit/08/before/index.html index dda519c33..e01611967 100644 --- a/packages/lit-dev-content/samples/tutorials/wc-to-lit/08/before/index.html +++ b/packages/lit-dev-content/samples/tutorials/wc-to-lit/08/before/index.html @@ -1,4 +1,4 @@ - + @@ -16,20 +16,38 @@ cursor: pointer; } - :host([vote=up]) .thumb_up { + :host([vote='up']) .thumb_up { fill: green; } - :host([vote=down]) .thumb_down { + :host([vote='down']) .thumb_down { fill: red; } - diff --git a/packages/lit-dev-content/samples/tutorials/wc-to-lit/08/before/rating-element.ts b/packages/lit-dev-content/samples/tutorials/wc-to-lit/08/before/rating-element.ts index c7c2c08bf..ede55f72a 100644 --- a/packages/lit-dev-content/samples/tutorials/wc-to-lit/08/before/rating-element.ts +++ b/packages/lit-dev-content/samples/tutorials/wc-to-lit/08/before/rating-element.ts @@ -1,27 +1,34 @@ export class RatingElement extends HTMLElement { private _rating = 0; - private _vote: 'up'|'down'|null = null; + private _vote: 'up' | 'down' | null = null; connectedCallback() { const shadowRoot = this.attachShadow({mode: 'open'}); - const templateContent = document.querySelector('#rating-element-template')!.content; + const templateContent = document.querySelector( + '#rating-element-template', + )!.content; const clonedContent = templateContent.cloneNode(true); shadowRoot.appendChild(clonedContent); - this.shadowRoot!.querySelector('.rating')!.innerText = `${this.rating}`; + this.shadowRoot!.querySelector('.rating')!.innerText = + `${this.rating}`; } static get observedAttributes() { return ['rating', 'vote']; } - attributeChangedCallback(attributeName: string, _oldValue: string, newValue: string) { + attributeChangedCallback( + attributeName: string, + _oldValue: string, + newValue: string, + ) { if (attributeName === 'rating') { const newRating = Number(newValue); this.rating = newRating; } else if (attributeName === 'vote') { - this.vote = newValue as 'up'|'down'; + this.vote = newValue as 'up' | 'down'; } } @@ -70,6 +77,6 @@ export class RatingElement extends HTMLElement { get vote() { return this._vote; } - } +} - customElements.define('rating-element', RatingElement); +customElements.define('rating-element', RatingElement); diff --git a/packages/lit-dev-content/samples/tutorials/wc-to-lit/09/before/index.html b/packages/lit-dev-content/samples/tutorials/wc-to-lit/09/before/index.html index dda519c33..e01611967 100644 --- a/packages/lit-dev-content/samples/tutorials/wc-to-lit/09/before/index.html +++ b/packages/lit-dev-content/samples/tutorials/wc-to-lit/09/before/index.html @@ -1,4 +1,4 @@ - + @@ -16,20 +16,38 @@ cursor: pointer; } - :host([vote=up]) .thumb_up { + :host([vote='up']) .thumb_up { fill: green; } - :host([vote=down]) .thumb_down { + :host([vote='down']) .thumb_down { fill: red; } - diff --git a/packages/lit-dev-content/samples/tutorials/wc-to-lit/09/before/rating-element.ts b/packages/lit-dev-content/samples/tutorials/wc-to-lit/09/before/rating-element.ts index c4828518f..93f434745 100644 --- a/packages/lit-dev-content/samples/tutorials/wc-to-lit/09/before/rating-element.ts +++ b/packages/lit-dev-content/samples/tutorials/wc-to-lit/09/before/rating-element.ts @@ -1,45 +1,56 @@ export class RatingElement extends HTMLElement { private _rating = 0; - private _vote: 'up'|'down'|null = null; + private _vote: 'up' | 'down' | null = null; private _boundOnUpClick = this._onUpClick.bind(this); private _boundOnDownClick = this._onDownClick.bind(this); connectedCallback() { const shadowRoot = this.attachShadow({mode: 'open'}); - const templateContent = document.querySelector('#rating-element-template')!.content; + const templateContent = document.querySelector( + '#rating-element-template', + )!.content; const clonedContent = templateContent.cloneNode(true); shadowRoot.appendChild(clonedContent); - this.shadowRoot!.querySelector('.rating')!.innerText = `${this.rating}`; - - this.shadowRoot! - .querySelector('.thumb_up')! - .addEventListener('click', this._boundOnUpClick); - this.shadowRoot! - .querySelector('.thumb_down')! - .addEventListener('click', this._boundOnDownClick); + this.shadowRoot!.querySelector('.rating')!.innerText = + `${this.rating}`; + + this.shadowRoot!.querySelector('.thumb_up')!.addEventListener( + 'click', + this._boundOnUpClick, + ); + this.shadowRoot!.querySelector('.thumb_down')!.addEventListener( + 'click', + this._boundOnDownClick, + ); } disconnectedCallback() { - this.shadowRoot! - .querySelector('.thumb_up')! - .removeEventListener('click', this._boundOnUpClick); - this.shadowRoot! - .querySelector('.thumb_down')! - .removeEventListener('click', this._boundOnDownClick); + this.shadowRoot!.querySelector('.thumb_up')!.removeEventListener( + 'click', + this._boundOnUpClick, + ); + this.shadowRoot!.querySelector('.thumb_down')!.removeEventListener( + 'click', + this._boundOnDownClick, + ); } static get observedAttributes() { return ['rating', 'vote']; } - attributeChangedCallback(attributeName: string, _oldValue: string, newValue: string) { + attributeChangedCallback( + attributeName: string, + _oldValue: string, + newValue: string, + ) { if (attributeName === 'rating') { const newRating = Number(newValue); this.rating = newRating; } else if (attributeName === 'vote') { - this.vote = newValue as 'up'|'down'; + this.vote = newValue as 'up' | 'down'; } } @@ -96,6 +107,6 @@ export class RatingElement extends HTMLElement { _onDownClick() { this.vote = 'down'; } - } +} - customElements.define('rating-element', RatingElement); +customElements.define('rating-element', RatingElement); diff --git a/packages/lit-dev-content/samples/tutorials/wc-to-lit/10/before/index.html b/packages/lit-dev-content/samples/tutorials/wc-to-lit/10/before/index.html index 1756d3695..6b10ad860 100644 --- a/packages/lit-dev-content/samples/tutorials/wc-to-lit/10/before/index.html +++ b/packages/lit-dev-content/samples/tutorials/wc-to-lit/10/before/index.html @@ -1,4 +1,4 @@ - + diff --git a/packages/lit-dev-content/samples/tutorials/wc-to-lit/10/before/rating-element.ts b/packages/lit-dev-content/samples/tutorials/wc-to-lit/10/before/rating-element.ts index b9b159120..66ed89c7b 100644 --- a/packages/lit-dev-content/samples/tutorials/wc-to-lit/10/before/rating-element.ts +++ b/packages/lit-dev-content/samples/tutorials/wc-to-lit/10/before/rating-element.ts @@ -2,7 +2,7 @@ import {render, html} from 'lit'; export class RatingElement extends HTMLElement { private _rating = 0; - private _vote: 'up'|'down'|null = null; + private _vote: 'up' | 'down' | null = null; private _boundOnUpClick = this._onUpClick.bind(this); private _boundOnDownClick = this._onDownClick.bind(this); @@ -10,34 +10,42 @@ export class RatingElement extends HTMLElement { this.attachShadow({mode: 'open'}); this.render(); - this.shadowRoot! - .querySelector('.thumb_up')! - .addEventListener('click', this._boundOnUpClick); - this.shadowRoot! - .querySelector('.thumb_down')! - .addEventListener('click', this._boundOnDownClick); + this.shadowRoot!.querySelector('.thumb_up')!.addEventListener( + 'click', + this._boundOnUpClick, + ); + this.shadowRoot!.querySelector('.thumb_down')!.addEventListener( + 'click', + this._boundOnDownClick, + ); } disconnectedCallback() { - this.shadowRoot! - .querySelector('.thumb_up')! - .removeEventListener('click', this._boundOnUpClick); - this.shadowRoot! - .querySelector('.thumb_down')! - .removeEventListener('click', this._boundOnDownClick); + this.shadowRoot!.querySelector('.thumb_up')!.removeEventListener( + 'click', + this._boundOnUpClick, + ); + this.shadowRoot!.querySelector('.thumb_down')!.removeEventListener( + 'click', + this._boundOnDownClick, + ); } static get observedAttributes() { return ['rating', 'vote']; } - attributeChangedCallback(attributeName: string, _oldValue: string, newValue: string) { + attributeChangedCallback( + attributeName: string, + _oldValue: string, + newValue: string, + ) { if (attributeName === 'rating') { const newRating = Number(newValue); this.rating = newRating; } else if (attributeName === 'vote') { - this.vote = newValue as 'up'|'down'; + this.vote = newValue as 'up' | 'down'; } } @@ -100,8 +108,7 @@ export class RatingElement extends HTMLElement { return; } - const template = html` - ${this.rating} `; render(template, this.shadowRoot); } - } +} - customElements.define('rating-element', RatingElement); +customElements.define('rating-element', RatingElement); diff --git a/packages/lit-dev-content/samples/tutorials/wc-to-lit/11/before/index.html b/packages/lit-dev-content/samples/tutorials/wc-to-lit/11/before/index.html index 1756d3695..6b10ad860 100644 --- a/packages/lit-dev-content/samples/tutorials/wc-to-lit/11/before/index.html +++ b/packages/lit-dev-content/samples/tutorials/wc-to-lit/11/before/index.html @@ -1,4 +1,4 @@ - + diff --git a/packages/lit-dev-content/samples/tutorials/wc-to-lit/11/before/rating-element.ts b/packages/lit-dev-content/samples/tutorials/wc-to-lit/11/before/rating-element.ts index 546da045e..0fab31619 100644 --- a/packages/lit-dev-content/samples/tutorials/wc-to-lit/11/before/rating-element.ts +++ b/packages/lit-dev-content/samples/tutorials/wc-to-lit/11/before/rating-element.ts @@ -2,7 +2,7 @@ import {render, html} from 'lit'; export class RatingElement extends HTMLElement { private _rating = 0; - private _vote: 'up'|'down'|null = null; + private _vote: 'up' | 'down' | null = null; connectedCallback() { this.attachShadow({mode: 'open'}); @@ -13,7 +13,11 @@ export class RatingElement extends HTMLElement { return ['rating']; } - attributeChangedCallback(attributeName: string, _oldValue: string, newValue: string) { + attributeChangedCallback( + attributeName: string, + _oldValue: string, + newValue: string, + ) { if (attributeName === 'rating') { const newRating = Number(newValue); @@ -64,8 +68,7 @@ export class RatingElement extends HTMLElement { return; } - const template = html` - ${this.rating} `; render(template, this.shadowRoot); } - } +} - customElements.define('rating-element', RatingElement); +customElements.define('rating-element', RatingElement); diff --git a/packages/lit-dev-content/samples/tutorials/wc-to-lit/12/before/index.html b/packages/lit-dev-content/samples/tutorials/wc-to-lit/12/before/index.html index 1756d3695..6b10ad860 100644 --- a/packages/lit-dev-content/samples/tutorials/wc-to-lit/12/before/index.html +++ b/packages/lit-dev-content/samples/tutorials/wc-to-lit/12/before/index.html @@ -1,4 +1,4 @@ - + diff --git a/packages/lit-dev-content/samples/tutorials/wc-to-lit/12/before/rating-element.ts b/packages/lit-dev-content/samples/tutorials/wc-to-lit/12/before/rating-element.ts index b8de33b32..17cf59162 100644 --- a/packages/lit-dev-content/samples/tutorials/wc-to-lit/12/before/rating-element.ts +++ b/packages/lit-dev-content/samples/tutorials/wc-to-lit/12/before/rating-element.ts @@ -15,23 +15,27 @@ export class RatingElement extends LitElement { cursor: pointer; } - :host([vote=up]) .thumb_up { + :host([vote='up']) .thumb_up { fill: green; } - :host([vote=down]) .thumb_down { + :host([vote='down']) .thumb_down { fill: red; } `; private _rating = 0; - private _vote: 'up'|'down'|null = null; + private _vote: 'up' | 'down' | null = null; // static get observedAttributes() { // return ['rating']; // } - attributeChangedCallback(attributeName: string, _oldValue: string, newValue: string) { + attributeChangedCallback( + attributeName: string, + _oldValue: string, + newValue: string, + ) { if (attributeName === 'rating') { const newRating = Number(newValue); @@ -78,17 +82,40 @@ export class RatingElement extends LitElement { } render() { - return html` - ${this.rating} `; } } diff --git a/packages/lit-dev-content/samples/tutorials/wc-to-lit/13/before/index.html b/packages/lit-dev-content/samples/tutorials/wc-to-lit/13/before/index.html index 372d55ac7..fe702d95e 100644 --- a/packages/lit-dev-content/samples/tutorials/wc-to-lit/13/before/index.html +++ b/packages/lit-dev-content/samples/tutorials/wc-to-lit/13/before/index.html @@ -1,4 +1,4 @@ - + @@ -21,20 +21,38 @@ cursor: pointer; } - :host([vote=up]) .thumb_up { + :host([vote='up']) .thumb_up { fill: green; } - :host([vote=down]) .thumb_down { + :host([vote='down']) .thumb_down { fill: red; } - diff --git a/packages/lit-dev-content/samples/tutorials/wc-to-lit/13/before/rating-element.ts b/packages/lit-dev-content/samples/tutorials/wc-to-lit/13/before/rating-element.ts index 1c1d38d35..ed8ca15eb 100644 --- a/packages/lit-dev-content/samples/tutorials/wc-to-lit/13/before/rating-element.ts +++ b/packages/lit-dev-content/samples/tutorials/wc-to-lit/13/before/rating-element.ts @@ -15,11 +15,11 @@ class RatingElement extends LitElement { cursor: pointer; } - :host([vote=up]) .thumb_up { + :host([vote='up']) .thumb_up { fill: green; } - :host([vote=down]) .thumb_down { + :host([vote='down']) .thumb_down { fill: red; } `; @@ -28,7 +28,7 @@ class RatingElement extends LitElement { rating = 0; @property({type: String, reflect: true}) - vote: 'up'|'down'|null = null; + vote: 'up' | 'down' | null = null; willUpdate(changedProps: PropertyValues) { if (changedProps.has('vote')) { @@ -52,17 +52,40 @@ class RatingElement extends LitElement { } render() { - return html` - ${this.rating} `; } } diff --git a/packages/lit-dev-content/samples/tutorials/wc-to-lit/tutorial.json b/packages/lit-dev-content/samples/tutorials/wc-to-lit/tutorial.json index 8512ba287..6f47450b5 100644 --- a/packages/lit-dev-content/samples/tutorials/wc-to-lit/tutorial.json +++ b/packages/lit-dev-content/samples/tutorials/wc-to-lit/tutorial.json @@ -51,4 +51,4 @@ "noSolve": true } ] -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/00/after/index.html b/packages/lit-dev-content/samples/tutorials/word-viewer/00/after/index.html index adf78eba6..cea1ee17b 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/00/after/index.html +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/00/after/index.html @@ -1,4 +1,4 @@ - + @@ -14,7 +14,8 @@

    Click the bouncing ball!

    - +_______9" + > diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/00/after/word-viewer.ts b/packages/lit-dev-content/samples/tutorials/word-viewer/00/after/word-viewer.ts index 817218e38..3af209f2d 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/00/after/word-viewer.ts +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/00/after/word-viewer.ts @@ -1,6 +1,6 @@ -import { css, html, LitElement } from 'lit'; -import { customElement, property, state } from 'lit/decorators.js'; -import { classMap } from 'lit/directives/class-map.js'; +import {css, html, LitElement} from 'lit'; +import {customElement, property, state} from 'lit/decorators.js'; +import {classMap} from 'lit/directives/class-map.js'; @customElement('word-viewer') class WordViewer extends LitElement { @@ -18,7 +18,7 @@ class WordViewer extends LitElement { color: white; background-color: violet; } - ` + `; @state() private playDirection: -1 | 1 = 1; @state() private idx = 0; @@ -39,15 +39,20 @@ class WordViewer extends LitElement { render() { const splitWords = this.words.split('.'); - const idx = ((this.idx % splitWords.length) + splitWords.length) % splitWords.length; + const idx = + ((this.idx % splitWords.length) + splitWords.length) % splitWords.length; const word = splitWords[idx]; return html`
    ${word}
    `; + > +${word}`; } - tickToNextWord = () => { this.idx += this.playDirection; }; + tickToNextWord = () => { + this.idx += this.playDirection; + }; switchPlayDirection() { this.playDirection *= -1; diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/00/before/index.html b/packages/lit-dev-content/samples/tutorials/word-viewer/00/before/index.html index 52d99d087..3f10f3a03 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/00/before/index.html +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/00/before/index.html @@ -1,4 +1,4 @@ - + @@ -18,6 +18,5 @@

    <word-viewer> examples:

    Add your own here... - diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/00/before/project.json b/packages/lit-dev-content/samples/tutorials/word-viewer/00/before/project.json index 6315ce34d..58e4329b8 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/00/before/project.json +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/00/before/project.json @@ -6,4 +6,4 @@ }, "word-viewer.ts": {} } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/00/before/word-viewer.ts b/packages/lit-dev-content/samples/tutorials/word-viewer/00/before/word-viewer.ts index 417243e18..af8190e02 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/00/before/word-viewer.ts +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/00/before/word-viewer.ts @@ -1,6 +1,6 @@ -import { css, html, LitElement } from 'lit'; -import { customElement, property, state } from 'lit/decorators.js'; -import { classMap } from 'lit/directives/class-map.js'; +import {css, html, LitElement} from 'lit'; +import {customElement, property, state} from 'lit/decorators.js'; +import {classMap} from 'lit/directives/class-map.js'; @customElement('word-viewer') class WordViewer extends LitElement { @@ -18,7 +18,7 @@ class WordViewer extends LitElement { color: white; background-color: violet; } - ` + `; @state() private playDirection: -1 | 1 = 1; @state() private idx = 0; @@ -39,15 +39,20 @@ class WordViewer extends LitElement { render() { const splitWords = this.words.split('.'); - const idx = ((this.idx % splitWords.length) + splitWords.length) % splitWords.length; + const idx = + ((this.idx % splitWords.length) + splitWords.length) % splitWords.length; const word = splitWords[idx]; return html`
    ${word}
    `; + > +${word}`; } - tickToNextWord = () => { this.idx += this.playDirection; }; + tickToNextWord = () => { + this.idx += this.playDirection; + }; switchPlayDirection() { this.playDirection *= -1; diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/01/after/word-viewer.ts b/packages/lit-dev-content/samples/tutorials/word-viewer/01/after/word-viewer.ts index 02bc4685b..29b2d3f77 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/01/after/word-viewer.ts +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/01/after/word-viewer.ts @@ -1,15 +1,15 @@ -import { html, LitElement } from 'lit'; -import { customElement } from 'lit/decorators.js'; +import {html, LitElement} from 'lit'; +import {customElement} from 'lit/decorators.js'; @customElement('word-viewer') class WordViewer extends LitElement { render() { - return html`
    A super expressive and efficient template!
    ` + return html`
    A super expressive and efficient template!
    `; } } declare global { interface HTMLElementTagNameMap { - "word-viewer": WordViewer + 'word-viewer': WordViewer; } } diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/01/before/word-viewer.ts b/packages/lit-dev-content/samples/tutorials/word-viewer/01/before/word-viewer.ts index db175b0b3..74874f2c6 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/01/before/word-viewer.ts +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/01/before/word-viewer.ts @@ -1,5 +1,5 @@ -import { html, LitElement } from 'lit'; -import { customElement } from 'lit/decorators.js'; +import {html, LitElement} from 'lit'; +import {customElement} from 'lit/decorators.js'; class WordViewer extends LitElement { render() { diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/02/after/word-viewer.ts b/packages/lit-dev-content/samples/tutorials/word-viewer/02/after/word-viewer.ts index 291b60f1c..ece7cdea5 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/02/after/word-viewer.ts +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/02/after/word-viewer.ts @@ -1,12 +1,11 @@ -import { html, LitElement } from 'lit'; -import { customElement, property } from 'lit/decorators.js'; +import {html, LitElement} from 'lit'; +import {customElement, property} from 'lit/decorators.js'; @customElement('word-viewer') class WordViewer extends LitElement { @property() words = 'initial value'; render() { - return html`
    ${this.words}
    ` + return html`
    ${this.words}
    `; } } - diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/02/before/word-viewer.js b/packages/lit-dev-content/samples/tutorials/word-viewer/02/before/word-viewer.js index 0e3d4199e..b8297c388 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/02/before/word-viewer.js +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/02/before/word-viewer.js @@ -1,5 +1,4 @@ -import { html, LitElement } from 'lit'; - +import {html, LitElement} from 'lit'; class WordViewer extends LitElement { // TODO: Declare a reactive property `words`. diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/02/before/word-viewer.ts b/packages/lit-dev-content/samples/tutorials/word-viewer/02/before/word-viewer.ts index 4654b39c4..9a06b7c91 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/02/before/word-viewer.ts +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/02/before/word-viewer.ts @@ -1,5 +1,5 @@ -import { html, LitElement } from 'lit'; -import { customElement, property } from 'lit/decorators.js'; +import {html, LitElement} from 'lit'; +import {customElement, property} from 'lit/decorators.js'; @customElement('word-viewer') class WordViewer extends LitElement { @@ -9,4 +9,3 @@ class WordViewer extends LitElement { return html`
    ${this.words}
    `; } } - diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/03/after/word-viewer.ts b/packages/lit-dev-content/samples/tutorials/word-viewer/03/after/word-viewer.ts index 4fc3a4245..6e5ba207a 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/03/after/word-viewer.ts +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/03/after/word-viewer.ts @@ -1,5 +1,5 @@ -import { html, LitElement } from 'lit'; -import { customElement, property, state } from 'lit/decorators.js'; +import {html, LitElement} from 'lit'; +import {customElement, property, state} from 'lit/decorators.js'; @customElement('word-viewer') class WordViewer extends LitElement { @@ -12,4 +12,3 @@ class WordViewer extends LitElement { return html`
    ${word}
    `; } } - diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/03/before/word-viewer.ts b/packages/lit-dev-content/samples/tutorials/word-viewer/03/before/word-viewer.ts index 5daf600fa..47d9282ee 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/03/before/word-viewer.ts +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/03/before/word-viewer.ts @@ -1,5 +1,5 @@ -import { html, LitElement } from 'lit'; -import { customElement, property, state } from 'lit/decorators.js'; +import {html, LitElement} from 'lit'; +import {customElement, property, state} from 'lit/decorators.js'; @customElement('word-viewer') class WordViewer extends LitElement { @@ -12,4 +12,3 @@ class WordViewer extends LitElement { return html`
    ${this.words}
    `; } } - diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/04/after/word-viewer.ts b/packages/lit-dev-content/samples/tutorials/word-viewer/04/after/word-viewer.ts index 3fbe89591..ab3e3e1fc 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/04/after/word-viewer.ts +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/04/after/word-viewer.ts @@ -1,5 +1,5 @@ -import { html, LitElement } from 'lit'; -import { customElement, property, state } from 'lit/decorators.js'; +import {html, LitElement} from 'lit'; +import {customElement, property, state} from 'lit/decorators.js'; @customElement('word-viewer') class WordViewer extends LitElement { @@ -7,12 +7,12 @@ class WordViewer extends LitElement { @property() words = 'initial value'; private intervalTimer?: number; - + connectedCallback() { super.connectedCallback(); this.intervalTimer = setInterval(this.tickToNextWord, 1000); } - + disconnectedCallback() { super.disconnectedCallback(); clearInterval(this.intervalTimer); @@ -25,6 +25,7 @@ class WordViewer extends LitElement { return html`
    ${word}
    `; } - tickToNextWord = () => { this.idx += 1; }; + tickToNextWord = () => { + this.idx += 1; + }; } - diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/04/before/word-viewer.ts b/packages/lit-dev-content/samples/tutorials/word-viewer/04/before/word-viewer.ts index 247d0b0bc..4d891b288 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/04/before/word-viewer.ts +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/04/before/word-viewer.ts @@ -1,5 +1,5 @@ -import { html, LitElement } from 'lit'; -import { customElement, property, state } from 'lit/decorators.js'; +import {html, LitElement} from 'lit'; +import {customElement, property, state} from 'lit/decorators.js'; @customElement('word-viewer') class WordViewer extends LitElement { @@ -7,7 +7,7 @@ class WordViewer extends LitElement { @property() words = 'initial value'; // TODO: Define a `connectedCallback` which sets an interval. - // TODO: Define a `disconnectedCallback` which clears the interval. + // TODO: Define a `disconnectedCallback` which clears the interval. render() { const splitWords = this.words.split('.'); @@ -17,4 +17,3 @@ class WordViewer extends LitElement { // TODO: Define `tickToNextWord`. } - diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/05/after/word-viewer.ts b/packages/lit-dev-content/samples/tutorials/word-viewer/05/after/word-viewer.ts index fdf5581a5..f63e4c20f 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/05/after/word-viewer.ts +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/05/after/word-viewer.ts @@ -1,5 +1,5 @@ -import { css, html, LitElement } from 'lit'; -import { customElement, property, state } from 'lit/decorators.js'; +import {css, html, LitElement} from 'lit'; +import {customElement, property, state} from 'lit/decorators.js'; @customElement('word-viewer') class WordViewer extends LitElement { @@ -37,6 +37,7 @@ class WordViewer extends LitElement { return html`
    ${word}
    `; } - tickToNextWord = () => { this.idx += 1; }; + tickToNextWord = () => { + this.idx += 1; + }; } - diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/05/before/word-viewer.ts b/packages/lit-dev-content/samples/tutorials/word-viewer/05/before/word-viewer.ts index 0305f02fe..272ee4507 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/05/before/word-viewer.ts +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/05/before/word-viewer.ts @@ -1,5 +1,5 @@ -import { css, html, LitElement } from 'lit'; -import { customElement, property, state } from 'lit/decorators.js'; +import {css, html, LitElement} from 'lit'; +import {customElement, property, state} from 'lit/decorators.js'; @customElement('word-viewer') class WordViewer extends LitElement { @@ -9,12 +9,12 @@ class WordViewer extends LitElement { @property() words = 'initial value'; private intervalTimer?: number; - + connectedCallback() { super.connectedCallback(); this.intervalTimer = setInterval(this.tickToNextWord, 1000); } - + disconnectedCallback() { super.disconnectedCallback(); clearInterval(this.intervalTimer); @@ -27,6 +27,7 @@ class WordViewer extends LitElement { return html`
    ${word}
    `; } - tickToNextWord = () => { this.idx += 1; }; + tickToNextWord = () => { + this.idx += 1; + }; } - diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/06/after/word-viewer.ts b/packages/lit-dev-content/samples/tutorials/word-viewer/06/after/word-viewer.ts index d00fab1f0..99db44666 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/06/after/word-viewer.ts +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/06/after/word-viewer.ts @@ -1,5 +1,5 @@ -import { css, html, LitElement } from 'lit'; -import { customElement, property, state } from 'lit/decorators.js'; +import {css, html, LitElement} from 'lit'; +import {customElement, property, state} from 'lit/decorators.js'; @customElement('word-viewer') class WordViewer extends LitElement { @@ -34,17 +34,17 @@ class WordViewer extends LitElement { render() { const splitWords = this.words.split('.'); - const idx = ((this.idx % splitWords.length) + splitWords.length) % splitWords.length; + const idx = + ((this.idx % splitWords.length) + splitWords.length) % splitWords.length; const word = splitWords[idx]; - return html`
    ${word}
    `; + return html`
    ${word}
    `; } - tickToNextWord = () => { this.idx += this.playDirection; }; + tickToNextWord = () => { + this.idx += this.playDirection; + }; switchPlayDirection() { this.playDirection *= -1; } } - diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/06/before/project.json b/packages/lit-dev-content/samples/tutorials/word-viewer/06/before/project.json index 324d2795c..c04439e43 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/06/before/project.json +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/06/before/project.json @@ -6,4 +6,4 @@ }, "index.html": {} } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/06/before/word-viewer.ts b/packages/lit-dev-content/samples/tutorials/word-viewer/06/before/word-viewer.ts index 574f90a2a..df8699ba1 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/06/before/word-viewer.ts +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/06/before/word-viewer.ts @@ -1,5 +1,5 @@ -import { css, html, LitElement } from 'lit'; -import { customElement, property, state } from 'lit/decorators.js'; +import {css, html, LitElement} from 'lit'; +import {customElement, property, state} from 'lit/decorators.js'; @customElement('word-viewer') class WordViewer extends LitElement { @@ -40,8 +40,9 @@ class WordViewer extends LitElement { return html`
    ${word}
    `; } // TODO: Increment by `this.playDirection` - tickToNextWord = () => { this.idx += 1; }; + tickToNextWord = () => { + this.idx += 1; + }; // TODO: Add switchPlayDirection method. } - diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/07/after/word-viewer.ts b/packages/lit-dev-content/samples/tutorials/word-viewer/07/after/word-viewer.ts index 3004483c3..af8190e02 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/07/after/word-viewer.ts +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/07/after/word-viewer.ts @@ -1,6 +1,6 @@ -import { css, html, LitElement } from 'lit'; -import { customElement, property, state } from 'lit/decorators.js'; -import { classMap } from 'lit/directives/class-map.js'; +import {css, html, LitElement} from 'lit'; +import {customElement, property, state} from 'lit/decorators.js'; +import {classMap} from 'lit/directives/class-map.js'; @customElement('word-viewer') class WordViewer extends LitElement { @@ -18,7 +18,7 @@ class WordViewer extends LitElement { color: white; background-color: violet; } - ` + `; @state() private playDirection: -1 | 1 = 1; @state() private idx = 0; @@ -39,18 +39,22 @@ class WordViewer extends LitElement { render() { const splitWords = this.words.split('.'); - const idx = ((this.idx % splitWords.length) + splitWords.length) % splitWords.length; + const idx = + ((this.idx % splitWords.length) + splitWords.length) % splitWords.length; const word = splitWords[idx]; return html`
    ${word}
    `; + > +${word}`; } - tickToNextWord = () => { this.idx += this.playDirection; }; + tickToNextWord = () => { + this.idx += this.playDirection; + }; switchPlayDirection() { this.playDirection *= -1; } } - diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/07/before/project.json b/packages/lit-dev-content/samples/tutorials/word-viewer/07/before/project.json index 324d2795c..c04439e43 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/07/before/project.json +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/07/before/project.json @@ -6,4 +6,4 @@ }, "index.html": {} } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/07/before/word-viewer.ts b/packages/lit-dev-content/samples/tutorials/word-viewer/07/before/word-viewer.ts index c7958bb35..d0d690b11 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/07/before/word-viewer.ts +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/07/before/word-viewer.ts @@ -1,6 +1,6 @@ -import { css, html, LitElement } from 'lit'; -import { customElement, property, state } from 'lit/decorators.js'; -import { classMap } from 'lit/directives/class-map.js'; +import {css, html, LitElement} from 'lit'; +import {customElement, property, state} from 'lit/decorators.js'; +import {classMap} from 'lit/directives/class-map.js'; @customElement('word-viewer') class WordViewer extends LitElement { @@ -36,18 +36,22 @@ class WordViewer extends LitElement { render() { const splitWords = this.words.split('.'); - const idx = ((this.idx % splitWords.length) + splitWords.length) % splitWords.length; + const idx = + ((this.idx % splitWords.length) + splitWords.length) % splitWords.length; const word = splitWords[idx]; return html`
    ${word}
    `; + > +${word}`; } - tickToNextWord = () => { this.idx += this.playDirection; }; + tickToNextWord = () => { + this.idx += this.playDirection; + }; switchPlayDirection() { this.playDirection *= -1; } } - diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/08/before/index.html b/packages/lit-dev-content/samples/tutorials/word-viewer/08/before/index.html index adf78eba6..cea1ee17b 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/08/before/index.html +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/08/before/index.html @@ -1,4 +1,4 @@ - + @@ -14,7 +14,8 @@

    Click the bouncing ball!

    - +_______9" + > diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/08/before/project.json b/packages/lit-dev-content/samples/tutorials/word-viewer/08/before/project.json index 6315ce34d..58e4329b8 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/08/before/project.json +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/08/before/project.json @@ -6,4 +6,4 @@ }, "word-viewer.ts": {} } -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/08/before/word-viewer.ts b/packages/lit-dev-content/samples/tutorials/word-viewer/08/before/word-viewer.ts index d875268ad..3af209f2d 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/08/before/word-viewer.ts +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/08/before/word-viewer.ts @@ -1,6 +1,6 @@ -import { css, html, LitElement } from 'lit'; -import { customElement, property, state } from 'lit/decorators.js'; -import { classMap } from 'lit/directives/class-map.js'; +import {css, html, LitElement} from 'lit'; +import {customElement, property, state} from 'lit/decorators.js'; +import {classMap} from 'lit/directives/class-map.js'; @customElement('word-viewer') class WordViewer extends LitElement { @@ -18,7 +18,7 @@ class WordViewer extends LitElement { color: white; background-color: violet; } - ` + `; @state() private playDirection: -1 | 1 = 1; @state() private idx = 0; @@ -39,18 +39,22 @@ class WordViewer extends LitElement { render() { const splitWords = this.words.split('.'); - const idx = ((this.idx % splitWords.length) + splitWords.length) % splitWords.length; + const idx = + ((this.idx % splitWords.length) + splitWords.length) % splitWords.length; const word = splitWords[idx]; return html`
    ${word}
    `; + > +${word}`; } - tickToNextWord = () => { this.idx += this.playDirection; }; + tickToNextWord = () => { + this.idx += this.playDirection; + }; switchPlayDirection() { this.playDirection *= -1; } } - diff --git a/packages/lit-dev-content/samples/tutorials/word-viewer/tutorial.json b/packages/lit-dev-content/samples/tutorials/word-viewer/tutorial.json index ab653cee1..0bd8e0403 100644 --- a/packages/lit-dev-content/samples/tutorials/word-viewer/tutorial.json +++ b/packages/lit-dev-content/samples/tutorials/word-viewer/tutorial.json @@ -43,4 +43,4 @@ "noSolve": true } ] -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/00/before/index.html b/packages/lit-dev-content/samples/tutorials/working-with-lists/00/before/index.html index a332734e2..3e7a17991 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/00/before/index.html +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/00/before/index.html @@ -1,4 +1,4 @@ - + diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/00/before/my-element.ts b/packages/lit-dev-content/samples/tutorials/working-with-lists/00/before/my-element.ts index f926dc3e5..4311b6c71 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/00/before/my-element.ts +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/00/before/my-element.ts @@ -8,20 +8,15 @@ class MyElement extends LitElement {

    Rendering lists with Lit

    Lit has built-in support for any iterables!

    Array

    -

    - ${['✨', '🔥', '❤️']} -

    +

    ${['✨', '🔥', '❤️']}

    Set

    -

    - ${new Set(['A', 'B', 'C'])} -

    +

    ${new Set(['A', 'B', 'C'])}

    Generator

    ${(function* () { - for (let i = 1; i < 4; i++) yield i; + for (let i = 1; i < 4; i++) yield i; })()}

    `; } } - diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/01/after/index.html b/packages/lit-dev-content/samples/tutorials/working-with-lists/01/after/index.html index a332734e2..3e7a17991 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/01/after/index.html +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/01/after/index.html @@ -1,4 +1,4 @@ - + diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/01/after/my-element.ts b/packages/lit-dev-content/samples/tutorials/working-with-lists/01/after/my-element.ts index 92556c517..b0f453b80 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/01/after/my-element.ts +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/01/after/my-element.ts @@ -5,7 +5,7 @@ import {map} from 'lit/directives/map.js'; @customElement('my-element') class MyElement extends LitElement { @state() - items = new Set(['Apple', 'Banana', 'Grape', 'Orange', 'Lime']) + items = new Set(['Apple', 'Banana', 'Grape', 'Orange', 'Lime']); render() { return html` diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/01/before/index.html b/packages/lit-dev-content/samples/tutorials/working-with-lists/01/before/index.html index a332734e2..3e7a17991 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/01/before/index.html +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/01/before/index.html @@ -1,4 +1,4 @@ - + diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/01/before/my-element.ts b/packages/lit-dev-content/samples/tutorials/working-with-lists/01/before/my-element.ts index 8b08288e1..66a08d243 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/01/before/my-element.ts +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/01/before/my-element.ts @@ -5,7 +5,7 @@ import {customElement, state} from 'lit/decorators.js'; @customElement('my-element') class MyElement extends LitElement { @state() - items = new Set(['Apple', 'Banana', 'Grape', 'Orange', 'Lime']) + items = new Set(['Apple', 'Banana', 'Grape', 'Orange', 'Lime']); render() { return html` diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/02/after/index.html b/packages/lit-dev-content/samples/tutorials/working-with-lists/02/after/index.html index a332734e2..3e7a17991 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/02/after/index.html +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/02/after/index.html @@ -1,4 +1,4 @@ - + diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/02/after/my-element.ts b/packages/lit-dev-content/samples/tutorials/working-with-lists/02/after/my-element.ts index 95c6d3191..2b1faa565 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/02/after/my-element.ts +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/02/after/my-element.ts @@ -10,9 +10,9 @@ class MyElement extends LitElement { return html`

    A list of names that include the letter "e"

      - ${this.names - .filter((name) => name.match(/e/i)) - .map((name) => html`
    • ${name}
    • `)} + ${this.names + .filter((name) => name.match(/e/i)) + .map((name) => html`
    • ${name}
    • `)}
    `; } diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/02/before/index.html b/packages/lit-dev-content/samples/tutorials/working-with-lists/02/before/index.html index a332734e2..3e7a17991 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/02/before/index.html +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/02/before/index.html @@ -1,4 +1,4 @@ - + diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/03/after/index.html b/packages/lit-dev-content/samples/tutorials/working-with-lists/03/after/index.html index a332734e2..3e7a17991 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/03/after/index.html +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/03/after/index.html @@ -1,4 +1,4 @@ - + diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/03/after/my-element.ts b/packages/lit-dev-content/samples/tutorials/working-with-lists/03/after/my-element.ts index fcedcadef..5bf5d1c77 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/03/after/my-element.ts +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/03/after/my-element.ts @@ -9,9 +9,9 @@ class MyElement extends LitElement { @state() pets = [ - { name: "Hedwig", species: "Owl" }, - { name: "Scabbers", species: "Rat" }, - { name: "Crookshanks", species: "Cat" }, + {name: 'Hedwig', species: 'Owl'}, + {name: 'Scabbers', species: 'Rat'}, + {name: 'Crookshanks', species: 'Cat'}, ]; @state() diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/03/before/index.html b/packages/lit-dev-content/samples/tutorials/working-with-lists/03/before/index.html index a332734e2..3e7a17991 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/03/before/index.html +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/03/before/index.html @@ -1,4 +1,4 @@ - + diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/03/before/my-element.ts b/packages/lit-dev-content/samples/tutorials/working-with-lists/03/before/my-element.ts index ef5a53404..8a4dcfbe8 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/03/before/my-element.ts +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/03/before/my-element.ts @@ -9,9 +9,9 @@ class MyElement extends LitElement { @state() pets = [ - { name: "Hedwig", species: "Owl" }, - { name: "Scabbers", species: "Rat" }, - { name: "Crookshanks", species: "Cat" }, + {name: 'Hedwig', species: 'Owl'}, + {name: 'Scabbers', species: 'Rat'}, + {name: 'Crookshanks', species: 'Cat'}, ]; @state() diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/04/after/index.html b/packages/lit-dev-content/samples/tutorials/working-with-lists/04/after/index.html index a332734e2..3e7a17991 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/04/after/index.html +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/04/after/index.html @@ -1,4 +1,4 @@ - + diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/04/after/my-element.js b/packages/lit-dev-content/samples/tutorials/working-with-lists/04/after/my-element.js index 1c304b4b7..62347bdad 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/04/after/my-element.js +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/04/after/my-element.js @@ -30,7 +30,6 @@ class MyElement extends LitElement { background: white; } /* playground-fold-end */ - `; render() { @@ -41,9 +40,9 @@ class MyElement extends LitElement { map( range(8), (col) => html` -
    ${getLabel(row, col)}
    - ` - ) +
    ${getLabel(row, col)}
    + `, + ), )}
    `; diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/04/after/my-element.ts b/packages/lit-dev-content/samples/tutorials/working-with-lists/04/after/my-element.ts index 1c30cff05..518c2cd6d 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/04/after/my-element.ts +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/04/after/my-element.ts @@ -32,22 +32,26 @@ class MyElement extends LitElement { background: white; } /* playground-fold-end */ - `; render() { return html`

    Let's play a game!

    - ${map(range(8), (row) => map(range(8), (col) => html` -
    ${getLabel(row, col)}
    - `))} + ${map(range(8), (row) => + map( + range(8), + (col) => html` +
    ${getLabel(row, col)}
    + `, + ), + )}
    `; } } const getColor = (row: number, col: number) => - (row + col) % 2 ? "black" : "white"; + (row + col) % 2 ? 'black' : 'white'; const getLabel = (row: number, col: number) => `${String.fromCharCode(65 + col)}${8 - row}`; diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/04/before/index.html b/packages/lit-dev-content/samples/tutorials/working-with-lists/04/before/index.html index a332734e2..3e7a17991 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/04/before/index.html +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/04/before/index.html @@ -1,4 +1,4 @@ - + diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/04/before/my-element.ts b/packages/lit-dev-content/samples/tutorials/working-with-lists/04/before/my-element.ts index 46c0e8e3b..a858d6b4c 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/04/before/my-element.ts +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/04/before/my-element.ts @@ -31,7 +31,6 @@ class MyElement extends LitElement { background: white; } /* playground-fold-end */ - `; render() { diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/05/after/index.html b/packages/lit-dev-content/samples/tutorials/working-with-lists/05/after/index.html index a332734e2..3e7a17991 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/05/after/index.html +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/05/after/index.html @@ -1,4 +1,4 @@ - + diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/05/after/my-element.ts b/packages/lit-dev-content/samples/tutorials/working-with-lists/05/after/my-element.ts index 449c3537e..db9c55cc6 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/05/after/my-element.ts +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/05/after/my-element.ts @@ -6,10 +6,10 @@ import {repeat} from 'lit/directives/repeat.js'; class MyElement extends LitElement { @state() tasks = [ - { id: 'a', label: 'Learn Lit'}, - { id: 'b', label: 'Feed the cat'}, - { id: 'c', label: 'Go for a walk'}, - { id: 'd', label: 'Take a nap'}, + {id: 'a', label: 'Learn Lit'}, + {id: 'b', label: 'Feed the cat'}, + {id: 'c', label: 'Go for a walk'}, + {id: 'd', label: 'Take a nap'}, ]; render() { @@ -25,7 +25,7 @@ class MyElement extends LitElement {
  • - ` + `, )} `; diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/05/before/index.html b/packages/lit-dev-content/samples/tutorials/working-with-lists/05/before/index.html index a332734e2..3e7a17991 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/05/before/index.html +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/05/before/index.html @@ -1,4 +1,4 @@ - + diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/05/before/my-element.ts b/packages/lit-dev-content/samples/tutorials/working-with-lists/05/before/my-element.ts index 52cbeb6d8..54d903cb3 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/05/before/my-element.ts +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/05/before/my-element.ts @@ -1,17 +1,17 @@ import {LitElement, html} from 'lit'; import {customElement, state} from 'lit/decorators.js'; -import {map} from 'lit/directives/map.js' +import {map} from 'lit/directives/map.js'; // TODO: import repeat directive. @customElement('my-element') class MyElement extends LitElement { @state() tasks = [ - { id: 'a', label: 'Learn Lit'}, - { id: 'b', label: 'Feed the cat'}, - { id: 'c', label: 'Go for a walk'}, - { id: 'd', label: 'Take a nap'}, - ] + {id: 'a', label: 'Learn Lit'}, + {id: 'b', label: 'Feed the cat'}, + {id: 'c', label: 'Go for a walk'}, + {id: 'd', label: 'Take a nap'}, + ]; render() { return html` @@ -26,7 +26,7 @@ class MyElement extends LitElement {
  • - ` + `, )} `; diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/06/before/index.html b/packages/lit-dev-content/samples/tutorials/working-with-lists/06/before/index.html index a332734e2..3e7a17991 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/06/before/index.html +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/06/before/index.html @@ -1,4 +1,4 @@ - + diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/06/before/my-element.ts b/packages/lit-dev-content/samples/tutorials/working-with-lists/06/before/my-element.ts index 34d740b9a..23aabd700 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/06/before/my-element.ts +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/06/before/my-element.ts @@ -6,10 +6,10 @@ import {map} from 'lit/directives/map.js'; class MyElement extends LitElement { @state() things = [ - "Raindrops on roses", - "Whiskers on kittens", - "Bright copper kettles", - "Warm woolen mittens", + 'Raindrops on roses', + 'Whiskers on kittens', + 'Bright copper kettles', + 'Warm woolen mittens', ]; render() { @@ -24,7 +24,7 @@ class MyElement extends LitElement { ${thing} - ` + `, )} `; diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/07/before/index.html b/packages/lit-dev-content/samples/tutorials/working-with-lists/07/before/index.html index a332734e2..3e7a17991 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/07/before/index.html +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/07/before/index.html @@ -1,4 +1,4 @@ - + diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/07/before/my-element.ts b/packages/lit-dev-content/samples/tutorials/working-with-lists/07/before/my-element.ts index a92736926..48ec55ed8 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/07/before/my-element.ts +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/07/before/my-element.ts @@ -6,10 +6,10 @@ import {map} from 'lit/directives/map.js'; class MyElement extends LitElement { @state() things = [ - "Raindrops on roses", - "Whiskers on kittens", - "Bright copper kettles", - "Warm woolen mittens", + 'Raindrops on roses', + 'Whiskers on kittens', + 'Bright copper kettles', + 'Warm woolen mittens', ]; render() { @@ -23,7 +23,7 @@ class MyElement extends LitElement { ${thing} - ` + `, )} `; diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/description.md b/packages/lit-dev-content/samples/tutorials/working-with-lists/description.md index 3baec8417..31f9a3f59 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/description.md +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/description.md @@ -1 +1 @@ -Learn how to take a list of items and render it on the page in multiple ways. \ No newline at end of file +Learn how to take a list of items and render it on the page in multiple ways. diff --git a/packages/lit-dev-content/samples/tutorials/working-with-lists/tutorial.json b/packages/lit-dev-content/samples/tutorials/working-with-lists/tutorial.json index 88a392e15..ebc9b9700 100644 --- a/packages/lit-dev-content/samples/tutorials/working-with-lists/tutorial.json +++ b/packages/lit-dev-content/samples/tutorials/working-with-lists/tutorial.json @@ -39,4 +39,4 @@ "noSolve": true } ] -} \ No newline at end of file +} diff --git a/packages/lit-dev-content/samples/v2-docs/components/events/comm/my-dispatcher.ts b/packages/lit-dev-content/samples/v2-docs/components/events/comm/my-dispatcher.ts index 10e31167a..70355d533 100644 --- a/packages/lit-dev-content/samples/v2-docs/components/events/comm/my-dispatcher.ts +++ b/packages/lit-dev-content/samples/v2-docs/components/events/comm/my-dispatcher.ts @@ -9,13 +9,20 @@ class MyDispatcher extends LitElement { private _resetMessage?: ReturnType; protected render() { return html` - +
    ${this.message}
    `; } private _tryChange(e: Event) { const detail = {message: this.message}; - const event = new CustomEvent('checked', {detail, bubbles: true, composed: true, cancelable: true}); + const event = new CustomEvent('checked', { + detail, + bubbles: true, + composed: true, + cancelable: true, + }); this.dispatchEvent(event); if (event.defaultPrevented) { e.preventDefault(); @@ -24,7 +31,9 @@ class MyDispatcher extends LitElement { } protected updated() { clearTimeout(this._resetMessage); - this._resetMessage = - setTimeout(() => this.message = this.defaultMessage, 1000); + this._resetMessage = setTimeout( + () => (this.message = this.defaultMessage), + 1000, + ); } } diff --git a/packages/lit-dev-content/samples/v2-docs/components/events/comm/my-listener.ts b/packages/lit-dev-content/samples/v2-docs/components/events/comm/my-listener.ts index c2acc3166..92d4df166 100644 --- a/packages/lit-dev-content/samples/v2-docs/components/events/comm/my-listener.ts +++ b/packages/lit-dev-content/samples/v2-docs/components/events/comm/my-listener.ts @@ -5,9 +5,8 @@ import {customElement, property} from 'lit/decorators.js'; class MyListener extends LitElement { @property() canCheck = false; protected render() { - return html` -

    -
    + return html`

    +

    ${this.canCheck ? 'Allowing' : 'Preventing'} check

    `; } diff --git a/packages/lit-dev-content/samples/v2-docs/components/events/delegation/my-element.ts b/packages/lit-dev-content/samples/v2-docs/components/events/delegation/my-element.ts index c8f8b534d..de0390ff5 100644 --- a/packages/lit-dev-content/samples/v2-docs/components/events/delegation/my-element.ts +++ b/packages/lit-dev-content/samples/v2-docs/components/events/delegation/my-element.ts @@ -15,7 +15,9 @@ class MyElement extends LitElement { `; } private _clickHandler(e: Event) { - this.clicked = e.target === e.currentTarget ? - 'container' : (e.target as HTMLDivElement).textContent!; + this.clicked = + e.target === e.currentTarget + ? 'container' + : (e.target as HTMLDivElement).textContent!; } } diff --git a/packages/lit-dev-content/samples/v2-docs/components/events/dispatch/my-dispatcher.ts b/packages/lit-dev-content/samples/v2-docs/components/events/dispatch/my-dispatcher.ts index 3e64679ff..98b1c332d 100644 --- a/packages/lit-dev-content/samples/v2-docs/components/events/dispatch/my-dispatcher.ts +++ b/packages/lit-dev-content/samples/v2-docs/components/events/dispatch/my-dispatcher.ts @@ -6,7 +6,7 @@ class MyDispatcher extends LitElement { @query('input', true) _input!: HTMLInputElement; protected render() { return html` -

    Name:

    +

    Name:

    `; } @@ -16,7 +16,7 @@ class MyDispatcher extends LitElement { const options = { detail: {name}, bubbles: true, - composed: true + composed: true, }; this.dispatchEvent(new CustomEvent('mylogin', options)); } diff --git a/packages/lit-dev-content/samples/v2-docs/components/events/dispatch/my-listener.ts b/packages/lit-dev-content/samples/v2-docs/components/events/dispatch/my-listener.ts index 48ac9d745..83fa2d926 100644 --- a/packages/lit-dev-content/samples/v2-docs/components/events/dispatch/my-listener.ts +++ b/packages/lit-dev-content/samples/v2-docs/components/events/dispatch/my-listener.ts @@ -4,8 +4,7 @@ import {customElement, property} from 'lit/decorators.js'; class MyListener extends LitElement { @property() name = ''; protected render() { - return html` -

    + return html`

    Login: ${this.name}

    `; } private _loginListener(e: CustomEvent) { diff --git a/packages/lit-dev-content/samples/v2-docs/components/events/host/my-element.ts b/packages/lit-dev-content/samples/v2-docs/components/events/host/my-element.ts index ee0bb9430..b0f923ffb 100644 --- a/packages/lit-dev-content/samples/v2-docs/components/events/host/my-element.ts +++ b/packages/lit-dev-content/samples/v2-docs/components/events/host/my-element.ts @@ -6,13 +6,17 @@ class MyElement extends LitElement { @property() shadowName = ''; constructor() { super(); - this.addEventListener('click', - (e: Event) => this.hostName = (e.target as Element).localName); + this.addEventListener( + 'click', + (e: Event) => (this.hostName = (e.target as Element).localName), + ); } protected createRenderRoot() { const root = super.createRenderRoot(); - root.addEventListener('click', - (e: Event) => this.shadowName = (e.target as Element).localName); + root.addEventListener( + 'click', + (e: Event) => (this.shadowName = (e.target as Element).localName), + ); return root; } protected render() { diff --git a/packages/lit-dev-content/samples/v2-docs/components/events/list/my-element.ts b/packages/lit-dev-content/samples/v2-docs/components/events/list/my-element.ts index 39ea50868..4ef305cd4 100644 --- a/packages/lit-dev-content/samples/v2-docs/components/events/list/my-element.ts +++ b/packages/lit-dev-content/samples/v2-docs/components/events/list/my-element.ts @@ -8,9 +8,11 @@ class MyElement extends LitElement { protected render() { return html`
    - ${this.data.map(i => html` - - `)} + ${this.data.map( + (i) => html` + + `, + )}

    Clicked: ${this.clicked}

    Focused: ${this.focused}

    diff --git a/packages/lit-dev-content/samples/v2-docs/components/events/update/my-dispatcher.ts b/packages/lit-dev-content/samples/v2-docs/components/events/update/my-dispatcher.ts index c4d722319..2f9513237 100644 --- a/packages/lit-dev-content/samples/v2-docs/components/events/update/my-dispatcher.ts +++ b/packages/lit-dev-content/samples/v2-docs/components/events/update/my-dispatcher.ts @@ -6,7 +6,9 @@ class MyDispatcher extends LitElement { @property({type: Boolean}) open = true; protected render() { return html` -

    +

    + +

    Content!

    `; } diff --git a/packages/lit-dev-content/samples/v2-docs/components/events/update/my-listener.ts b/packages/lit-dev-content/samples/v2-docs/components/events/update/my-listener.ts index ecf396e38..b64b2a4d1 100644 --- a/packages/lit-dev-content/samples/v2-docs/components/events/update/my-listener.ts +++ b/packages/lit-dev-content/samples/v2-docs/components/events/update/my-listener.ts @@ -3,10 +3,11 @@ import {customElement, property} from 'lit/decorators.js'; @customElement('my-listener') class MyListener extends LitElement { - @property({type: Number}) height: number|null = null; + @property({type: Number}) height: number | null = null; protected render() { - return html` -

    + return html`

    + +

    Height: ${this.height}px

    `; } private _listener() { @@ -14,7 +15,9 @@ class MyListener extends LitElement { } protected updated() { if (this.height === null) { - requestAnimationFrame(() => this.height = this.getBoundingClientRect().height); + requestAnimationFrame( + () => (this.height = this.getBoundingClientRect().height), + ); } } } diff --git a/packages/lit-dev-content/samples/v2-docs/components/overview/simple-greeting/index.html b/packages/lit-dev-content/samples/v2-docs/components/overview/simple-greeting/index.html index 41814caa5..e0d58f0cb 100644 --- a/packages/lit-dev-content/samples/v2-docs/components/overview/simple-greeting/index.html +++ b/packages/lit-dev-content/samples/v2-docs/components/overview/simple-greeting/index.html @@ -1,14 +1,14 @@ - + - - - - + + + + - - Lit code sample - - - - + + Lit code sample + + + + diff --git a/packages/lit-dev-content/samples/v2-docs/components/shadowdom/namedslots/index.html b/packages/lit-dev-content/samples/v2-docs/components/shadowdom/namedslots/index.html index 9bf7f3473..575cf9ad3 100644 --- a/packages/lit-dev-content/samples/v2-docs/components/shadowdom/namedslots/index.html +++ b/packages/lit-dev-content/samples/v2-docs/components/shadowdom/namedslots/index.html @@ -4,7 +4,7 @@

    Include me in slot "two".

    -
    +

    Include me in slot "one".

    diff --git a/packages/lit-dev-content/samples/v2-docs/components/shadowdom/renderroot/default-root.ts b/packages/lit-dev-content/samples/v2-docs/components/shadowdom/renderroot/default-root.ts index 3d3210226..e04aab141 100644 --- a/packages/lit-dev-content/samples/v2-docs/components/shadowdom/renderroot/default-root.ts +++ b/packages/lit-dev-content/samples/v2-docs/components/shadowdom/renderroot/default-root.ts @@ -4,8 +4,6 @@ import {customElement} from 'lit/decorators.js'; @customElement('default-root') export class DefaultRoot extends LitElement { protected render() { - return html` -

    By default template renders into shadow DOM.

    - `; + return html`

    By default template renders into shadow DOM.

    `; } } diff --git a/packages/lit-dev-content/samples/v2-docs/components/shadowdom/renderroot/index.html b/packages/lit-dev-content/samples/v2-docs/components/shadowdom/renderroot/index.html index 68192b58c..ae4ed4c95 100644 --- a/packages/lit-dev-content/samples/v2-docs/components/shadowdom/renderroot/index.html +++ b/packages/lit-dev-content/samples/v2-docs/components/shadowdom/renderroot/index.html @@ -1,4 +1,4 @@ - + diff --git a/packages/lit-dev-content/samples/v2-docs/components/shadowdom/slots/index.html b/packages/lit-dev-content/samples/v2-docs/components/shadowdom/slots/index.html index c4385b0f0..bc48d1d54 100644 --- a/packages/lit-dev-content/samples/v2-docs/components/shadowdom/slots/index.html +++ b/packages/lit-dev-content/samples/v2-docs/components/shadowdom/slots/index.html @@ -4,7 +4,7 @@

    Render me in a slot

    -
    +

    Render me in a slot

    diff --git a/packages/lit-dev-content/samples/v2-docs/components/style/maps/my-element.ts b/packages/lit-dev-content/samples/v2-docs/components/style/maps/my-element.ts index 95edb6d42..e5bea60ed 100644 --- a/packages/lit-dev-content/samples/v2-docs/components/style/maps/my-element.ts +++ b/packages/lit-dev-content/samples/v2-docs/components/style/maps/my-element.ts @@ -6,13 +6,18 @@ import {styleMap} from 'lit/directives/style-map.js'; @customElement('my-element') export class MyElement extends LitElement { static styles = css` - .someclass { border: 1px solid red; padding: 4px; } - .anotherclass { background-color: navy; } + .someclass { + border: 1px solid red; + padding: 4px; + } + .anotherclass { + background-color: navy; + } `; @property() - classes = { someclass: true, anotherclass: true }; + classes = {someclass: true, anotherclass: true}; @property() - styles = { color: 'lightgreen', fontFamily: 'Roboto' }; + styles = {color: 'lightgreen', fontFamily: 'Roboto'}; protected render() { return html`
    diff --git a/packages/lit-dev-content/samples/v2-docs/components/style/slottedselector/my-element.ts b/packages/lit-dev-content/samples/v2-docs/components/style/slottedselector/my-element.ts index 69c4ccd59..8771fc843 100644 --- a/packages/lit-dev-content/samples/v2-docs/components/style/slottedselector/my-element.ts +++ b/packages/lit-dev-content/samples/v2-docs/components/style/slottedselector/my-element.ts @@ -4,9 +4,15 @@ import {customElement} from 'lit/decorators.js'; @customElement('my-element') export class MyElement extends LitElement { static styles = css` - ::slotted(*) { font-family: Roboto; } - ::slotted(p) { color: blue; } - div ::slotted(*) { color: red; } + ::slotted(*) { + font-family: Roboto; + } + ::slotted(p) { + color: blue; + } + div ::slotted(*) { + color: red; + } `; protected render() { return html` diff --git a/packages/lit-dev-content/samples/v2-docs/components/style/superstyles/my-element.ts b/packages/lit-dev-content/samples/v2-docs/components/style/superstyles/my-element.ts index 2a2551aa7..cb381ae30 100644 --- a/packages/lit-dev-content/samples/v2-docs/components/style/superstyles/my-element.ts +++ b/packages/lit-dev-content/samples/v2-docs/components/style/superstyles/my-element.ts @@ -6,8 +6,10 @@ import {SuperElement} from './super-element.js'; export class MyElement extends SuperElement { static styles = [ SuperElement.styles, - css`div { - color: red; - }` + css` + div { + color: red; + } + `, ]; } diff --git a/packages/lit-dev-content/samples/v2-docs/components/style/superstyles/super-element.ts b/packages/lit-dev-content/samples/v2-docs/components/style/superstyles/super-element.ts index 9e2a75b98..0d99805b7 100644 --- a/packages/lit-dev-content/samples/v2-docs/components/style/superstyles/super-element.ts +++ b/packages/lit-dev-content/samples/v2-docs/components/style/superstyles/super-element.ts @@ -10,8 +10,6 @@ export class SuperElement extends LitElement { } ` as CSSResultGroup; protected render() { - return html` -
    Content
    - `; + return html`
    Content
    `; } } diff --git a/packages/lit-dev-content/samples/v2-docs/composition/mediator-pattern/index.html b/packages/lit-dev-content/samples/v2-docs/composition/mediator-pattern/index.html index c8ac8f56d..305c46f49 100644 --- a/packages/lit-dev-content/samples/v2-docs/composition/mediator-pattern/index.html +++ b/packages/lit-dev-content/samples/v2-docs/composition/mediator-pattern/index.html @@ -1,14 +1,14 @@ - + - - - - + + + + - - Lit code sample - - - - + + Lit code sample + + + + diff --git a/packages/lit-dev-content/samples/v2-docs/composition/mediator-pattern/mediator-element.ts b/packages/lit-dev-content/samples/v2-docs/composition/mediator-pattern/mediator-element.ts index 5bb0576cd..d089ace83 100644 --- a/packages/lit-dev-content/samples/v2-docs/composition/mediator-pattern/mediator-element.ts +++ b/packages/lit-dev-content/samples/v2-docs/composition/mediator-pattern/mediator-element.ts @@ -28,10 +28,12 @@ export class MediatorElement extends LitElement { render() { return html`

    Nickname: ${this.name}

    - - `; + + `; } } diff --git a/packages/lit-dev-content/samples/v2-docs/controllers/mouse/my-element.ts b/packages/lit-dev-content/samples/v2-docs/controllers/mouse/my-element.ts index e2a3c42f9..85ddfdc04 100644 --- a/packages/lit-dev-content/samples/v2-docs/controllers/mouse/my-element.ts +++ b/packages/lit-dev-content/samples/v2-docs/controllers/mouse/my-element.ts @@ -12,7 +12,8 @@ class MyElement extends LitElement {
             x: ${this.mouse.pos.x as number}
             y: ${this.mouse.pos.y as number}
    -      
    + `; } } diff --git a/packages/lit-dev-content/samples/v2-docs/controllers/names/my-element.ts b/packages/lit-dev-content/samples/v2-docs/controllers/names/my-element.ts index 2c9d29ba7..a1204dd4b 100644 --- a/packages/lit-dev-content/samples/v2-docs/controllers/names/my-element.ts +++ b/packages/lit-dev-content/samples/v2-docs/controllers/names/my-element.ts @@ -8,23 +8,22 @@ export class MyElement extends LitElement { private names = new NamesController(this); render() { - return html` -

    Names List

    - Kind: - ${this.names.render({ - complete: (result: Names.Result) => html` -

    List of ${this.names.kind}

    -
      ${result.map(i => html`
    • ${i.name}
    • `)} -
    - `, - initial: () => html`

    Select a kind...

    `, - pending: () => html`

    Loading ${this.names.kind}...

    `, - error: (e: any) => html`

    ${e}

    ` - })}`; + return html`

    Names List

    + Kind: + + ${this.names.render({ + complete: (result: Names.Result) => html` +

    List of ${this.names.kind}

    +
      + ${result.map((i) => html`
    • ${i.name}
    • `)} +
    + `, + initial: () => html`

    Select a kind...

    `, + pending: () => html`

    Loading ${this.names.kind}...

    `, + error: (e: any) => html`

    ${e}

    `, + })}`; } private _kindChange(e: Event) { diff --git a/packages/lit-dev-content/samples/v2-docs/controllers/names/names-api.ts b/packages/lit-dev-content/samples/v2-docs/controllers/names/names-api.ts index c9e013425..71a1174cb 100644 --- a/packages/lit-dev-content/samples/v2-docs/controllers/names/names-api.ts +++ b/packages/lit-dev-content/samples/v2-docs/controllers/names/names-api.ts @@ -1,5 +1,5 @@ export type Result = Array<{name: string}>; -export type Kind = typeof kinds[number]; +export type Kind = (typeof kinds)[number]; export const baseUrl = 'https://swapi.py4e.com/api/'; @@ -10,5 +10,5 @@ export const kinds = [ 'species', 'planets', // Inserted to demo an error state. - 'error' + 'error', ] as const; diff --git a/packages/lit-dev-content/samples/v2-docs/controllers/names/names-controller.ts b/packages/lit-dev-content/samples/v2-docs/controllers/names/names-controller.ts index decb19631..48417c4e6 100644 --- a/packages/lit-dev-content/samples/v2-docs/controllers/names/names-controller.ts +++ b/packages/lit-dev-content/samples/v2-docs/controllers/names/names-controller.ts @@ -11,7 +11,8 @@ export class NamesController { constructor(host: ReactiveControllerHost) { this.host = host; - this.task = new Task<[Names.Kind], Names.Result>(host, + this.task = new Task<[Names.Kind], Names.Result>( + host, async ([kind]: [Names.Kind]) => { if (!kind?.trim()) { return initialState; @@ -23,7 +24,8 @@ export class NamesController { } catch { throw new Error(`Failed to fetch "${kind}"`); } - }, () => [this.kind] + }, + () => [this.kind], ); } @@ -31,7 +33,9 @@ export class NamesController { this._kind = value; this.host.requestUpdate(); } - get kind() { return this._kind; } + get kind() { + return this._kind; + } render(renderFunctions: StatusRenderer) { return this.task.render(renderFunctions); diff --git a/packages/lit-dev-content/samples/v2-docs/controllers/overview/my-element.ts b/packages/lit-dev-content/samples/v2-docs/controllers/overview/my-element.ts index 9286733c4..1cb0ee33c 100644 --- a/packages/lit-dev-content/samples/v2-docs/controllers/overview/my-element.ts +++ b/packages/lit-dev-content/samples/v2-docs/controllers/overview/my-element.ts @@ -15,5 +15,7 @@ class MyElement extends LitElement { } const timeFormat = new Intl.DateTimeFormat('en-US', { - hour: 'numeric', minute: 'numeric', second: 'numeric', + hour: 'numeric', + minute: 'numeric', + second: 'numeric', }); diff --git a/packages/lit-dev-content/samples/v2-docs/libraries/localization/runtime/index.html b/packages/lit-dev-content/samples/v2-docs/libraries/localization/runtime/index.html index 2e89f4951..92eba33e8 100644 --- a/packages/lit-dev-content/samples/v2-docs/libraries/localization/runtime/index.html +++ b/packages/lit-dev-content/samples/v2-docs/libraries/localization/runtime/index.html @@ -1,4 +1,4 @@ - + lit-localize runtime example diff --git a/packages/lit-dev-content/samples/v2-docs/libraries/localization/runtime/index.ts b/packages/lit-dev-content/samples/v2-docs/libraries/localization/runtime/index.ts index 6e9551010..cfb30f80e 100644 --- a/packages/lit-dev-content/samples/v2-docs/libraries/localization/runtime/index.ts +++ b/packages/lit-dev-content/samples/v2-docs/libraries/localization/runtime/index.ts @@ -30,7 +30,7 @@ window.addEventListener(LOCALE_STATUS_EVENT, ({detail}) => { spinner.setAttribute('hidden', ''); } else if (detail.status === 'error') { console.error( - `Error loading locale ${detail.errorLocale}: ` + detail.errorMessage + `Error loading locale ${detail.errorLocale}: ` + detail.errorMessage, ); spinner.setAttribute('hidden', ''); } diff --git a/packages/lit-dev-content/samples/v2-docs/libraries/localization/runtime/locale-picker.ts b/packages/lit-dev-content/samples/v2-docs/libraries/localization/runtime/locale-picker.ts index 59efb6d5a..de4ebe3b4 100644 --- a/packages/lit-dev-content/samples/v2-docs/libraries/localization/runtime/locale-picker.ts +++ b/packages/lit-dev-content/samples/v2-docs/libraries/localization/runtime/locale-picker.ts @@ -11,7 +11,7 @@ import {allLocales} from './locale-codes.js'; import {localized} from '@lit/localize'; const localeNames: { - [L in typeof allLocales[number]]: string; + [L in (typeof allLocales)[number]]: string; } = { en: 'English', 'es-419': 'Español (Latinoamérica)‎', @@ -31,7 +31,7 @@ export class LocalePicker extends LitElement { (locale) => html`` + `, )} `; diff --git a/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/element-one.ts b/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/element-one.ts index 94504aa63..f499d8d09 100644 --- a/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/element-one.ts +++ b/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/element-one.ts @@ -1,10 +1,10 @@ import {LitElement, html} from 'lit'; import {customElement} from 'lit/decorators.js'; -import {Highlightable} from './highlightable.js' +import {Highlightable} from './highlightable.js'; @customElement('element-one') export class ElementOne extends Highlightable(LitElement) { - render(){ + render() { return this.renderHighlight(html`

    Simple highlight

    `); } } diff --git a/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/element-two.js b/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/element-two.js index 8da1e16b3..3cc8a6e58 100644 --- a/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/element-two.js +++ b/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/element-two.js @@ -6,14 +6,20 @@ const HighlightableLitElement = Highlightable(LitElement); export class ElementTwo extends HighlightableLitElement { static styles = [ HighlightableLitElement.styles || [], - css`:host { display: block; }`, + css` + :host { + display: block; + } + `, ]; render() { return this.renderHighlight(html` `); diff --git a/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/element-two.ts b/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/element-two.ts index 0e2990047..3d694a6a6 100644 --- a/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/element-two.ts +++ b/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/element-two.ts @@ -1,6 +1,6 @@ import {LitElement, html, css} from 'lit'; import {customElement} from 'lit/decorators.js'; -import {Highlightable} from './highlightable.js' +import {Highlightable} from './highlightable.js'; const HighlightableLitElement = Highlightable(LitElement); @@ -8,14 +8,20 @@ const HighlightableLitElement = Highlightable(LitElement); export class ElementTwo extends HighlightableLitElement { static styles = [ HighlightableLitElement.styles || [], - css`:host { display: block; }` + css` + :host { + display: block; + } + `, ]; - render(){ + render() { return this.renderHighlight(html` `); diff --git a/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/highlightable.js b/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/highlightable.js index fd0fa1497..26e1873fc 100644 --- a/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/highlightable.js +++ b/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/highlightable.js @@ -11,7 +11,11 @@ export const Highlightable = (superClass) => { // Adds some styles... static styles = [ superClass.styles ?? [], - css`.highlight { background: yellow; }`, + css` + .highlight { + background: yellow; + } + `, ]; constructor() { @@ -22,10 +26,9 @@ export const Highlightable = (superClass) => { // ...and a helper render method: renderHighlight(content) { - return html` -
    - ${content} -
    `; + return html`
    + ${content} +
    `; } } return HighlightableElement; diff --git a/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/highlightable.ts b/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/highlightable.ts index c649e05e1..68f76b9ee 100644 --- a/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/highlightable.ts +++ b/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/highlightable.ts @@ -11,25 +11,29 @@ export declare class HighlightableInterface { } /* playground-fold-end */ -export const Highlightable = - >(superClass: T) => { - class HighlightableElement extends superClass { - // Adds some styles... - static styles = [ - (superClass as unknown as typeof LitElement).styles ?? [], - css`.highlight { background: yellow; }` - ]; +export const Highlightable = >( + superClass: T, +) => { + class HighlightableElement extends superClass { + // Adds some styles... + static styles = [ + (superClass as unknown as typeof LitElement).styles ?? [], + css` + .highlight { + background: yellow; + } + `, + ]; - // ...a public `highlight` property/attribute... - @property({type: Boolean}) highlight = false; + // ...a public `highlight` property/attribute... + @property({type: Boolean}) highlight = false; - // ...and a helper render method: - renderHighlight(content: unknown) { - return html` -
    - ${content} -
    `; - } - } - return HighlightableElement as Constructor & T; - }; + // ...and a helper render method: + renderHighlight(content: unknown) { + return html`
    + ${content} +
    `; + } + } + return HighlightableElement as Constructor & T; +}; diff --git a/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/index.html b/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/index.html index 6416a4125..9142728cd 100644 --- a/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/index.html +++ b/packages/lit-dev-content/samples/v2-docs/mixins/highlightable/index.html @@ -1,14 +1,14 @@ - + - - - - - - lit-element code sample - - - - - + + + + + + lit-element code sample + + + + + diff --git a/packages/lit-dev-content/samples/v2-docs/templates/compose/index.html b/packages/lit-dev-content/samples/v2-docs/templates/compose/index.html index 32dfee477..a7a3601a3 100644 --- a/packages/lit-dev-content/samples/v2-docs/templates/compose/index.html +++ b/packages/lit-dev-content/samples/v2-docs/templates/compose/index.html @@ -1,11 +1,11 @@ - + - - - - - lit-element code sample - + + + + + lit-element code sample + diff --git a/packages/lit-dev-content/samples/v2-docs/templates/compose/my-page.ts b/packages/lit-dev-content/samples/v2-docs/templates/compose/my-page.ts index cb1278529..29e9353f6 100644 --- a/packages/lit-dev-content/samples/v2-docs/templates/compose/my-page.ts +++ b/packages/lit-dev-content/samples/v2-docs/templates/compose/my-page.ts @@ -1,10 +1,8 @@ import {LitElement, html} from 'lit'; import {customElement, property} from 'lit/decorators.js'; - @customElement('my-page') class MyPage extends LitElement { - @property({attribute: false}) article = { title: 'My Nifty Article', @@ -25,8 +23,7 @@ class MyPage extends LitElement { render() { return html` - ${this.headerTemplate()} - ${this.articleTemplate()} + ${this.headerTemplate()} ${this.articleTemplate()} ${this.footerTemplate()} `; } diff --git a/packages/lit-dev-content/samples/v2-docs/templates/composeimports/index.html b/packages/lit-dev-content/samples/v2-docs/templates/composeimports/index.html index 32dfee477..a7a3601a3 100644 --- a/packages/lit-dev-content/samples/v2-docs/templates/composeimports/index.html +++ b/packages/lit-dev-content/samples/v2-docs/templates/composeimports/index.html @@ -1,11 +1,11 @@ - + - - - - - lit-element code sample - + + + + + lit-element code sample + diff --git a/packages/lit-dev-content/samples/v2-docs/templates/composeimports/my-article.ts b/packages/lit-dev-content/samples/v2-docs/templates/composeimports/my-article.ts index df8cc1e6b..97e8c2482 100644 --- a/packages/lit-dev-content/samples/v2-docs/templates/composeimports/my-article.ts +++ b/packages/lit-dev-content/samples/v2-docs/templates/composeimports/my-article.ts @@ -4,8 +4,6 @@ import {customElement} from 'lit/decorators.js'; @customElement('my-article') class MyArticle extends LitElement { render() { - return html` -
    article
    - `; + return html`
    article
    `; } } diff --git a/packages/lit-dev-content/samples/v2-docs/templates/composeimports/my-footer.ts b/packages/lit-dev-content/samples/v2-docs/templates/composeimports/my-footer.ts index 5a7bb688e..2bc0a910b 100644 --- a/packages/lit-dev-content/samples/v2-docs/templates/composeimports/my-footer.ts +++ b/packages/lit-dev-content/samples/v2-docs/templates/composeimports/my-footer.ts @@ -4,8 +4,6 @@ import {customElement} from 'lit/decorators.js'; @customElement('my-footer') class MyFooter extends LitElement { render() { - return html` -
    footer
    - `; + return html`
    footer
    `; } } diff --git a/packages/lit-dev-content/samples/v2-docs/templates/composeimports/my-header.ts b/packages/lit-dev-content/samples/v2-docs/templates/composeimports/my-header.ts index 29a4af465..8014f775a 100644 --- a/packages/lit-dev-content/samples/v2-docs/templates/composeimports/my-header.ts +++ b/packages/lit-dev-content/samples/v2-docs/templates/composeimports/my-header.ts @@ -4,8 +4,6 @@ import {customElement} from 'lit/decorators.js'; @customElement('my-header') class MyHeader extends LitElement { render() { - return html` -
    header
    - `; + return html`
    header
    `; } } diff --git a/packages/lit-dev-content/samples/v2-docs/templates/define/index.html b/packages/lit-dev-content/samples/v2-docs/templates/define/index.html index 241701161..8c658e1b2 100644 --- a/packages/lit-dev-content/samples/v2-docs/templates/define/index.html +++ b/packages/lit-dev-content/samples/v2-docs/templates/define/index.html @@ -1,12 +1,12 @@ - + - - - - - Lit code sample - - - - + + + + + Lit code sample + + + + diff --git a/packages/lit-dev-content/samples/v2-docs/templates/define/my-element.ts b/packages/lit-dev-content/samples/v2-docs/templates/define/my-element.ts index d4c96c980..7934ac8fe 100644 --- a/packages/lit-dev-content/samples/v2-docs/templates/define/my-element.ts +++ b/packages/lit-dev-content/samples/v2-docs/templates/define/my-element.ts @@ -3,8 +3,7 @@ import {customElement} from 'lit/decorators.js'; @customElement('my-element') class MyElement extends LitElement { - - render(){ + render() { return html`

    Hello from my template.

    `; } } diff --git a/packages/lit-dev-content/samples/v2-docs/templates/design/index.html b/packages/lit-dev-content/samples/v2-docs/templates/design/index.html index cb310edd0..674e46248 100644 --- a/packages/lit-dev-content/samples/v2-docs/templates/design/index.html +++ b/packages/lit-dev-content/samples/v2-docs/templates/design/index.html @@ -1,12 +1,12 @@ - + - - - - - lit-element code sample - - - - + + + + + lit-element code sample + + + + diff --git a/packages/lit-dev-content/samples/v2-docs/templates/design/update-properties.ts b/packages/lit-dev-content/samples/v2-docs/templates/design/update-properties.ts index b0b6a2bad..982dd1aba 100644 --- a/packages/lit-dev-content/samples/v2-docs/templates/design/update-properties.ts +++ b/packages/lit-dev-content/samples/v2-docs/templates/design/update-properties.ts @@ -3,19 +3,16 @@ import {customElement, property} from 'lit/decorators.js'; @customElement('update-properties') class UpdateProperties extends LitElement { - @property() message: string = 'Loading...'; constructor() { super(); - this.loadStuff().then((content) => this.message = content); + this.loadStuff().then((content) => (this.message = content)); } render() { - return html` -

    ${this.message}

    - `; + return html`

    ${this.message}

    `; } loadStuff() { diff --git a/packages/lit-dev-content/samples/v2-docs/templates/expressions/my-element.ts b/packages/lit-dev-content/samples/v2-docs/templates/expressions/my-element.ts index 20651bbdf..73279aac7 100644 --- a/packages/lit-dev-content/samples/v2-docs/templates/expressions/my-element.ts +++ b/packages/lit-dev-content/samples/v2-docs/templates/expressions/my-element.ts @@ -10,13 +10,16 @@ class MyElement extends LitElement { /* playground-fold-end */ render() { - return html` -

    + return html`

    ${this.greeting} - +

    - ${this.show ? html` -
      ${this.todos.map(i => html`
    • ${i}
    • `)}
    - ` : ''}`; - }/* playground-fold */ + ${this.show + ? html` +
      + ${this.todos.map((i) => html`
    • ${i}
    • `)} +
    + ` + : ''}`; + } /* playground-fold */ } diff --git a/packages/lit-dev-content/samples/v2-docs/templates/lists-arrays/index.html b/packages/lit-dev-content/samples/v2-docs/templates/lists-arrays/index.html index fe1517255..f149c266f 100644 --- a/packages/lit-dev-content/samples/v2-docs/templates/lists-arrays/index.html +++ b/packages/lit-dev-content/samples/v2-docs/templates/lists-arrays/index.html @@ -1,5 +1,7 @@ diff --git a/packages/lit-dev-content/samples/v2-docs/templates/lists-arrays/my-element.js b/packages/lit-dev-content/samples/v2-docs/templates/lists-arrays/my-element.js index fb56fe7af..5ad5cb829 100644 --- a/packages/lit-dev-content/samples/v2-docs/templates/lists-arrays/my-element.js +++ b/packages/lit-dev-content/samples/v2-docs/templates/lists-arrays/my-element.js @@ -2,22 +2,21 @@ import {LitElement, html} from 'lit'; class MyElement extends LitElement { -/* playground-fold-end */ - -static properties = { - colors: {}, -}; + /* playground-fold-end */ -constructor() { - super(); - this.colors = ['red', 'green', 'blue']; -} + static properties = { + colors: {}, + }; -render() { - return html`

    Colors: ${this.colors}

    `; -} -/* playground-fold */ + constructor() { + super(); + this.colors = ['red', 'green', 'blue']; + } + render() { + return html`

    Colors: ${this.colors}

    `; + } + /* playground-fold */ } customElements.define('my-element', MyElement); /* playground-fold-end */ diff --git a/packages/lit-dev-content/samples/v2-docs/templates/lists-arrays/my-element.ts b/packages/lit-dev-content/samples/v2-docs/templates/lists-arrays/my-element.ts index e90fffa67..76539b680 100644 --- a/packages/lit-dev-content/samples/v2-docs/templates/lists-arrays/my-element.ts +++ b/packages/lit-dev-content/samples/v2-docs/templates/lists-arrays/my-element.ts @@ -4,14 +4,13 @@ import {customElement, property} from 'lit/decorators.js'; @customElement('my-element') class MyElement extends LitElement { -/* playground-fold-end */ - -@property() colors = ['red', 'green', 'blue']; + /* playground-fold-end */ -render() { - return html`

    Colors: ${this.colors}

    `; -} -/* playground-fold */ + @property() colors = ['red', 'green', 'blue']; + render() { + return html`

    Colors: ${this.colors}

    `; + } + /* playground-fold */ } /* playground-fold-end */ diff --git a/packages/lit-dev-content/samples/v2-docs/templates/lists-map/index.html b/packages/lit-dev-content/samples/v2-docs/templates/lists-map/index.html index fe1517255..f149c266f 100644 --- a/packages/lit-dev-content/samples/v2-docs/templates/lists-map/index.html +++ b/packages/lit-dev-content/samples/v2-docs/templates/lists-map/index.html @@ -1,5 +1,7 @@ diff --git a/packages/lit-dev-content/samples/v2-docs/templates/lists-map/my-element.js b/packages/lit-dev-content/samples/v2-docs/templates/lists-map/my-element.js index 18b0fc2f0..392746450 100644 --- a/packages/lit-dev-content/samples/v2-docs/templates/lists-map/my-element.js +++ b/packages/lit-dev-content/samples/v2-docs/templates/lists-map/my-element.js @@ -2,28 +2,27 @@ import {LitElement, html} from 'lit'; class MyElement extends LitElement { -/* playground-fold-end */ - -static properties = { - colors: {}, -}; + /* playground-fold-end */ -constructor() { - super(); - this.colors = ['red', 'green', 'blue']; -} + static properties = { + colors: {}, + }; -render() { - return html` -
      - ${this.colors.map((color) => - html`
    • ${color}
    • ` - )} -
    - `; -} -/* playground-fold */ + constructor() { + super(); + this.colors = ['red', 'green', 'blue']; + } + render() { + return html` +
      + ${this.colors.map( + (color) => html`
    • ${color}
    • `, + )} +
    + `; + } + /* playground-fold */ } customElements.define('my-element', MyElement); /* playground-fold-end */ diff --git a/packages/lit-dev-content/samples/v2-docs/templates/lists-map/my-element.ts b/packages/lit-dev-content/samples/v2-docs/templates/lists-map/my-element.ts index 97fb8afa3..11ac98748 100644 --- a/packages/lit-dev-content/samples/v2-docs/templates/lists-map/my-element.ts +++ b/packages/lit-dev-content/samples/v2-docs/templates/lists-map/my-element.ts @@ -4,20 +4,19 @@ import {customElement, property} from 'lit/decorators.js'; @customElement('my-element') class MyElement extends LitElement { -/* playground-fold-end */ - -@property() colors = ['red', 'green', 'blue']; + /* playground-fold-end */ -render() { - return html` -
      - ${this.colors.map((color) => - html`
    • ${color}
    • ` - )} -
    - `; -} -/* playground-fold */ + @property() colors = ['red', 'green', 'blue']; + render() { + return html` +
      + ${this.colors.map( + (color) => html`
    • ${color}
    • `, + )} +
    + `; + } + /* playground-fold */ } /* playground-fold-end */ diff --git a/packages/lit-dev-content/samples/v2-docs/templates/lists-repeat/index.html b/packages/lit-dev-content/samples/v2-docs/templates/lists-repeat/index.html index fe1517255..f149c266f 100644 --- a/packages/lit-dev-content/samples/v2-docs/templates/lists-repeat/index.html +++ b/packages/lit-dev-content/samples/v2-docs/templates/lists-repeat/index.html @@ -1,5 +1,7 @@ diff --git a/packages/lit-dev-content/samples/v2-docs/templates/lists-repeat/my-element.ts b/packages/lit-dev-content/samples/v2-docs/templates/lists-repeat/my-element.ts index 9a48488ae..db180c68c 100644 --- a/packages/lit-dev-content/samples/v2-docs/templates/lists-repeat/my-element.ts +++ b/packages/lit-dev-content/samples/v2-docs/templates/lists-repeat/my-element.ts @@ -8,35 +8,42 @@ import {repeat} from 'lit/directives/repeat.js'; @customElement('my-element') class MyElement extends LitElement { + private sort = 1; -private sort = 1; + @property() employees = [ + {id: 0, givenName: 'Fred', familyName: 'Flintstone'}, + {id: 1, givenName: 'George', familyName: 'Jetson'}, + {id: 2, givenName: 'Barney', familyName: 'Rubble'}, + {id: 3, givenName: 'Cosmo', familyName: 'Spacely'}, + ]; + /* playground-fold-end */ -@property() employees = [ - {id: 0, givenName: 'Fred', familyName: 'Flintstone'}, - {id: 1, givenName: 'George', familyName: 'Jetson'}, - {id: 2, givenName: 'Barney', familyName: 'Rubble'}, - {id: 3, givenName: 'Cosmo', familyName: 'Spacely'} -]; -/* playground-fold-end */ - -render() { - return html` -
      - ${repeat(this.employees, (employee) => employee.id, (employee, index) => html` -
    • ${index}: ${employee.familyName}, ${employee.givenName}
    • - `)} -
    - - `; -} -/* playground-fold */ - -private toggleSort() { - this.sort *= -1; - this.employees = [...this.employees.sort((a, b) => - this.sort * (a.familyName.localeCompare(b.familyName) || - a.givenName.localeCompare(b.givenName)))]; -} + render() { + return html` +
      + ${repeat( + this.employees, + (employee) => employee.id, + (employee, index) => html` +
    • ${index}: ${employee.familyName}, ${employee.givenName}
    • + `, + )} +
    + + `; + } + /* playground-fold */ + private toggleSort() { + this.sort *= -1; + this.employees = [ + ...this.employees.sort( + (a, b) => + this.sort * + (a.familyName.localeCompare(b.familyName) || + a.givenName.localeCompare(b.givenName)), + ), + ]; + } } /* playground-fold-end */ diff --git a/packages/lit-dev-content/samples/v2-docs/what-is-lit/icons.ts b/packages/lit-dev-content/samples/v2-docs/what-is-lit/icons.ts index 2d149f146..91233aaec 100644 --- a/packages/lit-dev-content/samples/v2-docs/what-is-lit/icons.ts +++ b/packages/lit-dev-content/samples/v2-docs/what-is-lit/icons.ts @@ -1,5 +1,45 @@ import {html} from 'lit'; -export const replay = html`Replay`; -export const pause = html`Pause`; -export const play = html`Play`; +export const replay = html` + Replay + + + + + + + + + +`; +export const pause = html` + Pause + + +`; +export const play = html` + Play + + +`; diff --git a/packages/lit-dev-content/samples/v2-docs/what-is-lit/index.html b/packages/lit-dev-content/samples/v2-docs/what-is-lit/index.html index 00c26fcf6..243f398fb 100644 --- a/packages/lit-dev-content/samples/v2-docs/what-is-lit/index.html +++ b/packages/lit-dev-content/samples/v2-docs/what-is-lit/index.html @@ -1,7 +1,11 @@ - - - + + + + diff --git a/packages/lit-dev-content/samples/v3-docs/templates/lists-arrays/my-element.js b/packages/lit-dev-content/samples/v3-docs/templates/lists-arrays/my-element.js index fb56fe7af..5ad5cb829 100644 --- a/packages/lit-dev-content/samples/v3-docs/templates/lists-arrays/my-element.js +++ b/packages/lit-dev-content/samples/v3-docs/templates/lists-arrays/my-element.js @@ -2,22 +2,21 @@ import {LitElement, html} from 'lit'; class MyElement extends LitElement { -/* playground-fold-end */ - -static properties = { - colors: {}, -}; + /* playground-fold-end */ -constructor() { - super(); - this.colors = ['red', 'green', 'blue']; -} + static properties = { + colors: {}, + }; -render() { - return html`

    Colors: ${this.colors}

    `; -} -/* playground-fold */ + constructor() { + super(); + this.colors = ['red', 'green', 'blue']; + } + render() { + return html`

    Colors: ${this.colors}

    `; + } + /* playground-fold */ } customElements.define('my-element', MyElement); /* playground-fold-end */ diff --git a/packages/lit-dev-content/samples/v3-docs/templates/lists-arrays/my-element.ts b/packages/lit-dev-content/samples/v3-docs/templates/lists-arrays/my-element.ts index e90fffa67..76539b680 100644 --- a/packages/lit-dev-content/samples/v3-docs/templates/lists-arrays/my-element.ts +++ b/packages/lit-dev-content/samples/v3-docs/templates/lists-arrays/my-element.ts @@ -4,14 +4,13 @@ import {customElement, property} from 'lit/decorators.js'; @customElement('my-element') class MyElement extends LitElement { -/* playground-fold-end */ - -@property() colors = ['red', 'green', 'blue']; + /* playground-fold-end */ -render() { - return html`

    Colors: ${this.colors}

    `; -} -/* playground-fold */ + @property() colors = ['red', 'green', 'blue']; + render() { + return html`

    Colors: ${this.colors}

    `; + } + /* playground-fold */ } /* playground-fold-end */ diff --git a/packages/lit-dev-content/samples/v3-docs/templates/lists-map/index.html b/packages/lit-dev-content/samples/v3-docs/templates/lists-map/index.html index fe1517255..f149c266f 100644 --- a/packages/lit-dev-content/samples/v3-docs/templates/lists-map/index.html +++ b/packages/lit-dev-content/samples/v3-docs/templates/lists-map/index.html @@ -1,5 +1,7 @@ diff --git a/packages/lit-dev-content/samples/v3-docs/templates/lists-map/my-element.js b/packages/lit-dev-content/samples/v3-docs/templates/lists-map/my-element.js index 18b0fc2f0..392746450 100644 --- a/packages/lit-dev-content/samples/v3-docs/templates/lists-map/my-element.js +++ b/packages/lit-dev-content/samples/v3-docs/templates/lists-map/my-element.js @@ -2,28 +2,27 @@ import {LitElement, html} from 'lit'; class MyElement extends LitElement { -/* playground-fold-end */ - -static properties = { - colors: {}, -}; + /* playground-fold-end */ -constructor() { - super(); - this.colors = ['red', 'green', 'blue']; -} + static properties = { + colors: {}, + }; -render() { - return html` -
      - ${this.colors.map((color) => - html`
    • ${color}
    • ` - )} -
    - `; -} -/* playground-fold */ + constructor() { + super(); + this.colors = ['red', 'green', 'blue']; + } + render() { + return html` +
      + ${this.colors.map( + (color) => html`
    • ${color}
    • `, + )} +
    + `; + } + /* playground-fold */ } customElements.define('my-element', MyElement); /* playground-fold-end */ diff --git a/packages/lit-dev-content/samples/v3-docs/templates/lists-map/my-element.ts b/packages/lit-dev-content/samples/v3-docs/templates/lists-map/my-element.ts index 97fb8afa3..11ac98748 100644 --- a/packages/lit-dev-content/samples/v3-docs/templates/lists-map/my-element.ts +++ b/packages/lit-dev-content/samples/v3-docs/templates/lists-map/my-element.ts @@ -4,20 +4,19 @@ import {customElement, property} from 'lit/decorators.js'; @customElement('my-element') class MyElement extends LitElement { -/* playground-fold-end */ - -@property() colors = ['red', 'green', 'blue']; + /* playground-fold-end */ -render() { - return html` -
      - ${this.colors.map((color) => - html`
    • ${color}
    • ` - )} -
    - `; -} -/* playground-fold */ + @property() colors = ['red', 'green', 'blue']; + render() { + return html` +
      + ${this.colors.map( + (color) => html`
    • ${color}
    • `, + )} +
    + `; + } + /* playground-fold */ } /* playground-fold-end */ diff --git a/packages/lit-dev-content/samples/v3-docs/templates/lists-repeat/index.html b/packages/lit-dev-content/samples/v3-docs/templates/lists-repeat/index.html index fe1517255..f149c266f 100644 --- a/packages/lit-dev-content/samples/v3-docs/templates/lists-repeat/index.html +++ b/packages/lit-dev-content/samples/v3-docs/templates/lists-repeat/index.html @@ -1,5 +1,7 @@ diff --git a/packages/lit-dev-content/samples/v3-docs/templates/lists-repeat/my-element.ts b/packages/lit-dev-content/samples/v3-docs/templates/lists-repeat/my-element.ts index 9a48488ae..db180c68c 100644 --- a/packages/lit-dev-content/samples/v3-docs/templates/lists-repeat/my-element.ts +++ b/packages/lit-dev-content/samples/v3-docs/templates/lists-repeat/my-element.ts @@ -8,35 +8,42 @@ import {repeat} from 'lit/directives/repeat.js'; @customElement('my-element') class MyElement extends LitElement { + private sort = 1; -private sort = 1; + @property() employees = [ + {id: 0, givenName: 'Fred', familyName: 'Flintstone'}, + {id: 1, givenName: 'George', familyName: 'Jetson'}, + {id: 2, givenName: 'Barney', familyName: 'Rubble'}, + {id: 3, givenName: 'Cosmo', familyName: 'Spacely'}, + ]; + /* playground-fold-end */ -@property() employees = [ - {id: 0, givenName: 'Fred', familyName: 'Flintstone'}, - {id: 1, givenName: 'George', familyName: 'Jetson'}, - {id: 2, givenName: 'Barney', familyName: 'Rubble'}, - {id: 3, givenName: 'Cosmo', familyName: 'Spacely'} -]; -/* playground-fold-end */ - -render() { - return html` -
      - ${repeat(this.employees, (employee) => employee.id, (employee, index) => html` -
    • ${index}: ${employee.familyName}, ${employee.givenName}
    • - `)} -
    - - `; -} -/* playground-fold */ - -private toggleSort() { - this.sort *= -1; - this.employees = [...this.employees.sort((a, b) => - this.sort * (a.familyName.localeCompare(b.familyName) || - a.givenName.localeCompare(b.givenName)))]; -} + render() { + return html` +
      + ${repeat( + this.employees, + (employee) => employee.id, + (employee, index) => html` +
    • ${index}: ${employee.familyName}, ${employee.givenName}
    • + `, + )} +
    + + `; + } + /* playground-fold */ + private toggleSort() { + this.sort *= -1; + this.employees = [ + ...this.employees.sort( + (a, b) => + this.sort * + (a.familyName.localeCompare(b.familyName) || + a.givenName.localeCompare(b.givenName)), + ), + ]; + } } /* playground-fold-end */ diff --git a/packages/lit-dev-content/samples/v3-docs/what-is-lit/icons.ts b/packages/lit-dev-content/samples/v3-docs/what-is-lit/icons.ts index 2d149f146..91233aaec 100644 --- a/packages/lit-dev-content/samples/v3-docs/what-is-lit/icons.ts +++ b/packages/lit-dev-content/samples/v3-docs/what-is-lit/icons.ts @@ -1,5 +1,45 @@ import {html} from 'lit'; -export const replay = html`Replay`; -export const pause = html`Pause`; -export const play = html`Play`; +export const replay = html` + Replay + + + + + + + + + +`; +export const pause = html` + Pause + + +`; +export const play = html` + Play + + +`; diff --git a/packages/lit-dev-content/samples/v3-docs/what-is-lit/index.html b/packages/lit-dev-content/samples/v3-docs/what-is-lit/index.html index 00c26fcf6..243f398fb 100644 --- a/packages/lit-dev-content/samples/v3-docs/what-is-lit/index.html +++ b/packages/lit-dev-content/samples/v3-docs/what-is-lit/index.html @@ -1,7 +1,11 @@ - - - + + + +