blob: c83b9642f10d3ec31c2ac0a9a033af18d3b78fdb [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()
Philip Zeyliger00bcaef2025-05-30 04:21:15 +00009 activeMode: "chat" | "diff2" | "terminal" = "chat";
Sean McCullough86b56862025-04-18 13:04:03 -070010 // 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 Zeyligerbce3a132025-04-30 22:03:39 +000038 @media (max-width: 1400px) {
39 .tab-btn span:not(.tab-icon) {
40 display: none;
41 }
42
43 .tab-btn {
44 padding: 8px 10px;
45 }
46 }
47
Philip Zeyligere66db3e2025-04-27 15:40:39 +000048 .tab-btn:not(:last-child) {
49 border-right: 1px solid #eee;
50 }
51
52 .tab-btn:hover {
Sean McCullough71941bd2025-04-18 13:31:48 -070053 background-color: #f0f0f0;
Sean McCullough71941bd2025-04-18 13:31:48 -070054 }
Sean McCullough86b56862025-04-18 13:04:03 -070055
Philip Zeyligere66db3e2025-04-27 15:40:39 +000056 .tab-btn.active {
57 border-bottom: 2px solid #4a90e2;
58 color: #4a90e2;
59 font-weight: 500;
Sean McCullough71941bd2025-04-18 13:31:48 -070060 background-color: #e6f7ff;
Philip Zeyligere66db3e2025-04-27 15:40:39 +000061 }
62
63 .tab-icon {
64 font-size: 16px;
Sean McCullough71941bd2025-04-18 13:31:48 -070065 }
66 `;
67
Sean McCullough86b56862025-04-18 13:04:03 -070068 constructor() {
69 super();
Sean McCullough71941bd2025-04-18 13:31:48 -070070
Sean McCullough86b56862025-04-18 13:04:03 -070071 // Binding methods
72 this._handleViewModeClick = this._handleViewModeClick.bind(this);
73 this._handleUpdateActiveMode = this._handleUpdateActiveMode.bind(this);
74 }
75
76 // See https://lit.dev/docs/components/lifecycle/
77 connectedCallback() {
78 super.connectedCallback();
Sean McCullough71941bd2025-04-18 13:31:48 -070079
Sean McCullough86b56862025-04-18 13:04:03 -070080 // Listen for update-active-mode events
Sean McCullough71941bd2025-04-18 13:31:48 -070081 this.addEventListener(
82 "update-active-mode",
83 this._handleUpdateActiveMode as EventListener,
84 );
Sean McCullough86b56862025-04-18 13:04:03 -070085 }
Sean McCullough71941bd2025-04-18 13:31:48 -070086
Sean McCullough86b56862025-04-18 13:04:03 -070087 /**
88 * Handle view mode button clicks
89 */
Philip Zeyliger00bcaef2025-05-30 04:21:15 +000090 private _handleViewModeClick(mode: "chat" | "diff2" | "terminal") {
Sean McCullough86b56862025-04-18 13:04:03 -070091 // Dispatch a custom event to notify the app shell to change the view
Sean McCullough71941bd2025-04-18 13:31:48 -070092 const event = new CustomEvent("view-mode-select", {
Sean McCullough86b56862025-04-18 13:04:03 -070093 detail: { mode },
94 bubbles: true,
Sean McCullough71941bd2025-04-18 13:31:48 -070095 composed: true,
Sean McCullough86b56862025-04-18 13:04:03 -070096 });
97 this.dispatchEvent(event);
98 }
Sean McCullough71941bd2025-04-18 13:31:48 -070099
Sean McCullough86b56862025-04-18 13:04:03 -0700100 /**
101 * Handle updates to the active mode
102 */
103 private _handleUpdateActiveMode(event: CustomEvent) {
104 const { mode } = event.detail;
105 if (mode) {
106 this.activeMode = mode;
107 }
108 }
109
110 // See https://lit.dev/docs/components/lifecycle/
111 disconnectedCallback() {
112 super.disconnectedCallback();
Sean McCullough71941bd2025-04-18 13:31:48 -0700113
Sean McCullough86b56862025-04-18 13:04:03 -0700114 // Remove event listeners
Sean McCullough71941bd2025-04-18 13:31:48 -0700115 this.removeEventListener(
116 "update-active-mode",
117 this._handleUpdateActiveMode as EventListener,
118 );
Sean McCullough86b56862025-04-18 13:04:03 -0700119 }
120
121 render() {
122 return html`
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000123 <div class="tab-nav">
Sean McCullough86b56862025-04-18 13:04:03 -0700124 <button
125 id="showConversationButton"
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000126 class="tab-btn ${this.activeMode === "chat" ? "active" : ""}"
Sean McCullough86b56862025-04-18 13:04:03 -0700127 title="Conversation View"
Sean McCullough71941bd2025-04-18 13:31:48 -0700128 @click=${() => this._handleViewModeClick("chat")}
Sean McCullough86b56862025-04-18 13:04:03 -0700129 >
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000130 <span class="tab-icon">💬</span>
131 <span>Chat</span>
Sean McCullough86b56862025-04-18 13:04:03 -0700132 </button>
133 <button
Philip Zeyliger272a90e2025-05-16 14:49:51 -0700134 id="showDiff2Button"
135 class="tab-btn ${this.activeMode === "diff2" ? "active" : ""}"
Sean McCullough86b56862025-04-18 13:04:03 -0700136 title="Diff View"
Philip Zeyliger272a90e2025-05-16 14:49:51 -0700137 @click=${() => this._handleViewModeClick("diff2")}
Sean McCullough86b56862025-04-18 13:04:03 -0700138 >
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000139 <span class="tab-icon">±</span>
140 <span>Diff</span>
Sean McCullough86b56862025-04-18 13:04:03 -0700141 </button>
Autoformatter8c463622025-05-16 21:54:17 +0000142
Sean McCullough86b56862025-04-18 13:04:03 -0700143 <button
144 id="showTerminalButton"
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000145 class="tab-btn ${this.activeMode === "terminal" ? "active" : ""}"
Sean McCullough86b56862025-04-18 13:04:03 -0700146 title="Terminal View"
Sean McCullough71941bd2025-04-18 13:31:48 -0700147 @click=${() => this._handleViewModeClick("terminal")}
Sean McCullough86b56862025-04-18 13:04:03 -0700148 >
Philip Zeyligere66db3e2025-04-27 15:40:39 +0000149 <span class="tab-icon">💻</span>
150 <span>Terminal</span>
Sean McCullough86b56862025-04-18 13:04:03 -0700151 </button>
152 </div>
153 `;
154 }
155}
156
157declare global {
158 interface HTMLElementTagNameMap {
159 "sketch-view-mode-select": SketchViewModeSelect;
160 }
Sean McCullough71941bd2025-04-18 13:31:48 -0700161}