From da885bec57a4345ceb03458751edc53ccf667a95 Mon Sep 17 00:00:00 2001 From: Sangelo Date: Tue, 12 Mar 2024 16:26:21 +0100 Subject: [PATCH] Initial Project Refactoring and Cleanup --- src/{routes => lib/components}/About.svelte | 31 +------ src/{routes => lib/components}/Home.svelte | 32 +------ src/{routes => lib/components}/Modal.svelte | 0 src/{routes => lib/components}/Navbar.svelte | 0 .../components}/Projects.svelte | 47 +++------- src/{routes => lib/components}/Socials.svelte | 89 +++---------------- src/lib/emojis.ts | 37 ++++++++ src/lib/index.ts | 29 +++++- src/{routes => lib}/modals/dashinit.svelte | 4 +- .../modals/explorecraft.svelte | 4 +- src/{routes => lib}/modals/lunivity.svelte | 4 +- src/{routes => lib}/modals/more.svelte | 14 +-- src/{routes => lib}/modals/sangefault.svelte | 4 +- .../modals/sangelospace.svelte | 4 +- .../modals/utilityclient.svelte | 4 +- src/routes/+layout.svelte | 2 +- src/routes/+page.svelte | 10 +-- svelte.config.js | 15 +++- 18 files changed, 133 insertions(+), 197 deletions(-) rename src/{routes => lib/components}/About.svelte (81%) rename src/{routes => lib/components}/Home.svelte (82%) rename src/{routes => lib/components}/Modal.svelte (100%) rename src/{routes => lib/components}/Navbar.svelte (100%) rename src/{routes => lib/components}/Projects.svelte (76%) rename src/{routes => lib/components}/Socials.svelte (86%) create mode 100644 src/lib/emojis.ts rename src/{routes => lib}/modals/dashinit.svelte (91%) rename src/{routes => lib}/modals/explorecraft.svelte (92%) rename src/{routes => lib}/modals/lunivity.svelte (91%) rename src/{routes => lib}/modals/more.svelte (93%) rename src/{routes => lib}/modals/sangefault.svelte (92%) rename src/{routes => lib}/modals/sangelospace.svelte (92%) rename src/{routes => lib}/modals/utilityclient.svelte (92%) diff --git a/src/routes/About.svelte b/src/lib/components/About.svelte similarity index 81% rename from src/routes/About.svelte rename to src/lib/components/About.svelte index bbb46b0..8a819e9 100644 --- a/src/routes/About.svelte +++ b/src/lib/components/About.svelte @@ -1,30 +1,5 @@
@@ -38,7 +13,7 @@ fill="none" xmlns="http://www.w3.org/2000/svg" tabindex="0" - on:click={redirectToHome} + on:click={() => smoothScrollTo('home')} on:keydown={handleKeydown} > \ No newline at end of file diff --git a/src/routes/Home.svelte b/src/lib/components/Home.svelte similarity index 82% rename from src/routes/Home.svelte rename to src/lib/components/Home.svelte index 14c4149..a10547c 100644 --- a/src/routes/Home.svelte +++ b/src/lib/components/Home.svelte @@ -1,32 +1,6 @@
@@ -80,6 +54,6 @@
\ No newline at end of file diff --git a/src/routes/Modal.svelte b/src/lib/components/Modal.svelte similarity index 100% rename from src/routes/Modal.svelte rename to src/lib/components/Modal.svelte diff --git a/src/routes/Navbar.svelte b/src/lib/components/Navbar.svelte similarity index 100% rename from src/routes/Navbar.svelte rename to src/lib/components/Navbar.svelte diff --git a/src/routes/Projects.svelte b/src/lib/components/Projects.svelte similarity index 76% rename from src/routes/Projects.svelte rename to src/lib/components/Projects.svelte index a58b9a7..eabe0f3 100644 --- a/src/routes/Projects.svelte +++ b/src/lib/components/Projects.svelte @@ -1,15 +1,17 @@
@@ -56,7 +37,7 @@ fill="none" xmlns="http://www.w3.org/2000/svg" tabindex="0" - on:click={redirectToHome} + on:click={() => smoothScrollTo('home')} on:keydown={handleKeydown} > diff --git a/src/routes/Socials.svelte b/src/lib/components/Socials.svelte similarity index 86% rename from src/routes/Socials.svelte rename to src/lib/components/Socials.svelte index cb96104..3d5f74d 100644 --- a/src/routes/Socials.svelte +++ b/src/lib/components/Socials.svelte @@ -1,7 +1,8 @@
@@ -299,8 +234,8 @@ fill="none" xmlns="http://www.w3.org/2000/svg" tabindex="0" - on:click={redirectToHome} - on:keydown={handleKeydownHome} + on:click={() => smoothScrollTo('home')} + on:keydown={handleKeydown} > diff --git a/src/lib/emojis.ts b/src/lib/emojis.ts new file mode 100644 index 0000000..3e6b14e --- /dev/null +++ b/src/lib/emojis.ts @@ -0,0 +1,37 @@ +// Initialisations + +export const emojis = [ + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ❤️', + 'with ☕️', + 'with 🍵', + 'with 🍪', + 'with 💤', + 'on a 💻', + 'in 🏫', + 'at 🏠', + 'with passion', + 'with VSCodium', + 'with StackOverflow', + 'with Svelte' +]; diff --git a/src/lib/index.ts b/src/lib/index.ts index 856f2b6..4905f7d 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -1 +1,28 @@ -// place files you want to import through the `$lib` alias in this folder. +// index.ts + +import { goto } from '$app/navigation'; + +export function smoothScrollTo(elementId: string) { + const element = document.getElementById(elementId); + if (element) { + element.scrollIntoView({ + behavior: 'smooth' + }); + } +} + +// export function redirectToHome() { +// // goto('/'); +// smoothScrollTo('home'); +// } + +export function handleKeydown(event: KeyboardEvent) { + // Trigger redirection on Enter key or Space bar + if (event.key === 'Enter' || event.key === ' ') { + smoothScrollTo('home'); + } +} + +export function openWebsite(url: string) { + goto(url); +} diff --git a/src/routes/modals/dashinit.svelte b/src/lib/modals/dashinit.svelte similarity index 91% rename from src/routes/modals/dashinit.svelte rename to src/lib/modals/dashinit.svelte index e0e8cae..9c454ba 100644 --- a/src/routes/modals/dashinit.svelte +++ b/src/lib/modals/dashinit.svelte @@ -37,6 +37,6 @@ diff --git a/src/routes/modals/explorecraft.svelte b/src/lib/modals/explorecraft.svelte similarity index 92% rename from src/routes/modals/explorecraft.svelte rename to src/lib/modals/explorecraft.svelte index d13f66c..16915b2 100644 --- a/src/routes/modals/explorecraft.svelte +++ b/src/lib/modals/explorecraft.svelte @@ -37,6 +37,6 @@ diff --git a/src/routes/modals/lunivity.svelte b/src/lib/modals/lunivity.svelte similarity index 91% rename from src/routes/modals/lunivity.svelte rename to src/lib/modals/lunivity.svelte index 1188d93..565213d 100644 --- a/src/routes/modals/lunivity.svelte +++ b/src/lib/modals/lunivity.svelte @@ -37,6 +37,6 @@ diff --git a/src/routes/modals/more.svelte b/src/lib/modals/more.svelte similarity index 93% rename from src/routes/modals/more.svelte rename to src/lib/modals/more.svelte index 59c9457..b4208a5 100644 --- a/src/routes/modals/more.svelte +++ b/src/lib/modals/more.svelte @@ -1,11 +1,5 @@ @@ -15,5 +15,5 @@
\ No newline at end of file diff --git a/svelte.config.js b/svelte.config.js index e6dc5e1..554a487 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -8,6 +8,13 @@ const config = { // for more information about preprocessors preprocess: [vitePreprocess({})], + onwarn: (warning, handler) => { + if (warning.code === 'css-unused-selector') { + return; + } + handler(warning); + }, + kit: { // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. // If your environment is not supported or you settled on a specific environment, switch out the adapter. @@ -20,7 +27,13 @@ const config = { fallback: undefined, precompress: false, strict: true - }) + }), + + alias: { + $routes: "src/routes", + $components: "src/components", + $styles: "src/styles" + }, } };