Skip to content

Commit fa4072f

Browse files
committed
more logview svelte 5 porting
1 parent a5282b9 commit fa4072f

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

tools/logview/frontend/src/App.svelte

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
let btnText = $state("pause scrolling");
1212
let searchTerm = $state("");
1313
let searchTermLC = "";
14-
let element = $state();
14+
/** @type {HTMLElement} */
15+
let logAreaEl;
1516
1617
/**
1718
* @param {string} s
@@ -47,13 +48,18 @@
4748
}
4849
4950
if (searchTermLC === "") {
50-
logs = logs;
5151
filteredLogs = logs;
52+
if (!autoScrollPaused) {
53+
scrollToBottom(logAreaEl);
54+
}
5255
return;
5356
}
5457
5558
if (didMatch) {
5659
filteredLogs = filteredLogs;
60+
if (!autoScrollPaused) {
61+
scrollToBottom(logAreaEl);
62+
}
5763
}
5864
}
5965
@@ -84,14 +90,6 @@
8490
node.scroll({ top: node.scrollHeight });
8591
}
8692
87-
// TODO(port): run on changes to logs
88-
// afterUpdate(() => {
89-
// if (autoScrollPaused) {
90-
// return;
91-
// }
92-
// scrollToBottom(element);
93-
// });
94-
9593
let windowTitle = "Logview " + version;
9694
// @ts-ignore
9795
window.runtime.WindowSetTitle(windowTitle);
@@ -134,14 +132,14 @@
134132
<button onclick={clearLogs}>clear</button>
135133
<div>{len(logs)} line, {len(filteredLogs)} shown</div>
136134
<div style="flex-grow: 1"></div>
137-
<button onclick={preventDefault(aboutClicked)}>about</button>
135+
<button onclick={aboutClicked}>about</button>
138136
</div>
139-
<div bind:this={element} class="log">
137+
<div bind:this={logAreaEl} class="log-area">
140138
{#if len(filteredLogs) == 0}
141139
<div class="no-results">No results matching '<b>{searchTerm}</b>'</div>
142140
{:else}
143141
{#each filteredLogs as log (log[1])}
144-
<span>{log[0]}</span><br />
142+
<span class="log-line">{log[0]}</span><br />
145143
{/each}
146144
{/if}
147145
</div>
@@ -172,14 +170,16 @@
172170
column-gap: 0.5rem;
173171
}
174172
175-
.log {
173+
.log-area {
176174
overflow: auto;
177175
margin-top: 0.5rem;
178176
/* background: rgb(239, 250, 254); */
179177
height: 100%;
180178
background-color: rgb(255, 255, 255);
181179
}
182-
span {
180+
.log-line {
183181
font-family: monospace;
182+
content-visibility: auto;
183+
/* contain-intrinsic-size: 1rem; */
184184
}
185185
</style>

0 commit comments

Comments
 (0)