Skip to content

Commit f3a8193

Browse files
committed
add reset button to REPL
1 parent e7100f0 commit f3a8193

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

packages/repl/src/lib/Output/Output.svelte

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666
6767
let current = $derived(workspace.current_compiled);
6868
69+
let resultTab: Viewer;
70+
6971
// TODO this effect is a bit of a code smell
7072
$effect(() => {
7173
if (current?.error) {
@@ -189,6 +191,15 @@
189191
<button class="active">Markdown</button>
190192
{:else}
191193
<button aria-current={view === 'result'} onclick={() => (view = 'result')}>Result</button>
194+
<button
195+
aria-current={view === 'result'}
196+
aria-label="Reset result"
197+
class="reset-result"
198+
onclick={() => {
199+
view = 'result';
200+
resultTab.reset();
201+
}}
202+
></button>
192203
<button aria-current={view === 'js'} onclick={() => (view = 'js')}>JS output</button>
193204
<button aria-current={view === 'css'} onclick={() => (view = 'css')}>CSS output</button>
194205
<button aria-current={view === 'ast'} onclick={() => (view = 'ast')}>AST output</button>
@@ -199,6 +210,7 @@
199210
<!-- component viewer -->
200211
<div class="tab-content" class:visible={!is_markdown && view === 'result'}>
201212
<Viewer
213+
bind:this={resultTab}
202214
bind:error={runtimeError}
203215
{status}
204216
{relaxed}
@@ -278,6 +290,18 @@
278290
&[aria-current='true'] {
279291
border-bottom: 1px solid var(--sk-fg-accent);
280292
}
293+
294+
&.reset-result {
295+
width: 2em;
296+
vertical-align: bottom;
297+
background: url(./reset-light.svg) 50% 50% no-repeat;
298+
background-size: 1em;
299+
margin-left: -1ch;
300+
cursor: pointer;
301+
:root.dark & {
302+
background-image: url(./reset-dark.svg);
303+
}
304+
}
281305
}
282306
283307
.tab-content {

packages/repl/src/lib/Output/Viewer.svelte

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@
231231
}
232232
});
233233
234+
export const reset = () => {
235+
if (ready) apply_bundle(bundle);
236+
};
237+
234238
$effect(() => {
235239
if (injectedCSS && proxy && ready) {
236240
proxy.eval(
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)