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