blob: 6ab6e62fd7f2278b0d66300e87b6dee665b3aa62 [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 />
Philip Zeyliger72682df2025-04-23 13:09:46 -070011 <script type="module" src="../sketch-diff-view.ts"></script>
Sean McCullough71941bd2025-04-18 13:31:48 -070012 <style>
13 body {
Autoformatterd8adbba2025-04-27 19:33:42 +000014 font-family:
15 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
16 Arial, sans-serif;
Sean McCullough71941bd2025-04-18 13:31:48 -070017 max-width: 1200px;
18 margin: 0 auto;
19 padding: 2rem;
20 }
Sean McCullough86b56862025-04-18 13:04:03 -070021
Sean McCullough71941bd2025-04-18 13:31:48 -070022 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 McCullough86b56862025-04-18 13:04:03 -070064index 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 McCullough71941bd2025-04-18 13:31:48 -070075 if (commit) {
Sean McCullough86b56862025-04-18 13:04:03 -070076 // For demo purposes, generate fake diff based on commit hash
Sean McCullough71941bd2025-04-18 13:31:48 -070077 diffContent = `diff --git a/file-${commit.substring(0, 5)}.txt b/file-${commit.substring(0, 5)}.txt
Sean McCullough86b56862025-04-18 13:04:03 -070078index 3333333..4444444 100644
Sean McCullough71941bd2025-04-18 13:31:48 -070079--- a/file-${commit.substring(0, 5)}.txt
80+++ b/file-${commit.substring(0, 5)}.txt
Sean McCullough86b56862025-04-18 13:04:03 -070081@@ -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 McCullough71941bd2025-04-18 13:31:48 -070090 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 McCullough86b56862025-04-18 13:04:03 -070098
Sean McCullough71941bd2025-04-18 13:31:48 -070099 <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>