blob: 2d9fde94a66039c41ea8bd3a503306630068e1fd [file] [log] [blame]
Josh Bleecher Snyder2d081192025-05-29 13:46:04 +00001import { css, html, LitElement } from "lit";
2import { customElement, property } from "lit/decorators.js";
3import { ToolCall } from "../types";
4
5@customElement("sketch-tool-card-browser-resize")
6export class SketchToolCardBrowserResize extends LitElement {
7 @property()
8 toolCall: ToolCall;
9
10 @property()
11 open: boolean;
12
13 static styles = css`
14 .summary-text {
15 font-family: monospace;
16 color: #444;
17 word-break: break-all;
18 }
Autoformatter71c73b52025-05-29 20:18:43 +000019
Josh Bleecher Snyder2d081192025-05-29 13:46:04 +000020 .size-input {
21 font-family: monospace;
22 background: rgba(0, 0, 0, 0.05);
23 padding: 4px 8px;
24 border-radius: 4px;
25 display: inline-block;
26 word-break: break-all;
27 }
28 `;
29
30 render() {
31 // Parse the input to get width and height
32 let width = "";
33 let height = "";
34 try {
35 if (this.toolCall?.input) {
36 const input = JSON.parse(this.toolCall.input);
37 width = input.width ? input.width.toString() : "";
38 height = input.height ? input.height.toString() : "";
39 }
40 } catch (e) {
41 console.error("Error parsing resize input:", e);
42 }
43
44 return html`
45 <sketch-tool-card .open=${this.open} .toolCall=${this.toolCall}>
Autoformatter71c73b52025-05-29 20:18:43 +000046 <span slot="summary" class="summary-text"> 🖼️ ${width}x${height} </span>
Josh Bleecher Snyder2d081192025-05-29 13:46:04 +000047 <div slot="input">
Autoformatter71c73b52025-05-29 20:18:43 +000048 <div>
49 Resize to: <span class="size-input">${width}x${height}</span>
50 </div>
Josh Bleecher Snyder2d081192025-05-29 13:46:04 +000051 </div>
52 <div slot="result">
53 ${this.toolCall?.result_message?.tool_result
54 ? html`<pre>${this.toolCall.result_message.tool_result}</pre>`
55 : ""}
56 </div>
57 </sketch-tool-card>
58 `;
59 }
60}
61
62declare global {
63 interface HTMLElementTagNameMap {
64 "sketch-tool-card-browser-resize": SketchToolCardBrowserResize;
65 }
66}