blob: be8ab8ec97d2d61b09057f11eb0d2c250def303d [file] [log] [blame]
Sean McCullough86b56862025-04-18 13:04:03 -07001<html>
2 <head>
3 <title>sketch-timeline demo</title>
4 <link rel="stylesheet" href="demo.css" />
Sean McCullough71941bd2025-04-18 13:31:48 -07005 <script
6 src="/dist/web-components/sketch-timeline.js"
7 type="module"
8 ></script>
Sean McCullough86b56862025-04-18 13:04:03 -07009 <script>
10 const messages = [
11 {
12 type: "user",
13 content: "a user message",
14 },
15 {
16 type: "agent",
17 content: "an agent message",
18 },
19 {
20 type: "agent",
21 content: "an agent message",
22 },
23 {
24 type: "agent",
25 content: "an agent message",
26 },
27 {
28 type: "user",
29 content: "a user message",
30 },
31 {
32 type: "user",
33 content: "a user message",
34 },
Sean McCullough2c5bba42025-04-20 19:33:17 -070035 {
36 type: "agent",
37 content: "an agent message",
38 },
39 {
40 type: "user",
41 content: "a user message",
42 },
43 {
44 type: "tool",
45 content: "a tool use message",
46 },
47 {
48 type: "commit",
49 end_of_turn: false,
50 content: "",
51 commits: [
52 {
53 hash: "ece101c103ec231da87f4df05c1b5e6a24e13add",
54 subject: "Add README.md for web components directory",
55 body: "This adds documentation for the web components used in the Loop UI,\nincluding a description of each component, usage examples, and\ndevelopment guidelines.\n\nCo-Authored-By: sketch\nadd README.md for loop/webui/src/web-components",
56 pushed_branch:
57 "sketch/create-readmemd-for-web-components-directory",
58 },
59 ],
60 timestamp: "2025-04-14T16:39:33.639533919Z",
61 conversation_id: "",
62 idx: 17,
63 },
64 {
65 type: "agent",
66 content: "an end-of-turn agent message",
67 end_of_turn: true,
68 },
Sean McCullough86b56862025-04-18 13:04:03 -070069 ];
Sean McCullough2c5bba42025-04-20 19:33:17 -070070
Sean McCullough86b56862025-04-18 13:04:03 -070071 document.addEventListener("DOMContentLoaded", () => {
Sean McCullough2c5bba42025-04-20 19:33:17 -070072 const appShell = document.querySelector(".app-shell");
Sean McCullough71941bd2025-04-18 13:31:48 -070073 const timelineEl = document.querySelector("sketch-timeline");
Sean McCullough86b56862025-04-18 13:04:03 -070074 timelineEl.messages = messages;
Sean McCullough2c5bba42025-04-20 19:33:17 -070075 timelineEl.scrollContainer = appShell;
76 const addMessagesCheckbox = document.querySelector("#addMessages");
77 addMessagesCheckbox.addEventListener("change", toggleAddMessages);
78
79 let addingMessages = false;
80 const addNewMessagesInterval = 1000;
81
82 function addNewMessages() {
83 if (!addingMessages) {
84 return;
85 }
86 const n = new Date().getMilliseconds() % messages.length;
87 const msgToDup = messages[n];
88 const dup = JSON.parse(JSON.stringify(msgToDup));
89 dup.idx = messages.length;
90 dup.timestamp = new Date().toISOString();
91 messages.push(dup);
92 timelineEl.messages = messages.concat();
93 timelineEl.prop;
94 timelineEl.requestUpdate();
95 }
96
97 let addMessagesHandler = setInterval(
98 addNewMessages,
99 addNewMessagesInterval,
100 );
101
102 function toggleAddMessages() {
103 addingMessages = !addingMessages;
104 if (addingMessages) {
105 } else {
106 }
107 }
Sean McCullough86b56862025-04-18 13:04:03 -0700108 });
109 </script>
Sean McCullough2c5bba42025-04-20 19:33:17 -0700110 <style>
111 .app-shell {
112 display: block;
113 font-family:
114 system-ui,
115 -apple-system,
116 BlinkMacSystemFont,
117 "Segoe UI",
118 Roboto,
119 sans-serif;
120 color: rgb(51, 51, 51);
121 line-height: 1.4;
122 min-height: 100vh;
123 width: 100%;
124 position: relative;
125 overflow-x: hidden;
126 }
127 .app-header {
128 flex-grow: 0;
129 }
130 .view-container {
131 flex-grow: 2;
132 }
133 </style>
Sean McCullough86b56862025-04-18 13:04:03 -0700134 </head>
135 <body>
Sean McCullough2c5bba42025-04-20 19:33:17 -0700136 <div class="app-shell">
137 <div class="app-header">
138 <h1>sketch-timeline demo</h1>
139 <input
140 type="checkbox"
141 id="addMessages"
142 title="Automatically add new messages"
143 /><label for="addMessages">Automatically add new messages</label>
144 </div>
145 <div class="view-container">
146 <div class="chat-view view-active">
147 <sketch-timeline></sketch-timeline>
148 </div>
149 </div>
150 </div>
Sean McCullough86b56862025-04-18 13:04:03 -0700151 </body>
Sean McCullough71941bd2025-04-18 13:31:48 -0700152</html>