Skip to content

Commit c8f87fa

Browse files
Rich-HarristomoamRich Harris
authored
open in new tab, part two (#330)
* feat: open in new tab * add new tab icon, refactor chrome to put more stuff in CSS * allow output to be collapsed all the way --------- Co-authored-by: tomoam <[email protected]> Co-authored-by: Rich Harris <[email protected]>
1 parent b0e2f6e commit c8f87fa

File tree

6 files changed

+58
-39
lines changed

6 files changed

+58
-39
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@lezer/javascript": "^1.4.1",
4949
"@lezer/lr": "^1.3.3",
5050
"@replit/codemirror-lang-svelte": "^6.0.0",
51-
"@rich_harris/svelte-split-pane": "^1.0.2",
51+
"@rich_harris/svelte-split-pane": "^1.1.0",
5252
"@webcontainer/api": "^1.1.0",
5353
"adm-zip": "^0.5.10",
5454
"ansi-to-html": "^0.7.2",

pnpm-lock.yaml

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/icons/external.svg

+3
Loading

src/routes/tutorial/[slug]/+page.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
</section>
174174
175175
<section slot="b">
176-
<SplitPane type="vertical" min="100px" max="-300px" pos="50%">
176+
<SplitPane type="vertical" min="100px" max="-4.1rem" pos="50%">
177177
<section slot="a">
178178
<SplitPane
179179
id="editor"
+48-33
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
<script>
22
import { createEventDispatcher } from 'svelte';
3-
import refresh from '$lib/icons/refresh.svg';
4-
import terminal from '$lib/icons/terminal.svg';
53
64
/** @type {string} */
75
export let path;
86
97
/** @type {boolean} */
108
export let loading;
119
10+
/** @type {string | null} */
11+
export let href;
12+
1213
const dispatch = createEventDispatcher();
1314
</script>
1415

15-
<div class="chrome">
16-
<button disabled={loading} on:click={() => dispatch('refresh')} aria-label="reload">
17-
<img src={refresh} alt="Reload icon" />
18-
</button>
16+
<div class="chrome" class:loading>
17+
<button disabled={loading} class="reload icon" on:click={() => dispatch('refresh')} aria-label="reload" />
1918

2019
<input
2120
disabled={loading}
@@ -26,13 +25,14 @@
2625
}}
2726
/>
2827

28+
<a {href} class="new-tab icon" target="_blank" aria-label="open in new tab" tabindex="0" />
29+
2930
<button
3031
disabled={loading}
32+
class="terminal icon"
3133
on:click={() => dispatch('toggle_terminal')}
3234
aria-label="toggle terminal"
33-
>
34-
<img src={terminal} alt="Terminal icon" />
35-
</button>
35+
/>
3636
</div>
3737

3838
<style>
@@ -43,26 +43,11 @@
4343
border-top: 1px solid var(--sk-back-4);
4444
}
4545
46-
.chrome button {
47-
padding: 0.8rem;
48-
box-sizing: border-box;
49-
background: var(--sk-back-4);
46+
button {
5047
user-select: none;
5148
}
5249
53-
.chrome button img {
54-
width: 2rem;
55-
height: 2rem;
56-
transition: 0.2s ease-out;
57-
transform: none;
58-
}
59-
60-
.chrome button[aria-label='reload']:active img {
61-
transform: rotate(-360deg);
62-
transition: none;
63-
}
64-
65-
.chrome input {
50+
input {
6651
flex: 1;
6752
padding: 0.5rem 1rem 0.4rem 1rem;
6853
background-color: var(--sk-back-3);
@@ -71,14 +56,44 @@
7156
font-size: 1.6rem;
7257
}
7358
74-
.chrome button,
75-
.chrome input {
76-
border: 2px solid transparent;
77-
}
78-
79-
.chrome button:focus-visible,
80-
.chrome input:focus-visible {
59+
a:focus-visible,
60+
button:focus-visible,
61+
input:focus-visible {
8162
outline: none;
8263
border: 2px solid var(--sk-theme-3);
8364
}
65+
66+
.icon, .icon::after {
67+
position: relative;
68+
height: 100%;
69+
aspect-ratio: 1;
70+
background: var(--sk-back-4) no-repeat 50% 50%;
71+
background-size: 2rem;
72+
}
73+
74+
.loading a {
75+
opacity: 0.5;
76+
}
77+
78+
.new-tab {
79+
background-image: url($lib/icons/external.svg);
80+
}
81+
82+
.terminal {
83+
background-image: url($lib/icons/terminal.svg);
84+
}
85+
86+
.reload::after {
87+
content: '';
88+
position: absolute;
89+
left: 0;
90+
top: 0;
91+
background-image: url($lib/icons/refresh.svg);
92+
transition: 0.2s ease-out;
93+
}
94+
95+
.reload:active::after {
96+
transform: rotate(-360deg);
97+
transition: none;
98+
}
8499
</style>

src/routes/tutorial/[slug]/Output.svelte

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
<Chrome
8282
{path}
8383
{loading}
84+
href={$base && ($base + path)}
8485
on:refresh={() => {
8586
set_iframe_src($base + path);
8687
}}

0 commit comments

Comments
 (0)