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