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