blob: 1dc933745802f76ed34d801a5d58031e02e6f8c9 [file] [log] [blame]
Sean McCullough71941bd2025-04-18 13:31:48 -07001<!doctype html>
Sean McCullough86b56862025-04-18 13:04:03 -07002<html lang="en">
Sean McCullough71941bd2025-04-18 13:31:48 -07003 <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 Rulee2a8c2f2025-04-23 15:09:25 +010012 type="module" src="../sketch-diff-view.ts"
Sean McCullough71941bd2025-04-18 13:31:48 -070013 ></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 McCullough86b56862025-04-18 13:04:03 -070023
Sean McCullough71941bd2025-04-18 13:31:48 -070024 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 McCullough86b56862025-04-18 13:04:03 -070066index 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 McCullough71941bd2025-04-18 13:31:48 -070077 if (commit) {
Sean McCullough86b56862025-04-18 13:04:03 -070078 // For demo purposes, generate fake diff based on commit hash
Sean McCullough71941bd2025-04-18 13:31:48 -070079 diffContent = `diff --git a/file-${commit.substring(0, 5)}.txt b/file-${commit.substring(0, 5)}.txt
Sean McCullough86b56862025-04-18 13:04:03 -070080index 3333333..4444444 100644
Sean McCullough71941bd2025-04-18 13:31:48 -070081--- a/file-${commit.substring(0, 5)}.txt
82+++ b/file-${commit.substring(0, 5)}.txt
Sean McCullough86b56862025-04-18 13:04:03 -070083@@ -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 McCullough71941bd2025-04-18 13:31:48 -070092 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 McCullough86b56862025-04-18 13:04:03 -0700100
Sean McCullough71941bd2025-04-18 13:31:48 -0700101 <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>