From 056ed3eb8dbc6a003efd2b3ab47eafc3a13b9399 Mon Sep 17 00:00:00 2001 From: Stephen Niedzielski Date: Fri, 9 Feb 2024 16:57:04 -0700 Subject: [PATCH] Demonstrate adding a new component --- src/ui/components/play-demo.ts | 40 ++++++++++++++++++++++++++ src/ui/components/play-pen/play-pen.ts | 8 +++++- src/ui/components/play-preview.ts | 2 ++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 src/ui/components/play-demo.ts diff --git a/src/ui/components/play-demo.ts b/src/ui/components/play-demo.ts new file mode 100644 index 0000000..ea62479 --- /dev/null +++ b/src/ui/components/play-demo.ts @@ -0,0 +1,40 @@ +import { + LitElement, + css, + html, + type CSSResultGroup, + type TemplateResult +} from 'lit' +import {customElement, property} from 'lit/decorators.js' +import {Bubble} from '../bubble.js' + +declare global { + interface HTMLElementEventMap { + 'fancy-click': CustomEvent + } + interface HTMLElementTagNameMap { + 'play-demo': PlayDemo + } +} + +export type FancyClick = {num: number} + +@customElement('play-demo') +export class PlayDemo extends LitElement { + @property({attribute: false}) example?: string + + static override styles: CSSResultGroup = css`` + + protected override render(): TemplateResult { + return html`` + } +} diff --git a/src/ui/components/play-pen/play-pen.ts b/src/ui/components/play-pen/play-pen.ts index 31f6982..3c75ab5 100644 --- a/src/ui/components/play-pen/play-pen.ts +++ b/src/ui/components/play-pen/play-pen.ts @@ -34,6 +34,8 @@ import type {PlayPreview} from '../play-preview.js' import type {PlayToast} from '../play-toast.js' import penVars from './pen-vars.css' +import '../play-demo.js' +import type {FancyClick} from '../play-demo.js' import '../play-editor/play-editor.js' import '../play-pen-footer.js' import '../play-pen-header.js' @@ -162,7 +164,7 @@ export class PlayPen extends LitElement { protected override render(): TemplateResult { return html` - Copied the URL!Copied the URL2!
+ ) => + this._editor.setSrc(ev.detail.num.toString())} + > ('error', {type: 'Error', err: ev.detail}) )} + @devvit-ui-logs=${(ev: CustomEvent) => + console.log('got some logs', ev.detail)} .meta="${this.#meta}" .client=${this._client} .scheme=${this.scheme}