Skip to content

Commit 016add4

Browse files
committed
Update welcome project to Svelte 5
1 parent a9db435 commit 016add4

File tree

4 files changed

+60
-46
lines changed

4 files changed

+60
-46
lines changed

src/welcome/InfoBox.svelte

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
<script lang="ts">
2+
import type { Snippet } from 'svelte';
3+
4+
interface Props {
5+
title: Snippet;
6+
detail1: Snippet;
7+
detail2?: Snippet;
8+
}
9+
10+
let { title, detail1, detail2 }: Props = $props();
211
</script>
312

413
<style>
@@ -27,17 +36,17 @@
2736
<div class="container">
2837
<div class="content">
2938
<div class="title">
30-
<slot name="title" />
39+
{@render title()}
3140
</div>
3241
<hr />
3342
<div class="detail">
3443
&bull;
35-
<slot name="detail1" />
44+
{@render detail1()}
3645
</div>
37-
{#if $$slots.detail2}
46+
{#if detail2}
3847
<div class="detail">
3948
&bull;
40-
<slot name="detail2" />
49+
{@render detail2()}
4150
</div>
4251
{/if}
4352
</div>

src/welcome/Welcome.svelte

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
import InfoBox from './InfoBox.svelte';
88
9-
let ready = false;
9+
let ready = $state(false);
1010
1111
onMount(() => {
1212
ready = true;
@@ -96,39 +96,58 @@
9696
{#if ready}
9797
<main transition:fade={{ delay: 400, duration: 300 }}>
9898
<InfoBox>
99-
<span slot="title">Getting started</span>
100-
<span slot="detail1">
101-
Open Treetop by clicking its icon (<img
102-
class="icon"
103-
src={icon}
104-
alt="Treetop Icon" />) in the toolbar.
105-
</span>
106-
<span slot="detail2"
107-
>Treetop shows all your bookmarks on a single page.</span>
99+
{#snippet title()}
100+
<span>Getting started</span>
101+
{/snippet}
102+
{#snippet detail1()}
103+
<span>
104+
Open Treetop by clicking its icon (<img
105+
class="icon"
106+
src={icon}
107+
alt="Treetop Icon" />) in the toolbar.
108+
</span>
109+
{/snippet}
110+
{#snippet detail2()}
111+
<span>Treetop shows all your bookmarks on a single page.</span>
112+
{/snippet}
108113
</InfoBox>
109114

110115
<InfoBox>
111-
<span slot="title">Always up-to-date</span>
112-
<span slot="detail1">Treetop updates automatically as you browse.</span>
113-
<span slot="detail2"
114-
>Recently visited bookmarks have a larger font.
115-
</span>
116+
{#snippet title()}
117+
<span>Always up-to-date</span>
118+
{/snippet}
119+
{#snippet detail1()}
120+
<span>Treetop updates automatically as you browse.</span>
121+
{/snippet}
122+
{#snippet detail2()}
123+
<span>Recently visited bookmarks have a larger font. </span>
124+
{/snippet}
116125
</InfoBox>
117126

118127
<InfoBox>
119-
<span slot="title">Find and edit your bookmarks</span>
120-
<span slot="detail1">Search for bookmarks by name or URL.</span>
121-
<span slot="detail2">
122-
Right-click to edit or delete bookmarks and folders.
123-
</span>
128+
{#snippet title()}
129+
<span>Find and edit your bookmarks</span>
130+
{/snippet}
131+
{#snippet detail1()}
132+
<span>Search for bookmarks by name or URL.</span>
133+
{/snippet}
134+
{#snippet detail2()}
135+
<span> Right-click to edit or delete bookmarks and folders. </span>
136+
{/snippet}
124137
</InfoBox>
125138

126139
<InfoBox>
127-
<span slot="title">Customize</span>
128-
<span slot="detail1">
129-
Click the Preferences button to customize Treetop's display.
130-
</span>
131-
<span slot="detail2">Click on a folder to make it the root folder.</span>
140+
{#snippet title()}
141+
<span>Customize</span>
142+
{/snippet}
143+
{#snippet detail1()}
144+
<span>
145+
Click the Preferences button to customize Treetop's display.
146+
</span>
147+
{/snippet}
148+
{#snippet detail2()}
149+
<span>Click on a folder to make it the root folder.</span>
150+
{/snippet}
132151
</InfoBox>
133152
</main>
134153
{/if}

src/welcome/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
// eslint-disable-next-line simple-import-sort/imports
22
import 'normalize.css/normalize.css';
33

4+
import { mount } from 'svelte';
45
import Welcome from './Welcome.svelte';
56

67
const target = document.getElementById('app');
78
if (!target) {
89
throw new Error('Missing app element');
910
}
1011

11-
new Welcome({
12+
mount(Welcome, {
1213
// Play transitions on first render
1314
intro: true,
1415
target,

src/welcome/vite.config.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { resolve } from 'path';
22
import { type ViteUserConfig, defineProject, mergeConfig } from 'vitest/config';
33
import { svelte } from '@sveltejs/vite-plugin-svelte';
44
import { svelteTesting } from '@testing-library/svelte/vite';
5-
import { sveltePreprocess } from 'svelte-preprocess';
65
import tsconfigPaths from 'vite-tsconfig-paths';
76
import { developmentConfig } from '../../vite.common-development.config.js';
87
import { getTreetopDistName } from '../../vite.common.config.js';
@@ -12,28 +11,14 @@ const dist = getTreetopDistName();
1211
// https://vitejs.dev/config/
1312
export default defineProject(({ mode }) => {
1413
const commonConfig: ViteUserConfig = {
15-
plugins: [
16-
tsconfigPaths(),
17-
svelte({
18-
preprocess: sveltePreprocess(),
19-
}),
20-
svelteTesting(),
21-
],
14+
plugins: [tsconfigPaths(), svelte(), svelteTesting()],
2215
build: {
2316
outDir: resolve(__dirname, '../../', dist),
2417
rollupOptions: {
2518
input: resolve(__dirname, './welcome.html'),
2619
},
2720
},
2821
test: {
29-
// Work around onMount not being called when running tests
30-
// https://github.com/vitest-dev/vitest/issues/2834#issuecomment-1439576110
31-
alias: [
32-
{
33-
find: /^svelte$/,
34-
replacement: 'svelte/internal',
35-
},
36-
],
3722
environment: 'jsdom',
3823
restoreMocks: true,
3924
setupFiles: ['../../test/vitest-setup.ts'],

0 commit comments

Comments
 (0)