blob: b55282a6ac694f393e1dd91a549d4ace9a96250c [file] [log] [blame]
Sean McCullough86b56862025-04-18 13:04:03 -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';
6
7@customElement('sketch-view-mode-select')
8export 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`
20/* View Mode Button Styles */
21.view-mode-buttons {
22 display: flex;
23 gap: 8px;
24 margin-right: 10px;
25}
26
27.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}
42
43.emoji-button:hover {
44 background-color: #f0f0f0;
45 transform: translateY(-2px);
46 box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
47}
48
49.emoji-button.active {
50 background-color: #e6f7ff;
51 border-color: #1890ff;
52 color: #1890ff;
53}
54`;
55
56 constructor() {
57 super();
58
59 // 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();
67
68 // Listen for update-active-mode events
69 this.addEventListener('update-active-mode', this._handleUpdateActiveMode as EventListener);
70 }
71
72 /**
73 * Handle view mode button clicks
74 */
75 private _handleViewModeClick(mode: "chat" | "diff" | "charts" | "terminal") {
76 // Dispatch a custom event to notify the app shell to change the view
77 const event = new CustomEvent('view-mode-select', {
78 detail: { mode },
79 bubbles: true,
80 composed: true
81 });
82 this.dispatchEvent(event);
83 }
84
85 /**
86 * Handle updates to the active mode
87 */
88 private _handleUpdateActiveMode(event: CustomEvent) {
89 const { mode } = event.detail;
90 if (mode) {
91 this.activeMode = mode;
92 }
93 }
94
95 // See https://lit.dev/docs/components/lifecycle/
96 disconnectedCallback() {
97 super.disconnectedCallback();
98
99 // Remove event listeners
100 this.removeEventListener('update-active-mode', this._handleUpdateActiveMode as EventListener);
101 }
102
103 render() {
104 return html`
105 <div class="view-mode-buttons">
106 <button
107 id="showConversationButton"
108 class="emoji-button ${this.activeMode === 'chat' ? 'active' : ''}"
109 title="Conversation View"
110 @click=${() => this._handleViewModeClick('chat')}
111 >
112 💬
113 </button>
114 <button
115 id="showDiffButton"
116 class="emoji-button ${this.activeMode === 'diff' ? 'active' : ''}"
117 title="Diff View"
118 @click=${() => this._handleViewModeClick('diff')}
119 >
120 ±
121 </button>
122 <button
123 id="showChartsButton"
124 class="emoji-button ${this.activeMode === 'charts' ? 'active' : ''}"
125 title="Charts View"
126 @click=${() => this._handleViewModeClick('charts')}
127 >
128 📈
129 </button>
130 <button
131 id="showTerminalButton"
132 class="emoji-button ${this.activeMode === 'terminal' ? 'active' : ''}"
133 title="Terminal View"
134 @click=${() => this._handleViewModeClick('terminal')}
135 >
136 💻
137 </button>
138 </div>
139 `;
140 }
141}
142
143declare global {
144 interface HTMLElementTagNameMap {
145 "sketch-view-mode-select": SketchViewModeSelect;
146 }
147}