Skip to content

Commit

Permalink
update svelte and svelte kit
Browse files Browse the repository at this point in the history
  • Loading branch information
emiljohansson committed Dec 25, 2024
1 parent 4861624 commit 8099f4d
Show file tree
Hide file tree
Showing 37 changed files with 302 additions and 250 deletions.
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ apps/next/tsconfig.json

# supabase database types
apps/next/src/lib/database.types.ts

# unfixable/dont have time for
apps/svelte/src/app.html
1 change: 1 addition & 0 deletions apps/code-not-found/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
"tsconfig": "workspace:*"
}
}

1 change: 1 addition & 0 deletions apps/design/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@
"tsconfig": "workspace:*"
}
}

1 change: 1 addition & 0 deletions apps/games/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@
"tsconfig": "workspace:*"
}
}

1 change: 1 addition & 0 deletions apps/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,4 @@
"tsconfig": "workspace:*"
}
}

1 change: 1 addition & 0 deletions apps/oauth-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@
"@types/jsonwebtoken": "9.0.1"
}
}

1 change: 1 addition & 0 deletions apps/password-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@
"tsconfig": "workspace:*"
}
}

4 changes: 3 additions & 1 deletion apps/svelte/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ pnpm-lock.yaml
package-lock.json
yarn.lock

*.timestamp-*.mjs
*.timestamp-*.mjs

./src/app.html
1 change: 0 additions & 1 deletion apps/svelte/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"trailingComma": "all",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"pluginSearchDirs": ["."],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }],
"semi": false
}
7 changes: 4 additions & 3 deletions apps/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@
"@repo/ui": "workspace:*",
"@sveltejs/adapter-auto": "3.3.1",
"@sveltejs/kit": "2.15.0",
"@sveltejs/vite-plugin-svelte": "5.0.3",
"@types/feather-icons": "4.29.1",
"@typescript-eslint/eslint-plugin": "6.12.0",
"@typescript-eslint/parser": "6.12.0",
"config": "workspace:*",
"eslint": "8.54.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-svelte": "2.35.1",
"eslint-plugin-svelte": "^2.45.1",
"feather-icons": "4.29.0",
"just-debounce-it": "3.2.0",
"just-range": "4.1.1",
"prettier": "2.8.0",
"prettier-plugin-svelte": "3.1.2",
"prettier": "^3.1.0",
"prettier-plugin-svelte": "^3.2.6",
"svelte": "5.16.0",
"svelte-check": "4.1.1",
"tsconfig": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion apps/svelte/src/app.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
11 changes: 8 additions & 3 deletions apps/svelte/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<script>
<script lang="ts">
import '@repo/ui/styles.css'
import "../app.css"
import '../app.css'
interface Props {
children?: import('svelte').Snippet
}
let { children }: Props = $props()
// import feather from "feather-icons"
</script>

Expand All @@ -27,4 +32,4 @@
</a>
</nav>

