blob: d67da0b548c6add57818c34836567f22246d4cef [file] [log] [blame]
Sean McCullough71941bd2025-04-18 13:31:48 -07001import { css, html, LitElement } from "lit";
2import { customElement, property, state } from "lit/decorators.js";
3import { DataManager, ConnectionStatus } from "../data";
4import { State, TimelineMessage } from "../types";
5import "./sketch-container-status";
Sean McCullough86b56862025-04-18 13:04:03 -07006
Sean McCullough71941bd2025-04-18 13:31:48 -07007@customElement("sketch-view-mode-select")
Sean McCullough86b56862025-04-18 13:04:03 -07008export class SketchViewModeSelect extends LitElement {
9 // Current active mode
10 @property()
11 activeMode: "chat" | "diff" | "charts" | "terminal" = "chat";
12 // Header bar: view mode buttons
13
14 // See https://lit.dev/docs/components/styles/ for how lit-element handles CSS.
15 // Note that these styles only apply to the scope of this web component's
16 // shadow DOM node, so they won't leak out or collide with CSS declared in
17 // other components or the containing web page (...unless you want it to do that).
18
19 static styles = css`
Sean McCullough71941bd2025-04-18 13:31:48 -070020 /* View Mode Button Styles */
21 .view-mode-buttons {
22 display: flex;
23 gap: 8px;
24 margin-right: 10px;
25 }
Sean McCullough86b56862025-04-18 13:04:03 -070026
Sean McCullough71941bd2025-04-18 13:31:48 -070027 .emoji-button {
28 font-size: 18px;
29 width: 32px;
30 height: 32px;
31 display: flex;
32 align-items: center;
33 justify-content: center;
34 background: white;
35 border: 1px solid #ddd;
36 border-radius: 4px;
37 cursor: pointer;
38 transition: all 0.2s ease;
39 padding: 0;
40 line-height: 1;
41 }
Sean McCullough86b56862025-04-18 13:04:03 -070042
Sean McCullough71941bd2025-04-18 13:31:48 -070043 .emoji-button:hover {
44 background-color: #f0f0f0;
45 transform: translateY(-2px);
46 box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
47 }
Sean McCullough86b56862025-04-18 13:04:03 -070048
Sean McCullough71941bd2025-04-18 13:31:48 -070049 .emoji-button.active {
50 background-color: #e6f7ff;
51 border-color: #1890ff;
52 color: #1890ff;
53 }
54 `;
55
Sean McCullough86b56862025-04-18 13:04:03 -070056 constructor() {
57 super();
Sean McCullough71941bd2025-04-18 13:31:48 -070058
Sean McCullough86b56862025-04-18 13:04:03 -070059 // Binding methods
60 this._handleViewModeClick = this._handleViewModeClick.bind(this);
61 this._handleUpdateActiveMode = this._handleUpdateActiveMode.bind(this);
62 }
63
64 // See https://lit.dev/docs/components/lifecycle/
65 connectedCallback() {
66 super.connectedCallback();
Sean McCullough71941bd2025-04-18 13:31:48 -070067
Sean McCullough86b56862025-04-18 13:04:03 -070068 // Listen for update-active-mode events
Sean McCullough71941bd2025-04-18 13:31:48 -070069 this.addEventListener(
70 "update-active-mode",
71 this._handleUpdateActiveMode as EventListener,
72 );
Sean McCullough86b56862025-04-18 13:04:03 -070073 }
Sean McCullough71941bd2025-04-18 13:31:48 -070074
Sean McCullough86b56862025-04-18 13:04:03 -070075 /**
76 * Handle view mode button clicks
77 */
78 private _handleViewModeClick(mode: "chat" | "diff" | "charts" | "terminal") {
79 // Dispatch a custom event to notify the app shell to change the view
Sean McCullough71941bd2025-04-18 13:31:48 -070080 const event = new CustomEvent("view-mode-select", {
Sean McCullough86b56862025-04-18 13:04:03 -070081 detail: { mode },
82 bubbles: true,
Sean McCullough71941bd2025-04-18 13:31:48 -070083 composed: true,
Sean McCullough86b56862025-04-18 13:04:03 -070084 });
85 this.dispatchEvent(event);
86 }
Sean McCullough71941bd2025-04-18 13:31:48 -070087
Sean McCullough86b56862025-04-18 13:04:03 -070088 /**
89 * Handle updates to the active mode
90 */
91 private _handleUpdateActiveMode(event: CustomEvent) {
92 const { mode } = event.detail;
93 if (mode) {
94 this.activeMode = mode;
95 }
96 }
97
98 // See https://lit.dev/docs/components/lifecycle/
99 disconnectedCallback() {
100 super.disconnectedCallback();
Sean McCullough71941bd2025-04-18 13:31:48 -0700101
Sean McCullough86b56862025-04-18 13:04:03 -0700102 // Remove event listeners
Sean McCullough71941bd2025-04-18 13:31:48 -0700103 this.removeEventListener(
104 "update-active-mode",
105 this._handleUpdateActiveMode as EventListener,
106 );
Sean McCullough86b56862025-04-18 13:04:03 -0700107 }
108
109 render() {
110 return html`
111 <div class="view-mode-buttons">
112 <button
113 id="showConversationButton"
Sean McCullough71941bd2025-04-18 13:31:48 -0700114 class="emoji-button ${this.activeMode === "chat" ? "active" : ""}"
Sean McCullough86b56862025-04-18 13:04:03 -0700115 title="Conversation View"
Sean McCullough71941bd2025-04-18 13:31:48 -0700116 @click=${() => this._handleViewModeClick("chat")}
Sean McCullough86b56862025-04-18 13:04:03 -0700117 >
118 💬
119 </button>
120 <button
121 id="showDiffButton"
Sean McCullough71941bd2025-04-18 13:31:48 -0700122 class="emoji-button ${this.activeMode === "diff" ? "active" : ""}"
Sean McCullough86b56862025-04-18 13:04:03 -0700123 title="Diff View"
Sean McCullough71941bd2025-04-18 13:31:48 -0700124 @click=${() => this._handleViewModeClick("diff")}
Sean McCullough86b56862025-04-18 13:04:03 -0700125 >
126 ±
127 </button>
128 <button
129 id="showChartsButton"
Sean McCullough71941bd2025-04-18 13:31:48 -0700130 class="emoji-button ${this.activeMode === "charts" ? "active" : ""}"
Sean McCullough86b56862025-04-18 13:04:03 -0700131 title="Charts View"
Sean McCullough71941bd2025-04-18 13:31:48 -0700132 @click=${() => this._handleViewModeClick("charts")}
Sean McCullough86b56862025-04-18 13:04:03 -0700133 >
134 📈
135 </button>
136 <button
137 id="showTerminalButton"
Sean McCullough71941bd2025-04-18 13:31:48 -0700138 class="emoji-button ${this.activeMode === "terminal" ? "active" : ""}"
Sean McCullough86b56862025-04-18 13:04:03 -0700139 title="Terminal View"
Sean McCullough71941bd2025-04-18 13:31:48 -0700140 @click=${() => this._handleViewModeClick("terminal")}
Sean McCullough86b56862025-04-18 13:04:03 -0700141 >
142 💻
143 </button>
144 </div>
145 `;
146 }
147}
148
149declare global {
150 interface HTMLElementTagNameMap {
151 "sketch-view-mode-select": SketchViewModeSelect;
152 }
Sean McCullough71941bd2025-04-18 13:31:48 -0700153}