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] (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} +
+
+ +
+ +
+ +
+ +