blob: ebbc5e307e1a6e284f21869f44f2195166c4d461 [file] [log] [blame]
banksean333aa672025-07-13 19:49:21 +00001import { html } from "lit";
Josh Bleecher Snyder2d081192025-05-29 13:46:04 +00002import { customElement, property } from "lit/decorators.js";
3import { ToolCall } from "../types";
banksean333aa672025-07-13 19:49:21 +00004import { SketchTailwindElement } from "./sketch-tailwind-element";
5import "./sketch-tool-card-base";
Josh Bleecher Snyder2d081192025-05-29 13:46:04 +00006
7@customElement("sketch-tool-card-browser-resize")
banksean333aa672025-07-13 19:49:21 +00008export class SketchToolCardBrowserResize extends SketchTailwindElement {
Josh Bleecher Snyder2d081192025-05-29 13:46:04 +00009 @property()
10 toolCall: ToolCall;
11
12 @property()
13 open: boolean;
14
Josh Bleecher Snyder2d081192025-05-29 13:46:04 +000015 render() {
16 // Parse the input to get width and height
17 let width = "";
18 let height = "";
19 try {
20 if (this.toolCall?.input) {
21 const input = JSON.parse(this.toolCall.input);
22 width = input.width ? input.width.toString() : "";
23 height = input.height ? input.height.toString() : "";
24 }
25 } catch (e) {
26 console.error("Error parsing resize input:", e);
27 }
28
banksean333aa672025-07-13 19:49:21 +000029 const summaryContent = html`<span class="font-mono text-gray-700 break-all">
30 🖼️ ${width}x${height}
31 </span>`;
32 const inputContent = html`<div>
33 Resize to:
34 <span
35 class="font-mono bg-black/[0.05] px-2 py-1 rounded inline-block break-all"
36 >${width}x${height}</span
37 >
38 </div>`;
39 const resultContent = this.toolCall?.result_message?.tool_result
40 ? html`<pre
41 class="bg-gray-200 text-black p-2 rounded whitespace-pre-wrap break-words max-w-full w-full box-border"
42 >
43${this.toolCall.result_message.tool_result}</pre
44 >`
45 : "";
46
Josh Bleecher Snyder2d081192025-05-29 13:46:04 +000047 return html`
banksean333aa672025-07-13 19:49:21 +000048 <sketch-tool-card-base
49 .open=${this.open}
50 .toolCall=${this.toolCall}
51 .summaryContent=${summaryContent}
52 .inputContent=${inputContent}
53 .resultContent=${resultContent}
54 >
55 </sketch-tool-card-base>
Josh Bleecher Snyder2d081192025-05-29 13:46:04 +000056 `;
57 }
58}
59
60declare global {
61 interface HTMLElementTagNameMap {
62 "sketch-tool-card-browser-resize": SketchToolCardBrowserResize;
63 }
64}