Skip to content
This repository was archived by the owner on Oct 27, 2024. It is now read-only.

Commit 6af9e08

Browse files
committed
update to latest sveltekit demo app
1 parent f0f154a commit 6af9e08

22 files changed

+161
-128
lines changed

demo/.gitignore

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
.DS_Store
21
node_modules
3-
/build
2+
3+
# Output
4+
.output
5+
.vercel
46
/.svelte-kit
5-
/package
7+
/build
8+
9+
# OS
10+
.DS_Store
11+
Thumbs.db
12+
13+
# Env
614
.env
715
.env.*
816
!.env.example
9-
.vercel
10-
.output
17+
!.env.test
18+
19+
# Vite
1120
vite.config.js.timestamp-*
1221
vite.config.ts.timestamp-*

demo/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ If you're seeing this, you've probably already done this step. Congrats!
99

1010
```bash
1111
# create a new project in the current directory
12-
npm create svelte@latest
12+
npx sv create
1313

1414
# create a new project in my-app
15-
npm create svelte@latest my-app
15+
npx sv create my-app
1616
```
1717

1818
## Developing
@@ -38,4 +38,4 @@ npm run build
3838
You can preview the production build with `npm run preview`.
3939

4040
> To deploy your app, you may need to install an
41-
> [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
41+
> [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.

demo/tsconfig.json renamed to demo/jsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"strict": true,
1212
"moduleResolution": "bundler"
1313
}
14-
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
14+
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
15+
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
1516
//
1617
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
1718
// from the referenced tsconfig.json - TypeScript does not merge them in

demo/package.json

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
{
22
"name": "demo",
33
"version": "0.0.1",
4+
"type": "module",
45
"scripts": {
56
"dev": "vite dev",
67
"build": "vite build",
78
"preview": "vite preview",
8-
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
9-
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
9+
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
10+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch"
1011
},
11-
"dependencies": {
12-
"@fontsource/fira-mono": "^5.0.8",
13-
"@neoconfetti/svelte": "^2.2.1",
14-
"@sveltejs/kit": "^2.0.6",
15-
"@sveltejs/vite-plugin-svelte": "^3.0.1",
16-
"svelte": "^4.2.8",
17-
"svelte-check": "^3.6.2",
18-
"sveltekit-adapter-deno": "^0.15.0",
19-
"tslib": "^2.6.2",
20-
"typescript": "^5.3.3",
21-
"vite": "^5.0.10"
12+
"devDependencies": {
13+
"@fontsource/fira-mono": "^5.0.0",
14+
"@neoconfetti/svelte": "^2.0.0",
15+
"@sveltejs/adapter-auto": "^3.0.0",
16+
"@sveltejs/kit": "^2.0.0",
17+
"@sveltejs/vite-plugin-svelte": "^4.0.0",
18+
"svelte": "^5.0.0",
19+
"svelte-check": "^4.0.0",
20+
"typescript": "^5.0.0",
21+
"vite": "^5.0.3"
2222
},
23-
"type": "module"
23+
"dependencies": {
24+
"sveltekit-adapter-deno": "^0.15.0"
25+
}
2426
}
File renamed without changes.

demo/src/app.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// See https://kit.svelte.dev/docs/types#app
1+
// See https://svelte.dev/docs/kit/types#app
22
// for information about these interfaces
33
declare global {
44
namespace App {

demo/src/routes/+layout.svelte

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
<script>
22
import Header from './Header.svelte';
3-
import './styles.css';
3+
import '../app.css';
4+
5+
/** @type {{children: import('svelte').Snippet}} */
6+
let { children } = $props();
47
</script>
58

69
<div class="app">
710
<Header />
811

912
<main>
10-
<slot />
13+
{@render children()}
1114
</main>
1215

1316
<footer>
14-
<p>visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to learn SvelteKit</p>
17+
<p>
18+
visit <a href="https://svelte.dev/docs/kit">svelte.dev/docs/kit</a> to learn about SvelteKit
19+
</p>
1520
</footer>
1621
</div>
1722

File renamed without changes.

demo/src/routes/+page.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script>
22
import Counter from './Counter.svelte';
33
import welcome from '$lib/images/svelte-welcome.webp';
4-
import welcome_fallback from '$lib/images/svelte-welcome.png';
4+
import welcomeFallback from '$lib/images/svelte-welcome.png';
55
</script>
66

77
<svelte:head>
@@ -14,7 +14,7 @@
1414
<span class="welcome">
1515
<picture>
1616
<source srcset={welcome} type="image/webp" />
17-
<img src={welcome_fallback} alt="Welcome" />
17+
<img src={welcomeFallback} alt="Welcome" />
1818
</picture>
1919
</span>
2020

demo/src/routes/Counter.svelte

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,41 @@
1-
<script lang="ts">
1+
<script>
22
import { spring } from 'svelte/motion';
33
4-
let count = 0;
4+
let count = $state(0);
55
6-
const displayed_count = spring();
7-
$: displayed_count.set(count);
8-
$: offset = modulo($displayed_count, 1);
6+
// svelte-ignore state_referenced_locally
7+
const displayedCount = spring(count);
98
10-
function modulo(n: number, m: number) {
9+
$effect(() => {
10+
displayedCount.set(count);
11+
});
12+
let offset = $derived(modulo($displayedCount, 1));
13+
14+
/**
15+
* @param {number} n
16+
* @param {number} m
17+
*/
18+
function modulo(n, m) {
1119
// handle negative numbers
1220
return ((n % m) + m) % m;
1321
}
1422
</script>
1523

1624
<div class="counter">
17-
<button on:click={() => (count -= 1)} aria-label="Decrease the counter by one">
25+
<button onclick={() => (count -= 1)} aria-label="Decrease the counter by one">
1826
<svg aria-hidden="true" viewBox="0 0 1 1">
1927
<path d="M0,0.5 L1,0.5" />
2028
</svg>
2129
</button>
2230

2331
<div class="counter-viewport">
2432
<div class="counter-digits" style="transform: translate(0, {100 * offset}%)">
25-
<strong class="hidden" aria-hidden="true">{Math.floor($displayed_count + 1)}</strong>
26-
<strong>{Math.floor($displayed_count)}</strong>
33+
<strong class="hidden" aria-hidden="true">{Math.floor($displayedCount + 1)}</strong>
34+
<strong>{Math.floor($displayedCount)}</strong>
2735
</div>
2836
</div>
2937

30-
<button on:click={() => (count += 1)} aria-label="Increase the counter by one">
38+
<button onclick={() => (count += 1)} aria-label="Increase the counter by one">
3139
<svg aria-hidden="true" viewBox="0 0 1 1">
3240
<path d="M0,0.5 L1,0.5 M0.5,0 L0.5,1" />
3341
</svg>

0 commit comments

Comments
 (0)