blob: f76f79246cf9d2047ddf99e1ebf863d7f8305c00 [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
banksean1ee0bc62025-07-22 23:24:18 +000029 const summaryContent = html`<span
30 class="font-mono text-gray-700 dark:text-gray-300 break-all"
31 >
banksean333aa672025-07-13 19:49:21 +000032 🖼️ ${width}x${height}
33 </span>`;
34 const inputContent = html`<div>
35 Resize to:
36 <span
banksean1ee0bc62025-07-22 23:24:18 +000037 class="font-mono bg-black/[0.05] dark:bg-white/[0.1] px-2 py-1 rounded inline-block break-all"
banksean333aa672025-07-13 19:49:21 +000038 >${width}x${height}</span
39 >
40 </div>`;
41 const resultContent = this.toolCall?.result_message?.tool_result
42 ? html`<pre
banksean1ee0bc62025-07-22 23:24:18 +000043 class="bg-gray-200 dark:bg-gray-700 text-black dark:text-gray-100 p-2 rounded whitespace-pre-wrap break-words max-w-full w-full box-border"
banksean333aa672025-07-13 19:49:21 +000044 >
45${this.toolCall.result_message.tool_result}</pre
46 >`
47 : "";
48
Josh Bleecher Snyder2d081192025-05-29 13:46:04 +000049 return html`
banksean333aa672025-07-13 19:49:21 +000050 <sketch-tool-card-base
51 .open=${this.open}
52 .toolCall=${this.toolCall}
53 .summaryContent=${summaryContent}
54 .inputContent=${inputContent}
55 .resultContent=${resultContent}
56 >
57 </sketch-tool-card-base>
Josh Bleecher Snyder2d081192025-05-29 13:46:04 +000058 `;
59 }
60}
61
62declare global {
63 interface HTMLElementTagNameMap {
64 "sketch-tool-card-browser-resize": SketchToolCardBrowserResize;
65 }
66}