-
Notifications
You must be signed in to change notification settings - Fork 0
/
+page.svelte
154 lines (137 loc) · 3.61 KB
/
+page.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<script lang="ts">
import sectionrefs from '$lib/sections/refs';
import MeSection from '$lib/sections/me.svelte';
import EducationSection from '$lib/sections/education.svelte';
import ExperienceSection from '$lib/sections/experience.svelte';
import SkillsSection from '$lib/sections/skills.svelte';
import ProjectsSection from '$lib/sections/projects.svelte';
import ContactSection from '$lib/sections/contact.svelte';
interface SectionData {
id: string;
name: string;
component: any;
}
const sections: SectionData[] = [
{
id: sectionrefs.me,
name: 'me',
component: MeSection
},
{
id: sectionrefs.education,
name: 'education',
component: EducationSection
},
{
id: sectionrefs.experience,
name: 'experience',
component: ExperienceSection
},
{
id: sectionrefs.skills,
name: 'skills',
component: SkillsSection
},
{
id: sectionrefs.projects,
name: 'projects',
component: ProjectsSection
},
{
id: sectionrefs.contact,
name: 'contact',
component: ContactSection
}
];
let activeSectionBools: boolean[] = [false, false, false, false, false, false];
import Background from '$lib/components/background.svelte';
import ScrollToTopButton from '$lib/components/scrollToTopButton.svelte';
import Navbar, { NavbarItem, scrollTop, scrollRef, scrollTo } from 'svelte-navbar';
// import { scrollTop, scrollTo, scrollRef } from 'svelte-scrolling';
import { goto } from '$app/navigation';
import LogoWithBlob from '$lib/components/iconwithblob.svelte';
const navBarScroll = {
startY: 100,
endY: 500,
get length() {
return this.endY - this.startY;
},
progress: function (scroll: number) {
return Math.min(Math.max(0, scrollY - this.startY) / this.length, 1);
}
};
let scrollY = 0;
let navBarSizeInPx = 60;
function routeToPage(route: string, replaceState: boolean) {
goto(`/${route}`, { replaceState });
}
let meSectionActive = false;
import { _ } from 'svelte-i18n';
</script>
<Background offsetTop={scrollY / 30} />
<div
id="body"
style="
--scroll-prog: {navBarScroll.progress(scrollY)};
margin-left: {navBarScroll.progress(scrollY) * navBarSizeInPx * 0.78}px;
width: calc(100% - {navBarScroll.progress(scrollY) * navBarSizeInPx}px);"
>
<div id="logo">
<LogoWithBlob animationduration={5000} />
</div>
{#each sections as section, i}
<section id={section.id}>
<svelte:component this={section.component} />
</section>
{/each}
</div>
<Navbar
scrollProgress={navBarScroll.progress(scrollY)}
rowSizeInPx={navBarSizeInPx}
color="#a7c347"
>
<NavbarItem on:click={(e) => scrollTop()}>Home</NavbarItem>
{#each sections as section, i}
<div class="smooth" class:activated={activeSectionBools[i]}>
<NavbarItem bind:isCurrentlyActive={activeSectionBools[i]} scrollTo={section.id}>
{$_(section.name + '.title')}</NavbarItem
>
</div>
{/each}
</Navbar>
<ScrollToTopButton />
<svelte:window bind:scrollY />
<style lang="scss">
$logo-height: min(70vh, 70vw);
:global(body, html) {
color: $on-surface;
}
.activated {
filter: invert(1);
& * {
//todo: fix this is not workinf
color: $on-surface !important;
text-decoration: underline solid $on-surface 2px !important;
}
}
.smooth {
transition: scale 400ms, color 400ms, filter 400ms;
}
#body {
// overflow: hidden;
}
#logo {
height: $logo-height;
aspect-ratio: 1;
margin: 0 auto;
margin-top: 100px;
transform: rotateZ(calc(var(--scroll-prog) * 90deg));
& + * {
margin-top: calc(100vh - $logo-height);
position: relative;
z-index: 1;
transform-origin: 50% calc(-2 * $logo-height);
rotate: calc((var(--scroll-prog) - 1) * 90deg);
}
}
</style>