blob: 4c3c91f31fa3f2c097c5d0473619c76e3b176938 [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`
Philip Zeyligere66db3e2025-04-27 15:40:39 +000013 /* Tab-style View Mode Styles */
14 .tab-nav {
Sean McCullough71941bd2025-04-18 13:31:48 -070015 display: flex;
Sean McCullough71941bd2025-04-18 13:31:48 -070016 margin-right: 10px;
Philip Zeyligere66db3e2025-04-27 15:40:39 +000017 background-color: #f8f8f8;
18 border-radius: 4px;
19 overflow: hidden;
20 border: 1px solid #ddd;
Sean McCullough71941bd2025-04-18 13:31:48 -070021 }
Sean McCullough86b56862025-04-18 13:04:03 -070022
Philip Zeyligere66db3e2025-04-27 15:40:39 +000023 .tab-btn {
24 padding: 8px 12px;
25 background: none;
26 border: none;
27 cursor: pointer;
28 font-size: 13px;
Sean McCullough71941bd2025-04-18 13:31:48 -070029 display: flex;
30 align-items: center;
Philip Zeyligere66db3e2025-04-27 15:40:39 +000031 gap: 5px;
32 color: #666;
33 border-bottom: 2px solid transparent;
Sean McCullough71941bd2025-04-18 13:31:48 -070034 transition: all 0.2s ease;
Philip Zeyligere66db3e2025-04-27 15:40:39 +000035 white-space: nowrap;
Sean McCullough71941bd2025-04-18 13:31:48 -070036 }
Sean McCullough86b56862025-04-18 13:04:03 -070037
Philip Zeyligere66db3e2025-04-27 15:40:39 +000038 .tab-btn:not(:last-child) {
39 border-right: 1px solid #eee;
40 }
41
42 .tab-btn:hover {
Sean McCullough71941bd2025-04-18 13:31:48 -070043 background-color: #f0f0f0;
Sean McCullough71941bd2025-04-18 13:31:48 -070044 }
Sean McCullough86b56862025-04-18 13:04:03 -070045
Philip Zeyligere66db3e2025-04-27 15:40:39 +000046 .tab-btn.active {
47 border-bottom: 2px solid #4a90e2;
48 color: #4a90e2;
49 font-weight: 500;
Sean McCullough71941bd2025-04-18 13:31:48 -070050 background-color: #e6f7ff;
Philip Zeyligere66db3e2025-04-27 15:40:39 +000051 }
52
53 .tab-icon {
54 font-size: 16px;
Sean McCullough71941bd2025-04-18 13:31:48 -070055 }
56 `;
57
Sean McCullough86b56862025-04-18 13:04:03 -070058 constructor() {
59 super();
Sean McCullough71941bd2025-04-18 13:31:48 -070060
Sean McCullough86b56862025-04-18 13:04:03 -070061 // Binding methods
62 this._handleViewModeClick = this._handleViewModeClick.bind(this);
63 this._handleUpdateActiveMode = this._handleUpdateActiveMode.bind(this);
64 }
65
66 // See https://lit.dev/docs/components/lifecycle/
67 connectedCallback() {
68 super.connectedCallback();
Sean McCullough71941bd2025-04-18 13:31:48 -070069
Sean McCullough86b56862025-04-18 13:04:03 -070070 // Listen for update-active-mode events
Sean McCullough71941bd2025-04-18 13:31:48 -070071 this.addEventListener(
72 "update-active-mode",
73 this._handleUpdateActiveMode as EventListener,
74 );
Sean McCullough86b56862025-04-18 13:04:03 -070075 }
Sean McCullough71941bd2025-04-18 13:31:48 -070076
Sean McCullough86b56862025-04-18 13:04:03 -070077 /**
78 * Handle view mode button clicks
79 */
80 private _handleViewModeClick(mode: "chat" | "diff" | "charts" | "terminal") {
81 // Dispatch a custom event to notify the app shell to change the view
Sean McCullough71941bd2025-04-18 13:31:48 -070082 const event = new CustomEvent("view-mode-select", {
Sean McCullough86b56862025-04-18 13:04:03 -070083 detail: { mode },
84 bubbles: true,
Sean McCullough71941bd2025-04-18 13:31:48 -070085 composed: true,
Sean McCullough86b56862025-04-18 13:04:03 -070086 });
87 this.dispatchEvent(event);
88 }
Sean McCullough71941bd2025-04-18 13:31:48 -070089
Sean McCullough86b56862025-04-18 13:04:03 -070090 /**
91 * Handle updates to the active mode
92 */
93 private _handleUpdateActiveMode(event: CustomEvent) {
94 const { mode } = event.detail;
95 if (mode) {
96 this.activeMode = mode;
97 }
98 }
99
100 // See https://lit.dev/docs/components/lifecycle/
101 disconnectedCallback() {
102 super.disconnectedCallback();
Sean McCullough71941bd2025-04-18 13:31:48 -0700103
Sean McCullough86b56862025-04-18 13:04:03 -0700104 // Remove event listeners
Sean McCullough71941bd2025-04-18 13:31:48 -0700105 this.removeEventListener(
106 "update-active-mode",
107 this._handleUpdateActiveMode as EventListener,
108 );
Sean McCullough86b56862025-04-18 13:04:03 -0700109 }
110
111 render() {
112 return html`
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000113 <div class="tab-nav">
Sean McCullough86b56862025-04-18 13:04:03 -0700114 <button
115 id="showConversationButton"
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000116 class="tab-btn ${this.activeMode === "chat" ? "active" : ""}"
Sean McCullough86b56862025-04-18 13:04:03 -0700117 title="Conversation View"
Sean McCullough71941bd2025-04-18 13:31:48 -0700118 @click=${() => this._handleViewModeClick("chat")}
Sean McCullough86b56862025-04-18 13:04:03 -0700119 >
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000120 <span class="tab-icon">💬</span>
121 <span>Chat</span>
Sean McCullough86b56862025-04-18 13:04:03 -0700122 </button>
123 <button
124 id="showDiffButton"
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000125 class="tab-btn ${this.activeMode === "diff" ? "active" : ""}"
Sean McCullough86b56862025-04-18 13:04:03 -0700126 title="Diff View"
Sean McCullough71941bd2025-04-18 13:31:48 -0700127 @click=${() => this._handleViewModeClick("diff")}
Sean McCullough86b56862025-04-18 13:04:03 -0700128 >
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000129 <span class="tab-icon">±</span>
130 <span>Diff</span>
Sean McCullough86b56862025-04-18 13:04:03 -0700131 </button>
132 <button
133 id="showChartsButton"
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000134 class="tab-btn ${this.activeMode === "charts" ? "active" : ""}"
Sean McCullough86b56862025-04-18 13:04:03 -0700135 title="Charts View"
Sean McCullough71941bd2025-04-18 13:31:48 -0700136 @click=${() => this._handleViewModeClick("charts")}
Sean McCullough86b56862025-04-18 13:04:03 -0700137 >
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000138 <span class="tab-icon">📈</span>
139 <span>Charts</span>
Sean McCullough86b56862025-04-18 13:04:03 -0700140 </button>
141 <button
142 id="showTerminalButton"
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000143 class="tab-btn ${this.activeMode === "terminal" ? "active" : ""}"
Sean McCullough86b56862025-04-18 13:04:03 -0700144 title="Terminal View"
Sean McCullough71941bd2025-04-18 13:31:48 -0700145 @click=${() => this._handleViewModeClick("terminal")}
Sean McCullough86b56862025-04-18 13:04:03 -0700146 >
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000147 <span class="tab-icon">💻</span>
148 <span>Terminal</span>
Sean McCullough86b56862025-04-18 13:04:03 -0700149 </button>
150 </div>
151 `;
152 }
153}
154
155declare global {
156 interface HTMLElementTagNameMap {
157 "sketch-view-mode-select": SketchViewModeSelect;
158 }
Sean McCullough71941bd2025-04-18 13:31:48 -0700159}