From 55baf1b3e3262072ce068495347adccfc84bcd8f Mon Sep 17 00:00:00 2001 From: Harding <000894566@mohawkcollege.ca> Date: Wed, 26 Feb 2025 17:43:58 -0500 Subject: [PATCH 1/3] (POC) Changed Snap Scroll system to button navigation system --- src/app.css | 25 +-- src/lib/components/Contact.svelte | 9 +- src/lib/components/Header.svelte | 45 +++--- src/lib/components/Media.svelte | 35 +++-- src/lib/components/Projects.svelte | 69 +++++---- src/lib/components/TechStack.svelte | 41 +++-- .../components/navigation-items/Down.svelte | 10 ++ .../components/navigation-items/Left.svelte | 10 ++ .../components/navigation-items/Right.svelte | 10 ++ src/lib/components/navigation-items/Up.svelte | 10 ++ src/routes/+page.svelte | 142 +++++++++--------- 11 files changed, 229 insertions(+), 177 deletions(-) create mode 100644 src/lib/components/navigation-items/Down.svelte create mode 100644 src/lib/components/navigation-items/Left.svelte create mode 100644 src/lib/components/navigation-items/Right.svelte create mode 100644 src/lib/components/navigation-items/Up.svelte diff --git a/src/app.css b/src/app.css index 8abcca8..8b895d0 100644 --- a/src/app.css +++ b/src/app.css @@ -3,32 +3,11 @@ @import 'tailwindcss/utilities'; * { - overflow-x: hidden; + overflow: hidden !important; } *:not(a), *:not(button), *:not(input) { user-select: none; -} - -/* @font-face { - font-family: 'Nunita'; - src: url('$lib/assets/fonts/Nunito-VariableFont_wght.ttf'); -} - -@font-face { - font-family: 'Roboto'; - src: url('$lib/assets/fonts/Roboto-VariableFont_wdth,wght.ttf'); -} - -:root { - --theme-font-family-base: 'Roboto', serif; - --theme-font-family-heading: 'Roboto', serif; -} - -:root body[data-theme='modern'], -:root body[data-theme='gold-nouveau'] { - --theme-font-family-base: 'Nunita', serif; - --theme-font-family-heading: 'Nunita', serif; -} */ \ No newline at end of file +} \ No newline at end of file diff --git a/src/lib/components/Contact.svelte b/src/lib/components/Contact.svelte index 2945fbd..a9f35f4 100644 --- a/src/lib/components/Contact.svelte +++ b/src/lib/components/Contact.svelte @@ -1,9 +1,13 @@ -
+
+

Contact Us


