| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 1 | import { css, html, LitElement } from "lit"; |
| Sean McCullough | d9f1337 | 2025-04-21 15:08:49 -0700 | [diff] [blame] | 2 | import { customElement, property } from "lit/decorators.js"; |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 3 | import "./sketch-container-status"; |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 4 | |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 5 | @customElement("sketch-view-mode-select") |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 6 | export 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 McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 12 | static styles = css` |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 13 | /* View Mode Button Styles */ |
| 14 | .view-mode-buttons { |
| 15 | display: flex; |
| 16 | gap: 8px; |
| 17 | margin-right: 10px; |
| 18 | } |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 19 | |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 20 | .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 McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 35 | |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 36 | .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 McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 41 | |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 42 | .emoji-button.active { |
| 43 | background-color: #e6f7ff; |
| 44 | border-color: #1890ff; |
| 45 | color: #1890ff; |
| 46 | } |
| 47 | `; |
| 48 | |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 49 | constructor() { |
| 50 | super(); |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 51 | |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 52 | // 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 McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 60 | |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 61 | // Listen for update-active-mode events |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 62 | this.addEventListener( |
| 63 | "update-active-mode", |
| 64 | this._handleUpdateActiveMode as EventListener, |
| 65 | ); |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 66 | } |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 67 | |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 68 | /** |
| 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 McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 73 | const event = new CustomEvent("view-mode-select", { |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 74 | detail: { mode }, |
| 75 | bubbles: true, |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 76 | composed: true, |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 77 | }); |
| 78 | this.dispatchEvent(event); |
| 79 | } |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 80 | |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 81 | /** |
| 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 McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 94 | |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 95 | // Remove event listeners |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 96 | this.removeEventListener( |
| 97 | "update-active-mode", |
| 98 | this._handleUpdateActiveMode as EventListener, |
| 99 | ); |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | render() { |
| 103 | return html` |
| 104 | <div class="view-mode-buttons"> |
| 105 | <button |
| 106 | id="showConversationButton" |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 107 | class="emoji-button ${this.activeMode === "chat" ? "active" : ""}" |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 108 | title="Conversation View" |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 109 | @click=${() => this._handleViewModeClick("chat")} |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 110 | > |
| 111 | 💬 |
| 112 | </button> |
| 113 | <button |
| 114 | id="showDiffButton" |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 115 | class="emoji-button ${this.activeMode === "diff" ? "active" : ""}" |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 116 | title="Diff View" |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 117 | @click=${() => this._handleViewModeClick("diff")} |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 118 | > |
| 119 | ± |
| 120 | </button> |
| 121 | <button |
| 122 | id="showChartsButton" |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 123 | class="emoji-button ${this.activeMode === "charts" ? "active" : ""}" |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 124 | title="Charts View" |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 125 | @click=${() => this._handleViewModeClick("charts")} |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 126 | > |
| 127 | 📈 |
| 128 | </button> |
| 129 | <button |
| 130 | id="showTerminalButton" |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 131 | class="emoji-button ${this.activeMode === "terminal" ? "active" : ""}" |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 132 | title="Terminal View" |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 133 | @click=${() => this._handleViewModeClick("terminal")} |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 134 | > |
| 135 | 💻 |
| 136 | </button> |
| 137 | </div> |
| 138 | `; |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | declare global { |
| 143 | interface HTMLElementTagNameMap { |
| 144 | "sketch-view-mode-select": SketchViewModeSelect; |
| 145 | } |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 146 | } |