From ad74bc0f85519d47ab9c14c04e8dc88fa6c4e7b5 Mon Sep 17 00:00:00 2001 From: Bradley Shellnut Date: Wed, 2 Oct 2024 16:01:38 -0700 Subject: [PATCH] Moving to TS tailwindcss, move to Sonner toast. --- components.json | 2 +- docker-compose.yaml | 15 +-- package.json | 3 +- pnpm-lock.yaml | 42 +++---- src/app.d.ts | 17 +-- src/app.html | 35 +----- src/lib/components/Header.svelte | 38 ++---- src/lib/components/ui/sonner/index.ts | 1 + src/lib/components/ui/sonner/sonner.svelte | 20 ++++ src/lib/utils/superforms.ts | 20 ++++ .../(app)/(protected)/admin/+layout.server.ts | 1 + .../(app)/(protected)/admin/+layout.svelte | 20 +--- src/routes/(app)/+layout.svelte | 25 +--- src/routes/(auth)/login/+page.server.ts | 89 +------------- src/routes/+layout.svelte | 113 +++++++++--------- tailwind.config.js | 65 ---------- tailwind.config.ts | 69 +++++++++++ 17 files changed, 217 insertions(+), 358 deletions(-) create mode 100644 src/lib/components/ui/sonner/index.ts create mode 100644 src/lib/components/ui/sonner/sonner.svelte create mode 100644 src/lib/utils/superforms.ts delete mode 100644 tailwind.config.js create mode 100644 tailwind.config.ts diff --git a/components.json b/components.json index 8d5d8e6..6d70d7d 100644 --- a/components.json +++ b/components.json @@ -2,7 +2,7 @@ "$schema": "https://shadcn-svelte.com/schema.json", "style": "default", "tailwind": { - "config": "tailwind.config.js", + "config": "tailwind.config.ts", "css": "src/lib/styles/app.pcss", "baseColor": "slate" }, diff --git a/docker-compose.yaml b/docker-compose.yaml index 82b9871..b16dfd0 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,6 +1,8 @@ +version: '3.8' services: postgres: image: postgres:latest + container_name: boredgame_postgres environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres @@ -11,6 +13,7 @@ services: - postgres_data:/var/lib/postgresql/data redis: image: redis:latest + container_name: boredgame_redis ports: - '6379:6379' volumes: @@ -23,18 +26,6 @@ services: # - '3592:3592' # volumes: # - ./policies:/policies -# caddy: -# image: caddy:latest -# restart: unless-stopped -# ports: -# - "80:80" -# - "443:443" -# - "443:443/udp" -# volumes: -# - ./Caddyfile:/etc/caddy/Caddyfile -# - ./site:/srv -# - caddy_data:/data -# - caddy_config:/config volumes: postgres_data: redis_data: diff --git a/package.json b/package.json index a4e9e9a..dcd652b 100644 --- a/package.json +++ b/package.json @@ -116,6 +116,7 @@ "just-capitalize": "^3.2.0", "just-kebab-case": "^4.2.0", "loader": "^2.1.1", + "mode-watcher": "^0.4.1", "open-props": "^1.7.6", "oslo": "^1.2.1", "pg": "^8.13.0", @@ -124,8 +125,8 @@ "radix-svelte": "^0.9.0", "rate-limit-redis": "^4.2.0", "reflect-metadata": "^0.2.2", - "svelte-french-toast": "^1.2.0", "svelte-lazy-loader": "^1.0.0", + "svelte-sonner": "^0.3.28", "tailwind-merge": "^2.5.2", "tailwind-variants": "^0.2.1", "tailwindcss-animate": "^1.0.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index acfa118..ad331de 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -134,6 +134,9 @@ importers: loader: specifier: ^2.1.1 version: 2.1.1 + mode-watcher: + specifier: ^0.4.1 + version: 0.4.1(svelte@5.0.0-next.175) open-props: specifier: ^1.7.6 version: 1.7.6 @@ -158,12 +161,12 @@ importers: reflect-metadata: specifier: ^0.2.2 version: 0.2.2 - svelte-french-toast: - specifier: ^1.2.0 - version: 1.2.0(svelte@5.0.0-next.175) svelte-lazy-loader: specifier: ^1.0.0 version: 1.0.0 + svelte-sonner: + specifier: ^0.3.28 + version: 0.3.28(svelte@5.0.0-next.175) tailwind-merge: specifier: ^2.5.2 version: 2.5.2 @@ -3454,6 +3457,11 @@ packages: mlly@1.7.1: resolution: {integrity: sha512-rrVRZRELyQzrIUAVMHxP97kv+G786pHmOKzuFII8zDYahFBS7qnHh2AlYSl1GAHhaMPCz6/oHjVMcfFYgFYHgA==} + mode-watcher@0.4.1: + resolution: {integrity: sha512-bNC+1NXmwEFZtziCdZSgP7HFQTpqJPcQn9GwwJQGSf6SBF3neEPYV1uRwkYuAQwbsvsXIYtzaqgedDzJ7D1mhg==} + peerDependencies: + svelte: ^4.0.0 || ^5.0.0-next.1 + mri@1.2.0: resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} engines: {node: '>=4'} @@ -4369,11 +4377,6 @@ packages: svelte: optional: true - svelte-french-toast@1.2.0: - resolution: {integrity: sha512-5PW+6RFX3xQPbR44CngYAP1Sd9oCq9P2FOox4FZffzJuZI2mHOB7q5gJBVnOiLF5y3moVGZ7u2bYt7+yPAgcEQ==} - peerDependencies: - svelte: ^3.57.0 || ^4.0.0 - svelte-headless-table@0.18.2: resolution: {integrity: sha512-dnDTaXW5CNzRUjHVbc/Hb0Zv80zU4VcIUnAja6OuZriXvim1AqcWYQCHPRzBGwqj1m3YEHHNvspSzY0o5HzA0A==} peerDependencies: @@ -4480,16 +4483,16 @@ packages: resolution: {integrity: sha512-DIFm0kSNscVxtBmKkBiygAHB5otoqN1aVmJ3t57jZhJfCB7Np/lUSoTtSrvPFjmlBbMeOsb1VQ06cut1+rBYOg==} engines: {node: '>=16'} + svelte-sonner@0.3.28: + resolution: {integrity: sha512-K3AmlySeFifF/cKgsYNv5uXqMVNln0NBAacOYgmkQStLa/UoU0LhfAACU6Gr+YYC8bOCHdVmFNoKuDbMEsppJg==} + peerDependencies: + svelte: ^3.0.0 || ^4.0.0 || ^5.0.0-next.1 + svelte-subscribe@2.0.1: resolution: {integrity: sha512-eKXIjLxB4C7eQWPqKEdxcGfNXm2g/qJ67zmEZK/GigCZMfrTR3m7DPY93R6MX+5uoqM1FRYxl8LZ1oy4URWi2A==} peerDependencies: svelte: ^4.0.0 - svelte-writable-derived@3.1.1: - resolution: {integrity: sha512-w4LR6/bYZEuCs7SGr+M54oipk/UQKtiMadyOhW0PTwAtJ/Ai12QS77sLngEcfBx2q4H8ZBQucc9ktSA5sUGZWw==} - peerDependencies: - svelte: ^3.2.1 || ^4.0.0-next.1 || ^5.0.0-next.94 - svelte@4.2.19: resolution: {integrity: sha512-IY1rnGr6izd10B0A8LqsBfmlT5OILVuZ7XsI0vdGPEvuonFV7NYEUK4dAkm9Zg2q0Um92kYjTpS1CAP3Nh/KWw==} engines: {node: '>=16'} @@ -7753,6 +7756,10 @@ snapshots: pkg-types: 1.2.0 ufo: 1.5.4 + mode-watcher@0.4.1(svelte@5.0.0-next.175): + dependencies: + svelte: 5.0.0-next.175 + mri@1.2.0: {} mrmime@2.0.0: {} @@ -8719,11 +8726,6 @@ snapshots: optionalDependencies: svelte: 5.0.0-next.175 - svelte-french-toast@1.2.0(svelte@5.0.0-next.175): - dependencies: - svelte: 5.0.0-next.175 - svelte-writable-derived: 3.1.1(svelte@5.0.0-next.175) - svelte-headless-table@0.18.2(svelte@5.0.0-next.175): dependencies: svelte: 5.0.0-next.175 @@ -8781,11 +8783,11 @@ snapshots: svelte: 4.2.19 tslib: 2.7.0 - svelte-subscribe@2.0.1(svelte@5.0.0-next.175): + svelte-sonner@0.3.28(svelte@5.0.0-next.175): dependencies: svelte: 5.0.0-next.175 - svelte-writable-derived@3.1.1(svelte@5.0.0-next.175): + svelte-subscribe@2.0.1(svelte@5.0.0-next.175): dependencies: svelte: 5.0.0-next.175 diff --git a/src/app.d.ts b/src/app.d.ts index 6ab483d..609d7c7 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -21,17 +21,12 @@ declare global { parseApiResponse: typeof parseApiResponse; getAuthedUser: () => Promise | null>; getAuthedUserOrThrow: () => Promise>; - auth: import('lucia').AuthRequest; - user: import('lucia').User | null; - session: import('lucia').Session | null; - startTimer: number; - ip: string; - country: string; - error: string; - errorId: string; - errorStackTrace: string; - message: unknown; - track: unknown; + } + namespace Superforms { + type Message = { + type: 'error' | 'success' | 'info', + text: string + } } interface Error { code?: string; diff --git a/src/app.html b/src/app.html index 936b6ea..ad66b45 100644 --- a/src/app.html +++ b/src/app.html @@ -6,40 +6,11 @@ - + %sveltekit.head% - -
%sveltekit.body%
+ +
%sveltekit.body%
diff --git a/src/lib/components/Header.svelte b/src/lib/components/Header.svelte index 4b3a06b..d0e912c 100644 --- a/src/lib/components/Header.svelte +++ b/src/lib/components/Header.svelte @@ -1,15 +1,14 @@
@@ -63,26 +62,7 @@ let avatar: string = $derived(user?.username?.slice(0, 1).toUpperCase() || ':)') -
{ - return async ({ result }) => { - console.log(result); - if (result.type === 'success' || result.type === 'redirect') { - toast.success('Logged Out'); - } else if (result.type === 'error') { - console.log(result); - toast.error(`Error: ${result.error.message}`); - } else { - toast.error(`Something went wrong.`); - console.log(result); - } - await invalidateAll(); - await applyAction(result); - }; - }} - action="/logout" - method="POST" - > +