@@ -34,4 +38,7 @@
+
+ +
\ No newline at end of file diff --git a/src/lib/components/Header.svelte b/src/lib/components/Header.svelte index e965d7f..b8e319e 100644 --- a/src/lib/components/Header.svelte +++ b/src/lib/components/Header.svelte @@ -1,9 +1,14 @@ - + + - -
-
- -
- {#if isAtTop} -
- -
- {/if} -
-
\ No newline at end of file + #header { + grid-template-areas: '. . .' + '. . .' + '. . .'; + } + \ No newline at end of file diff --git a/src/lib/components/Media.svelte b/src/lib/components/Media.svelte index 493d331..1cfdb4a 100644 --- a/src/lib/components/Media.svelte +++ b/src/lib/components/Media.svelte @@ -1,25 +1,32 @@ - -
-

Backwards Media

-

Upload and Share Media with your Friends

-
- - Try it out - - - - Learn more - - +
+
+
+

Backwards Media

+

Upload and Share Media with your Friends

+ +
+
+ +
-
\ No newline at end of file diff --git a/src/lib/components/navigation-items/Down.svelte b/src/lib/components/navigation-items/Down.svelte new file mode 100644 index 0000000..57323bf --- /dev/null +++ b/src/lib/components/navigation-items/Down.svelte @@ -0,0 +1,10 @@ + + +
+ +
\ No newline at end of file diff --git a/src/lib/components/navigation-items/Left.svelte b/src/lib/components/navigation-items/Left.svelte new file mode 100644 index 0000000..67b5a87 --- /dev/null +++ b/src/lib/components/navigation-items/Left.svelte @@ -0,0 +1,10 @@ + + +
+ +
\ No newline at end of file diff --git a/src/lib/components/navigation-items/Right.svelte b/src/lib/components/navigation-items/Right.svelte new file mode 100644 index 0000000..3262e4d --- /dev/null +++ b/src/lib/components/navigation-items/Right.svelte @@ -0,0 +1,10 @@ + + +
+ +
\ No newline at end of file diff --git a/src/lib/components/navigation-items/Up.svelte b/src/lib/components/navigation-items/Up.svelte new file mode 100644 index 0000000..f130151 --- /dev/null +++ b/src/lib/components/navigation-items/Up.svelte @@ -0,0 +1,10 @@ + + +
+ +
\ No newline at end of file diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index b0d1a15..6cd3640 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -6,93 +6,91 @@ import Contact from "$lib/components/Contact.svelte"; import TechStack from "$lib/components/TechStack.svelte"; import Projects from "$lib/components/Projects.svelte"; + import { tableMapperValues } from "@skeletonlabs/skeleton"; - /* IMPORTANT */ - // Anything added into the page directly will likely break the page's scrolling behaviour - // To properly add something to the main page, make it into a component and add it to the array. - // This array is in order of how they are to be displayed, modifying their positions will modify them in page. + function scrollToSection(section, smooth) { + section.scrollIntoView({ + behavior: smooth ? "smooth" : "instant", + block: "center", + }); + } - let slides = [ - Header, - Projects, - TechStack, - Contact, - // Media, + // by ID + let layout = [ + [null, "media", null], + ["contact", "header", "techstack"], + [null, "projects", null], ]; + let selectedId = "header"; - let currentSection = 0; + function getIndexPathOfSelected() { + for (let rowIndex = 0; rowIndex < layout.length; rowIndex++) { + const colIndex = layout[rowIndex].indexOf(selectedId); - // Update the current section based on scroll position - const handleScroll = () => { - const sections = document.querySelectorAll(".section"); - const scrollTop = document.querySelector(".scroll-container").scrollTop; - sections.forEach((section, index) => { - if (section.offsetTop <= scrollTop + window.innerHeight / 2) { - currentSection = index; + if (colIndex !== -1) { + return [rowIndex, colIndex]; } - }); - }; + } + return null; + } + + function evaluateArrays(input, equationArr) { + let output = []; + if (input.length !== equationArr.length) + return null; + for (let index = 0; index < input.length; index++) { + output.push(input[index] + equationArr[index]); + } + return output; + } + + function scrollInDirection(direction) { + const currentCoords = getIndexPathOfSelected(); + const newCoords = evaluateArrays(currentCoords, direction); + console.log(currentCoords) + console.log(newCoords) + const sectionId = layout[newCoords[0]][newCoords[1]]; + console.log(sectionId); + selectedId = sectionId; + scrollToSection(document.getElementById(sectionId), true); + } + + onMount(() => { + scrollToSection(document.getElementById("header")); + }); -
- {#each slides as content} -
- -
- {/each} -
- - -{#if currentSection > 0} -
- {#each slides.slice(1) as _, i} -
- {/each} -
-{/if} +
+
+ +
+ +
+ +
+ +
From 2b9bf20eb2a131e916581e8d3cb3b14f48fb962c Mon Sep 17 00:00:00 2001 From: Backwards Date: Thu, 27 Feb 2025 20:56:35 -0500 Subject: [PATCH 2/3] Multiple Changes --- package-lock.json | 8 +-- package.json | 2 +- src/lib/components/Hero.svelte | 10 +++- src/lib/components/TechStack.svelte | 20 +------ .../components/navigation-items/Down.svelte | 5 +- .../components/navigation-items/Left.svelte | 6 ++- .../components/navigation-items/Right.svelte | 5 +- src/lib/components/navigation-items/Up.svelte | 5 +- src/routes/+page.svelte | 52 +++++++++++++++++-- 9 files changed, 81 insertions(+), 32 deletions(-) diff --git a/package-lock.json b/package-lock.json index 06a6d6c..f5c6f9f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,7 @@ "@skeletonlabs/skeleton": "^2.10.4", "@skeletonlabs/tw-plugin": "^0.4.0", "@sveltejs/adapter-auto": "^3.0.0", - "@sveltejs/adapter-node": "^5.2.11", + "@sveltejs/adapter-node": "^5.2.12", "@sveltejs/kit": "^2.0.0", "@sveltejs/vite-plugin-svelte": "^4.0.4", "@tailwindcss/forms": "^0.5.10", @@ -1374,9 +1374,9 @@ } }, "node_modules/@sveltejs/adapter-node": { - "version": "5.2.11", - "resolved": "https://registry.npmjs.org/@sveltejs/adapter-node/-/adapter-node-5.2.11.tgz", - "integrity": "sha512-lR7/dfUaKFf3aI408KRDy/BVDYoqUws7zNOJz2Hl4JoshlTnMgdha3brXBRFXB+cWtYvJjjPhvmq3xqpbioi4w==", + "version": "5.2.12", + "resolved": "https://registry.npmjs.org/@sveltejs/adapter-node/-/adapter-node-5.2.12.tgz", + "integrity": "sha512-0bp4Yb3jKIEcZWVcJC/L1xXp9zzJS4hDwfb4VITAkfT4OVdkspSHsx7YhqJDbb2hgLl6R9Vs7VQR+fqIVOxPUQ==", "dev": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index f325819..aa154ae 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "@skeletonlabs/skeleton": "^2.10.4", "@skeletonlabs/tw-plugin": "^0.4.0", "@sveltejs/adapter-auto": "^3.0.0", - "@sveltejs/adapter-node": "^5.2.11", + "@sveltejs/adapter-node": "^5.2.12", "@sveltejs/kit": "^2.0.0", "@sveltejs/vite-plugin-svelte": "^4.0.4", "@tailwindcss/forms": "^0.5.10", diff --git a/src/lib/components/Hero.svelte b/src/lib/components/Hero.svelte index 1585cb9..21d5ea3 100644 --- a/src/lib/components/Hero.svelte +++ b/src/lib/components/Hero.svelte @@ -6,12 +6,18 @@ import MdiDiscord from '~icons/mdi/discord'; import MdiLinkedin from '~icons/mdi/linkedin'; import CibGitea from '~icons/cib/gitea'; + let personal = true;
-

Backwards Development

-

A Software Development and Distribution Company

+ {#if personal} +

Alexander Harding

+

Software and Application Developer

+ {:else} +

Backwards Development

+

A Software Development and Distribution Company

+ {/if}
diff --git a/src/lib/components/TechStack.svelte b/src/lib/components/TechStack.svelte index b877bc2..b5ee626 100644 --- a/src/lib/components/TechStack.svelte +++ b/src/lib/components/TechStack.svelte @@ -6,27 +6,11 @@ export let scrollInDirection; - - -
+
-
+

My Current Tech Stack

Subject to Change diff --git a/src/lib/components/navigation-items/Down.svelte b/src/lib/components/navigation-items/Down.svelte index 57323bf..ad3f7c3 100644 --- a/src/lib/components/navigation-items/Down.svelte +++ b/src/lib/components/navigation-items/Down.svelte @@ -4,7 +4,10 @@
-
\ No newline at end of file diff --git a/src/lib/components/navigation-items/Left.svelte b/src/lib/components/navigation-items/Left.svelte index 67b5a87..58fd0fc 100644 --- a/src/lib/components/navigation-items/Left.svelte +++ b/src/lib/components/navigation-items/Left.svelte @@ -1,10 +1,14 @@
-
\ No newline at end of file diff --git a/src/lib/components/navigation-items/Right.svelte b/src/lib/components/navigation-items/Right.svelte index 3262e4d..cc40462 100644 --- a/src/lib/components/navigation-items/Right.svelte +++ b/src/lib/components/navigation-items/Right.svelte @@ -4,7 +4,10 @@
-
\ No newline at end of file diff --git a/src/lib/components/navigation-items/Up.svelte b/src/lib/components/navigation-items/Up.svelte index f130151..6f25c53 100644 --- a/src/lib/components/navigation-items/Up.svelte +++ b/src/lib/components/navigation-items/Up.svelte @@ -4,7 +4,10 @@
-
\ No newline at end of file diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 6cd3640..48c706b 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -48,16 +48,62 @@ function scrollInDirection(direction) { const currentCoords = getIndexPathOfSelected(); const newCoords = evaluateArrays(currentCoords, direction); - console.log(currentCoords) - console.log(newCoords) + + const itemAtCoords = layout[newCoords[0]][newCoords[1]]; + if (itemAtCoords == null) + return; + const sectionId = layout[newCoords[0]][newCoords[1]]; - console.log(sectionId); selectedId = sectionId; scrollToSection(document.getElementById(sectionId), true); } + let keys = { + "up": [ + "ArrowUp", + "w" + ], + "down": [ + "ArrowDown", + "s" + ], + "left": [ + "ArrowLeft", + "a" + ], + "right": [ + "ArrowRight", + "d" + ] + }; + onMount(() => { scrollToSection(document.getElementById("header")); + + window.addEventListener("resize", e => { + e.preventDefault(); + }); + + document.addEventListener("keydown", e => { + const directionArr = Object.entries(keys).filter(([_, values]) => values.some(v => v == e.key)); + if (!directionArr || directionArr.length == 0) + return; + const direction = directionArr[0][0]; + switch (direction) { + case "up": + scrollInDirection([-1, 0]); + break; + case "down": + scrollInDirection([1, 0]); + break; + case "left": + scrollInDirection([0, -1]); + break; + case "right": + scrollInDirection([0, 1]); + break; + } + }); }); From c9fc0d5aaad0347b2e23c8feb43de50288543e1f Mon Sep 17 00:00:00 2001 From: Backwards Date: Fri, 28 Feb 2025 08:30:19 -0500 Subject: [PATCH 3/3] Fixed Zooming not centering on container --- src/routes/+page.svelte | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 48c706b..62cc333 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -81,7 +81,8 @@ scrollToSection(document.getElementById("header")); window.addEventListener("resize", e => { - e.preventDefault(); + console.log(selectedId) + scrollToSection(document.getElementById(selectedId)); }); document.addEventListener("keydown", e => {