Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Appending messages to conversation
  • Loading branch information
bfollington committed May 30, 2024
commit f48ff566ba85ebce74b794565bbc3f9c0f900707
25 changes: 22 additions & 3 deletions sketches/2024-05-30-lookslike-prototype/src/components/com-app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LitElement, html } from 'lit-element'
import { customElement, property } from 'lit/decorators.js'
import { customElement, state } from 'lit/decorators.js'
import { base } from '../styles'

import { todoAppMockup } from '../data'
Expand All @@ -8,17 +8,36 @@ import { todoAppMockup } from '../data'
export class ComApp extends LitElement {
static styles = [base]

@state() graph = todoAppMockup as any

appendMessage() {
const newGraph = { ...this.graph }
const id = 'new' + (Math.floor(Math.random() * 1000))

newGraph.nodes.push({
id,
messages: [
{
role: 'user',
content: 'new message'
}
],
definition: {}
});

newGraph.order.push(id);
this.graph = newGraph;
}

render() {
return html`
<com-app-grid>
<com-chat slot="main">
<com-thread slot="main" .graph=${todoAppMockup}></com-thread>
<com-thread slot="main" .graph=${this.graph}></com-thread>
<div slot="footer">
<com-unibox>
<com-editor slot="main"></com-editor>
<com-button slot="end">Send</com-button>
<com-button slot="end" .action=${() => this.appendMessage()}>Send</com-button>
</com-unibox>
</div>
</com-chat>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {LitElement, html, css} from 'lit-element'
import {customElement} from 'lit/decorators.js'
import {base} from '../styles'
import { LitElement, html, css } from 'lit-element'
import { customElement, property } from 'lit/decorators.js'
import { base } from '../styles'

const styles = css`
:host {
Expand Down Expand Up @@ -29,7 +29,9 @@ const styles = css`
export class ComButton extends LitElement {
static styles = [base, styles]

@property({ type: Function }) action = () => { }

render() {
return html`<button class="button"><slot></slot></button>`
return html`<button class="button" @click=${this.action}><slot></slot></button>`
}
}