| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 1 | <!doctype html> |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 2 | <html lang="en"> |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 3 | <head> |
| 4 | <meta charset="UTF-8" /> |
| 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| 6 | <title>Sketch Diff Viewer Demo</title> |
| 7 | <link |
| 8 | rel="stylesheet" |
| 9 | href="../../../node_modules/diff2html/bundles/css/diff2html.min.css" |
| 10 | /> |
| Philip Zeyliger | 72682df | 2025-04-23 13:09:46 -0700 | [diff] [blame^] | 11 | <script type="module" src="../sketch-diff-view.ts"></script> |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 12 | <style> |
| 13 | body { |
| 14 | font-family: |
| 15 | -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, |
| 16 | Arial, sans-serif; |
| 17 | max-width: 1200px; |
| 18 | margin: 0 auto; |
| 19 | padding: 2rem; |
| 20 | } |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 21 | |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 22 | h1 { |
| 23 | color: #333; |
| 24 | margin-bottom: 2rem; |
| 25 | } |
| 26 | |
| 27 | .control-panel { |
| 28 | margin-bottom: 2rem; |
| 29 | padding: 1rem; |
| 30 | background-color: #f0f0f0; |
| 31 | border-radius: 4px; |
| 32 | } |
| 33 | |
| 34 | input { |
| 35 | padding: 0.5rem; |
| 36 | border-radius: 4px; |
| 37 | border: 1px solid #ccc; |
| 38 | width: 300px; |
| 39 | } |
| 40 | |
| 41 | button { |
| 42 | padding: 0.5rem 1rem; |
| 43 | background-color: #2196f3; |
| 44 | color: white; |
| 45 | border: none; |
| 46 | border-radius: 4px; |
| 47 | cursor: pointer; |
| 48 | margin-left: 1rem; |
| 49 | } |
| 50 | |
| 51 | button:hover { |
| 52 | background-color: #0d8bf2; |
| 53 | } |
| 54 | </style> |
| 55 | |
| 56 | <script> |
| 57 | document.addEventListener("DOMContentLoaded", () => { |
| 58 | const diffViewer = document.getElementById("diffViewer"); |
| 59 | const commitHashInput = document.getElementById("commitHash"); |
| 60 | const viewDiffButton = document.getElementById("viewDiff"); |
| 61 | let commit = false; |
| 62 | viewDiffButton.addEventListener("click", () => { |
| 63 | let diffContent = `diff --git a/sample.txt b/sample.txt |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 64 | index 1111111..2222222 100644 |
| 65 | --- a/sample.txt |
| 66 | +++ b/sample.txt |
| 67 | @@ -1,5 +1,5 @@ |
| 68 | This is a sample file |
| 69 | -This line will be removed |
| 70 | +This line is added as a replacement |
| 71 | This line stays the same |
| 72 | -Another line to remove |
| 73 | +A completely new line |
| 74 | The last line is unchanged`; |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 75 | if (commit) { |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 76 | // For demo purposes, generate fake diff based on commit hash |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 77 | diffContent = `diff --git a/file-${commit.substring(0, 5)}.txt b/file-${commit.substring(0, 5)}.txt |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 78 | index 3333333..4444444 100644 |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 79 | --- a/file-${commit.substring(0, 5)}.txt |
| 80 | +++ b/file-${commit.substring(0, 5)}.txt |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 81 | @@ -1,4 +1,6 @@ |
| 82 | File with commit: ${commit} |
| 83 | +This line was added in commit ${commit} |
| 84 | This line exists in both versions |
| 85 | -This line was removed in commit ${commit} |
| 86 | +This line replaced the removed line |
| 87 | +Another new line added in this commit |
| 88 | Last line of the file`; |
| 89 | } |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 90 | diffViewer.diffText = diffContent; |
| 91 | diffViewer.commitHash = commitHashInput.value.trim(); |
| 92 | }); |
| 93 | }); |
| 94 | </script> |
| 95 | </head> |
| 96 | <body> |
| 97 | <h1>Sketch Diff Viewer Demo</h1> |
| Sean McCullough | 86b5686 | 2025-04-18 13:04:03 -0700 | [diff] [blame] | 98 | |
| Sean McCullough | 71941bd | 2025-04-18 13:31:48 -0700 | [diff] [blame] | 99 | <div class="control-panel"> |
| 100 | <label for="commitHash" |
| 101 | >Commit Hash (leave empty for unstaged changes):</label |
| 102 | > |
| 103 | <input type="text" id="commitHash" placeholder="Enter commit hash" /> |
| 104 | <button id="viewDiff">View Diff</button> |
| 105 | </div> |
| 106 | |
| 107 | <sketch-diff-view id="diffViewer"></sketch-diff-view> |
| 108 | </body> |
| 109 | </html> |