blob: 52f8a4e67d56a4e6250f2d982cbba7d44197280b [file] [log] [blame]
Sean McCullough71941bd2025-04-18 13:31:48 -07001import { css, html, LitElement } from "lit";
Sean McCulloughd9f13372025-04-21 15:08:49 -07002import { customElement, property } from "lit/decorators.js";
Sean McCullough71941bd2025-04-18 13:31:48 -07003import "./sketch-container-status";
Sean McCullough86b56862025-04-18 13:04:03 -07004
Sean McCullough71941bd2025-04-18 13:31:48 -07005@customElement("sketch-view-mode-select")
Sean McCullough86b56862025-04-18 13:04:03 -07006export class SketchViewModeSelect extends LitElement {
7 // Current active mode
8 @property()
9 activeMode: "chat" | "diff" | "charts" | "terminal" = "chat";
10 // Header bar: view mode buttons
11
Sean McCullough86b56862025-04-18 13:04:03 -070012 static styles = css`
Sean McCullough71941bd2025-04-18 13:31:48 -070013 /* View Mode Button Styles */
14 .view-mode-buttons {
15 display: flex;
16 gap: 8px;
17 margin-right: 10px;
18 }
Sean McCullough86b56862025-04-18 13:04:03 -070019
Sean McCullough71941bd2025-04-18 13:31:48 -070020 .emoji-button {
21 font-size: 18px;
22 width: 32px;
23 height: 32px;
24 display: flex;
25 align-items: center;
26 justify-content: center;
27 background: white;
28 border: 1px solid #ddd;
29 border-radius: 4px;
30 cursor: pointer;
31 transition: all 0.2s ease;
32 padding: 0;
33 line-height: 1;
34 }
Sean McCullough86b56862025-04-18 13:04:03 -070035
Sean McCullough71941bd2025-04-18 13:31:48 -070036 .emoji-button:hover {
37 background-color: #f0f0f0;
38 transform: translateY(-2px);
39 box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
40 }
Sean McCullough86b56862025-04-18 13:04:03 -070041
Sean McCullough71941bd2025-04-18 13:31:48 -070042 .emoji-button.active {
43 background-color: #e6f7ff;
44 border-color: #1890ff;
45 color: #1890ff;
46 }
47 `;
48
Sean McCullough86b56862025-04-18 13:04:03 -070049 constructor() {
50 super();
Sean McCullough71941bd2025-04-18 13:31:48 -070051
Sean McCullough86b56862025-04-18 13:04:03 -070052 // Binding methods
53 this._handleViewModeClick = this._handleViewModeClick.bind(this);
54 this._handleUpdateActiveMode = this._handleUpdateActiveMode.bind(this);
55 }
56
57 // See https://lit.dev/docs/components/lifecycle/
58 connectedCallback() {
59 super.connectedCallback();
Sean McCullough71941bd2025-04-18 13:31:48 -070060
Sean McCullough86b56862025-04-18 13:04:03 -070061 // Listen for update-active-mode events
Sean McCullough71941bd2025-04-18 13:31:48 -070062 this.addEventListener(
63 "update-active-mode",
64 this._handleUpdateActiveMode as EventListener,
65 );
Sean McCullough86b56862025-04-18 13:04:03 -070066 }
Sean McCullough71941bd2025-04-18 13:31:48 -070067
Sean McCullough86b56862025-04-18 13:04:03 -070068 /**
69 * Handle view mode button clicks
70 */
71 private _handleViewModeClick(mode: "chat" | "diff" | "charts" | "terminal") {
72 // Dispatch a custom event to notify the app shell to change the view
Sean McCullough71941bd2025-04-18 13:31:48 -070073 const event = new CustomEvent("view-mode-select", {
Sean McCullough86b56862025-04-18 13:04:03 -070074 detail: { mode },
75 bubbles: true,
Sean McCullough71941bd2025-04-18 13:31:48 -070076 composed: true,
Sean McCullough86b56862025-04-18 13:04:03 -070077 });
78 this.dispatchEvent(event);
79 }
Sean McCullough71941bd2025-04-18 13:31:48 -070080
Sean McCullough86b56862025-04-18 13:04:03 -070081 /**
82 * Handle updates to the active mode
83 */
84 private _handleUpdateActiveMode(event: CustomEvent) {
85 const { mode } = event.detail;
86 if (mode) {
87 this.activeMode = mode;
88 }
89 }
90
91 // See https://lit.dev/docs/components/lifecycle/
92 disconnectedCallback() {
93 super.disconnectedCallback();
Sean McCullough71941bd2025-04-18 13:31:48 -070094
Sean McCullough86b56862025-04-18 13:04:03 -070095 // Remove event listeners
Sean McCullough71941bd2025-04-18 13:31:48 -070096 this.removeEventListener(
97 "update-active-mode",
98 this._handleUpdateActiveMode as EventListener,
99 );
Sean McCullough86b56862025-04-18 13:04:03 -0700100 }
101
102 render() {
103 return html`
104 <div class="view-mode-buttons">
105 <button
106 id="showConversationButton"
Sean McCullough71941bd2025-04-18 13:31:48 -0700107 class="emoji-button ${this.activeMode === "chat" ? "active" : ""}"
Sean McCullough86b56862025-04-18 13:04:03 -0700108 title="Conversation View"
Sean McCullough71941bd2025-04-18 13:31:48 -0700109 @click=${() => this._handleViewModeClick("chat")}
Sean McCullough86b56862025-04-18 13:04:03 -0700110 >
111 💬
112 </button>
113 <button
114 id="showDiffButton"
Sean McCullough71941bd2025-04-18 13:31:48 -0700115 class="emoji-button ${this.activeMode === "diff" ? "active" : ""}"
Sean McCullough86b56862025-04-18 13:04:03 -0700116 title="Diff View"
Sean McCullough71941bd2025-04-18 13:31:48 -0700117 @click=${() => this._handleViewModeClick("diff")}
Sean McCullough86b56862025-04-18 13:04:03 -0700118 >
119 ±
120 </button>
121 <button
122 id="showChartsButton"
Sean McCullough71941bd2025-04-18 13:31:48 -0700123 class="emoji-button ${this.activeMode === "charts" ? "active" : ""}"
Sean McCullough86b56862025-04-18 13:04:03 -0700124 title="Charts View"
Sean McCullough71941bd2025-04-18 13:31:48 -0700125 @click=${() => this._handleViewModeClick("charts")}
Sean McCullough86b56862025-04-18 13:04:03 -0700126 >
127 📈
128 </button>
129 <button
130 id="showTerminalButton"
Sean McCullough71941bd2025-04-18 13:31:48 -0700131 class="emoji-button ${this.activeMode === "terminal" ? "active" : ""}"
Sean McCullough86b56862025-04-18 13:04:03 -0700132 title="Terminal View"
Sean McCullough71941bd2025-04-18 13:31:48 -0700133 @click=${() => this._handleViewModeClick("terminal")}
Sean McCullough86b56862025-04-18 13:04:03 -0700134 >
135 💻
136 </button>
137 </div>
138 `;
139 }
140}
141
142declare global {
143 interface HTMLElementTagNameMap {
144 "sketch-view-mode-select": SketchViewModeSelect;
145 }
Sean McCullough71941bd2025-04-18 13:31:48 -0700146}