| banksean | d52d39d | 2025-07-20 14:57:38 -0700 | [diff] [blame] | 1 | import { DemoModule } from "./demo-framework/types"; |
| 2 | import { demoUtils } from "./demo-fixtures/index"; |
| 3 | |
| 4 | const demo: DemoModule = { |
| 5 | title: "Sketch Monaco Diff View Demo", |
| 6 | description: |
| 7 | "Monaco-based diff view with range and file pickers using mock data", |
| 8 | imports: ["../sketch-diff2-view.ts"], |
| 9 | |
| 10 | customStyles: ` |
| 11 | .demo-container { |
| 12 | display: flex; |
| 13 | height: 80vh; |
| 14 | min-height: 600px; |
| 15 | border: 1px solid #ddd; |
| 16 | margin-top: 20px; |
| 17 | margin-bottom: 30px; |
| 18 | } |
| 19 | |
| 20 | sketch-diff2-view { |
| 21 | width: 100%; |
| 22 | height: 100%; |
| 23 | } |
| 24 | `, |
| 25 | |
| 26 | setup: async (container: HTMLElement) => { |
| 27 | // Import the mock service |
| 28 | const { MockGitDataService } = await import("./mock-git-data-service"); |
| 29 | |
| 30 | const section = demoUtils.createDemoSection( |
| 31 | "Monaco Diff View", |
| 32 | "Demonstrates the Monaco-based diff view with range and file pickers using mock data to simulate real API responses.", |
| 33 | ); |
| 34 | |
| 35 | // Create control panel |
| 36 | const controlPanel = document.createElement("div"); |
| 37 | controlPanel.className = "control-panel"; |
| 38 | controlPanel.style.marginBottom = "1rem"; |
| 39 | controlPanel.style.padding = "1rem"; |
| banksean | 1ee0bc6 | 2025-07-22 23:24:18 +0000 | [diff] [blame] | 40 | controlPanel.style.backgroundColor = "var(--demo-control-bg);"; |
| banksean | d52d39d | 2025-07-20 14:57:38 -0700 | [diff] [blame] | 41 | controlPanel.style.borderRadius = "4px"; |
| 42 | controlPanel.innerHTML = ` |
| 43 | <p><strong>Features:</strong></p> |
| 44 | <ul> |
| 45 | <li>Monaco editor integration for syntax highlighting</li> |
| 46 | <li>Side-by-side diff view</li> |
| 47 | <li>Git range and file picker functionality</li> |
| 48 | <li>Mock data service for demonstration</li> |
| 49 | </ul> |
| 50 | `; |
| 51 | |
| 52 | // Create demo container |
| 53 | const demoContainer = document.createElement("div"); |
| 54 | demoContainer.className = "demo-container"; |
| 55 | |
| 56 | // Create the diff2 view component |
| 57 | const diff2View = document.createElement("sketch-diff2-view"); |
| 58 | |
| 59 | // Create and set up mock service |
| 60 | const mockService = new MockGitDataService(); |
| 61 | console.log("Demo initialized with MockGitDataService"); |
| 62 | |
| 63 | // Set the git service property |
| 64 | diff2View.gitService = mockService; |
| 65 | |
| 66 | demoContainer.appendChild(diff2View); |
| 67 | section.appendChild(controlPanel); |
| 68 | section.appendChild(demoContainer); |
| 69 | container.appendChild(section); |
| 70 | }, |
| 71 | }; |
| 72 | |
| 73 | export default demo; |