| philip.zeyliger | 26bc659 | 2025-06-30 20:15:30 -0700 | [diff] [blame] | 1 | /* eslint-disable @typescript-eslint/no-explicit-any */ |
| banksean | d5c849d | 2025-06-26 15:48:31 +0000 | [diff] [blame] | 2 | /** |
| 3 | * Shared demo fixtures for SketchViewModeSelect component |
| 4 | */ |
| 5 | |
| 6 | /** |
| 7 | * Sample view mode configurations for different scenarios |
| 8 | */ |
| 9 | export const sampleViewModeConfigs = { |
| 10 | // Basic configuration with no diff stats |
| 11 | basic: { |
| 12 | activeMode: "chat" as const, |
| 13 | diffLinesAdded: 0, |
| 14 | diffLinesRemoved: 0, |
| 15 | }, |
| 16 | |
| 17 | // Configuration with small diff stats |
| 18 | smallDiff: { |
| 19 | activeMode: "diff2" as const, |
| 20 | diffLinesAdded: 5, |
| 21 | diffLinesRemoved: 2, |
| 22 | }, |
| 23 | |
| 24 | // Configuration with large diff stats |
| 25 | largeDiff: { |
| 26 | activeMode: "diff2" as const, |
| 27 | diffLinesAdded: 247, |
| 28 | diffLinesRemoved: 156, |
| 29 | }, |
| 30 | |
| 31 | // Configuration with terminal mode active |
| 32 | terminalActive: { |
| 33 | activeMode: "terminal" as const, |
| 34 | diffLinesAdded: 12, |
| 35 | diffLinesRemoved: 8, |
| 36 | }, |
| 37 | |
| 38 | // Configuration with only additions |
| 39 | additionsOnly: { |
| 40 | activeMode: "diff2" as const, |
| 41 | diffLinesAdded: 35, |
| 42 | diffLinesRemoved: 0, |
| 43 | }, |
| 44 | |
| 45 | // Configuration with only deletions |
| 46 | deletionsOnly: { |
| 47 | activeMode: "diff2" as const, |
| 48 | diffLinesAdded: 0, |
| 49 | diffLinesRemoved: 28, |
| 50 | }, |
| 51 | }; |
| 52 | |
| 53 | /** |
| 54 | * Sample scenarios for interactive demos |
| 55 | */ |
| 56 | export const viewModeScenarios = [ |
| 57 | { |
| 58 | name: "Fresh Start", |
| 59 | description: "No changes, chat mode active", |
| 60 | config: sampleViewModeConfigs.basic, |
| 61 | }, |
| 62 | { |
| 63 | name: "Small Changes", |
| 64 | description: "Few lines changed, diff view active", |
| 65 | config: sampleViewModeConfigs.smallDiff, |
| 66 | }, |
| 67 | { |
| 68 | name: "Major Refactor", |
| 69 | description: "Large number of changes across files", |
| 70 | config: sampleViewModeConfigs.largeDiff, |
| 71 | }, |
| 72 | { |
| 73 | name: "Terminal Work", |
| 74 | description: "Running commands, terminal active", |
| 75 | config: sampleViewModeConfigs.terminalActive, |
| 76 | }, |
| 77 | { |
| 78 | name: "New Feature", |
| 79 | description: "Only additions, new code written", |
| 80 | config: sampleViewModeConfigs.additionsOnly, |
| 81 | }, |
| 82 | { |
| 83 | name: "Code Cleanup", |
| 84 | description: "Only deletions, removing unused code", |
| 85 | config: sampleViewModeConfigs.deletionsOnly, |
| 86 | }, |
| 87 | ]; |
| 88 | |
| 89 | /** |
| 90 | * Type for view mode configuration |
| 91 | */ |
| 92 | export type ViewModeConfig = { |
| 93 | activeMode: "chat" | "diff2" | "terminal"; |
| 94 | diffLinesAdded: number; |
| 95 | diffLinesRemoved: number; |
| 96 | }; |
| 97 | |
| 98 | /** |
| 99 | * Helper function to apply configuration to a component |
| 100 | */ |
| 101 | export function applyViewModeConfig( |
| 102 | component: any, |
| 103 | config: ViewModeConfig, |
| 104 | ): void { |
| 105 | component.activeMode = config.activeMode; |
| 106 | component.diffLinesAdded = config.diffLinesAdded; |
| 107 | component.diffLinesRemoved = config.diffLinesRemoved; |
| 108 | component.requestUpdate(); |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Create a series of buttons for testing different scenarios |
| 113 | */ |
| 114 | export function createViewModeTestButtons( |
| 115 | component: any, |
| 116 | container: HTMLElement, |
| 117 | ): void { |
| 118 | const buttonContainer = document.createElement("div"); |
| 119 | buttonContainer.style.cssText = ` |
| 120 | display: flex; |
| 121 | flex-wrap: wrap; |
| 122 | gap: 8px; |
| 123 | margin: 15px 0; |
| 124 | padding: 10px; |
| 125 | background: #f6f8fa; |
| 126 | border-radius: 6px; |
| 127 | `; |
| 128 | |
| 129 | viewModeScenarios.forEach((scenario) => { |
| 130 | const button = document.createElement("button"); |
| 131 | button.textContent = scenario.name; |
| 132 | button.title = scenario.description; |
| 133 | button.style.cssText = ` |
| 134 | padding: 6px 12px; |
| 135 | background: #0969da; |
| 136 | color: white; |
| 137 | border: none; |
| 138 | border-radius: 4px; |
| 139 | cursor: pointer; |
| 140 | font-size: 12px; |
| 141 | transition: background-color 0.2s; |
| 142 | `; |
| 143 | |
| 144 | button.addEventListener("mouseenter", () => { |
| 145 | button.style.backgroundColor = "#0860ca"; |
| 146 | }); |
| 147 | |
| 148 | button.addEventListener("mouseleave", () => { |
| 149 | button.style.backgroundColor = "#0969da"; |
| 150 | }); |
| 151 | |
| 152 | button.addEventListener("click", () => { |
| 153 | applyViewModeConfig(component, scenario.config); |
| 154 | |
| 155 | // Visual feedback |
| 156 | const allButtons = buttonContainer.querySelectorAll("button"); |
| 157 | allButtons.forEach((btn) => { |
| 158 | (btn as HTMLButtonElement).style.backgroundColor = "#0969da"; |
| 159 | }); |
| 160 | button.style.backgroundColor = "#2da44e"; |
| 161 | |
| 162 | setTimeout(() => { |
| 163 | button.style.backgroundColor = "#0969da"; |
| 164 | }, 1000); |
| 165 | }); |
| 166 | |
| 167 | buttonContainer.appendChild(button); |
| 168 | }); |
| 169 | |
| 170 | container.appendChild(buttonContainer); |
| 171 | } |