<slot />
{@render children?.()}
92 changes: 46 additions & 46 deletions apps/svelte/src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
<script>
const projects = [
{
href: "https://emiljohansson.dev/design",
text: "Design System",
href: 'https://emiljohansson.dev/design',
text: 'Design System',
external: true,
description: "Design system for the apps developed by Emil Johansson.",
test: "design-system",
description: 'Design system for the apps developed by Emil Johansson.',
test: 'design-system',
},
{
href: "https://pw.emiljohansson.dev",
text: "Password Manager",
href: 'https://pw.emiljohansson.dev',
text: 'Password Manager',
external: true,
description: "Password manager for the apps developed by Emil Johansson.",
test: "password-manager",
description: 'Password manager for the apps developed by Emil Johansson.',
test: 'password-manager',
},
{
href: "https://games.emiljohansson.dev",
text: "Games",
href: 'https://games.emiljohansson.dev',
text: 'Games',
external: true,
description: "Some simple games.",
test: "games",
description: 'Some simple games.',
test: 'games',
},
{
href: "/password-generator",
text: "Password Generator",
description: "Generate a password that is difficult to guess.",
test: "password-generator",
href: '/password-generator',
text: 'Password Generator',
description: 'Generate a password that is difficult to guess.',
test: 'password-generator',
},
{
href: "/random-string",
text: "Random String",
description: "Generate a random string of characters.",
test: "random-string",
href: '/random-string',
text: 'Random String',
description: 'Generate a random string of characters.',
test: 'random-string',
},
{
href: "/current-time",
text: "Current Time",
description: "Get the current time.",
test: "current-time",
href: '/current-time',
text: 'Current Time',
description: 'Get the current time.',
test: 'current-time',
},
{
href: "/two-way-auth-generate",
text: "Two-Factor Authentication - Generate Code",
description: "Generate a two-factor authentication code.",
test: "two-way-auth-generate",
href: '/two-way-auth-generate',
text: 'Two-Factor Authentication - Generate Code',
description: 'Generate a two-factor authentication code.',
test: 'two-way-auth-generate',
},
{
href: "/two-way-auth-enter",
text: "Two-Factor Authentication - Enter Code",
description: "Enter a two-factor authentication code.",
test: "two-way-auth-enter",
href: '/two-way-auth-enter',
text: 'Two-Factor Authentication - Enter Code',
description: 'Enter a two-factor authentication code.',
test: 'two-way-auth-enter',
},
{
href: "/progress-bar",
text: "Progress Bar",
description: "Progress bar with a percentage.",
test: "progress-bar",
href: '/progress-bar',
text: 'Progress Bar',
description: 'Progress bar with a percentage.',
test: 'progress-bar',
},
{
href: "/confirm-button",
text: "Confirm Button",
description: "Hold down the button to confirm the action.",
test: "confirm-button",
href: '/confirm-button',
text: 'Confirm Button',
description: 'Hold down the button to confirm the action.',
test: 'confirm-button',
},
{
href: "/calculate",
text: "Calculate",
description: "Calculate a mathematical expression from an API route.",
test: "calculate",
href: '/calculate',
text: 'Calculate',
description: 'Calculate a mathematical expression from an API route.',
test: 'calculate',
},
]
</script>
Expand All @@ -85,8 +85,8 @@
class="font-bold hover:underline"
{href}
data-test={test}
target={external ? "_blank" : null}
rel={external ? "noreferrer" : null}
target={external ? '_blank' : null}
rel={external ? 'noreferrer' : null}
>
{text}
</a>
Expand Down
6 changes: 3 additions & 3 deletions apps/svelte/src/routes/current-time/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts">
import { onDestroy } from "svelte"
import { getCurrentTime } from "@repo/lib/utils/date"
import { onDestroy } from 'svelte'
import { getCurrentTime } from '@repo/lib/utils/date'
let { hours, minutes, meridiem } = getCurrentTime()
let { hours, minutes, meridiem } = $state(getCurrentTime())
const interval = setInterval(() => {
const newTime = getCurrentTime()
Expand Down
6 changes: 5 additions & 1 deletion apps/svelte/src/routes/hooks/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
import DebounceSection from './DebounceSection.svelte'
import RandomStringSection from './RandomStringSection.svelte'
export let data: PageData
interface Props {
data: PageData
}
let { data }: Props = $props()
</script>

<svelte:head>
Expand Down
12 changes: 7 additions & 5 deletions apps/svelte/src/routes/hooks/ClickOutsideSection.svelte
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<script lang="ts">
let isWithin = false
import { stopPropagation } from 'svelte/legacy'
let isWithin = $state(false)
function onGlobalClick() {
isWithin = false;
isWithin = false
}
</script>

<svelte:document on:click={onGlobalClick} />
<svelte:document onclick={onGlobalClick} />

<article>
<h2>Click Outside</h2>
<button class="btn-primary" on:click|stopPropagation={() => isWithin = true}>
<button class="btn-primary" onclick={stopPropagation(() => (isWithin = true))}>
{isWithin ? 'Within' : 'Outside'}
</button>
</article>
</article>
20 changes: 6 additions & 14 deletions apps/svelte/src/routes/hooks/CounterSection.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { createCounter } from "./counter.svelte"
import { createCounter } from './counter.svelte'
let counter = createCounter()
</script>
Expand All @@ -8,17 +8,9 @@
<h2>Counter</h2>
<p>Count: {counter.count}</p>
<div class="flex">
<button class="btn-secondary" on:click={counter.increment}>
Increment
</button>
<button class="btn-secondary" on:click={counter.decrement}>
Decrement
</button>
<button class="btn-secondary" on:click={counter.reset}>
Reset
</button>
<button class="btn-secondary" on:click={() => counter.set(5)}>
Set 5
</button>
<button class="btn-secondary" onclick={counter.increment}>Increment</button>
<button class="btn-secondary" onclick={counter.decrement}>Decrement</button>
<button class="btn-secondary" onclick={counter.reset}>Reset</button>
<button class="btn-secondary" onclick={() => counter.set(5)}>Set 5</button>
</div>
</article>
</article>
17 changes: 6 additions & 11 deletions apps/svelte/src/routes/hooks/DebounceSection.svelte
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
<script lang="ts">
let value = ''
let debounced = ''
let timer: ReturnType<typeof setTimeout>
let value = $state('')
let debounced = $state('')
let timer: ReturnType<typeof setTimeout>
const debounce = (func: () => void, delay = 300) => {
clearTimeout(timer);
clearTimeout(timer)
timer = setTimeout(func, delay)
}
</script>

<article>
<h2>Debounce</h2>
<input
class="input"
type="text"
bind:value={value}
on:keyup={() => debounce(() => debounced = value)}
/>
<input class="input" type="text" bind:value onkeyup={() => debounce(() => (debounced = value))} />
<p>Value: {value}</p>
<p>Debounced: {debounced}</p>
</article>
</article>
14 changes: 9 additions & 5 deletions apps/svelte/src/routes/hooks/RandomStringSection.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<script lang="ts">
import { randomString } from "./randomString"
import { randomString } from './randomString'
export let initValue: string
interface Props {
initValue: string
}
let {value: random, generate} = randomString(initValue)
let { initValue }: Props = $props()
let { value: random, generate } = randomString(initValue)
</script>

<article>
<h2>Random String</h2>
<button on:click={generate}>{$random}</button>
</article>
<button onclick={generate}>{$random}</button>
</article>
Loading

0 comments on commit 8099f4d

Please sign in to comment.