-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
149 lines (132 loc) · 4.15 KB
/
App.tsx
File metadata and controls
149 lines (132 loc) · 4.15 KB
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
import React, { useEffect } from 'react';
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import Navbar from './Navbar';
import Hero from './Hero';
import About from './About';
import Projects from './Projects';
import AllProjects from './AllProjects';
import Contact from './Contact';
import Footer from './Footer';
const App: React.FC = () => {
useEffect(() => {
// Add scroll effect to navbar
const handleScroll = () => {
const navbar = document.querySelector('.navbar') as HTMLElement;
if (navbar) {
if (window.scrollY > 50) {
navbar.style.backgroundColor = 'rgba(255, 255, 255, 0.95)';
navbar.style.backdropFilter = 'blur(10px)';
navbar.style.boxShadow = '0 2px 20px rgba(0, 0, 0, 0.1)';
} else {
navbar.style.backgroundColor = 'rgba(255, 255, 255, 0.95)';
navbar.style.backdropFilter = 'blur(10px)';
navbar.style.boxShadow = '0 2px 20px rgba(0, 0, 0, 0.1)';
}
}
};
window.addEventListener('scroll', handleScroll);
// Add smooth scrolling to anchor links
document.querySelectorAll('a[href^="#"]').forEach((anchor: Element) => {
anchor.addEventListener('click', (e: Event) => {
e.preventDefault();
const targetId = (anchor as HTMLAnchorElement).getAttribute('href')?.substring(1);
if (targetId) {
const element = document.getElementById(targetId);
if (element) {
const offsetTop = element.offsetTop - 80;
window.scrollTo({
top: offsetTop,
behavior: 'smooth'
});
}
}
});
});
// Add animation on scroll
const observerOptions: IntersectionObserverInit = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries: IntersectionObserverEntry[]) => {
entries.forEach((entry: IntersectionObserverEntry) => {
if (entry.isIntersecting) {
entry.target.classList.add('animate-in');
}
});
}, observerOptions);
document.querySelectorAll('.project-card, .contact-card, .about-content').forEach(el => {
observer.observe(el);
});
// Add CSS for animations
const style = document.createElement('style');
style.textContent = `
.project-card, .contact-card, .about-content {
opacity: 0;
transform: translateY(30px);
transition: opacity 0.6s ease, transform 0.6s ease;
}
.project-card.animate-in, .contact-card.animate-in, .about-content.animate-in {
opacity: 1;
transform: translateY(0);
}
.navbar-menu.active {
display: flex;
flex-direction: column;
position: absolute;
top: 100%;
left: 0;
right: 0;
background: white;
padding: 20px;
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}
@media (min-width: 769px) {
.navbar-menu.active {
display: flex !important;
flex-direction: row !important;
position: static !important;
background: transparent !important;
padding: 0 !important;
box-shadow: none !important;
}
}
`;
document.head.appendChild(style);
// Add responsive navbar menu styles
const responsiveStyle = document.createElement('style');
responsiveStyle.textContent = `
@media (max-width: 768px) {
.navbar-menu {
display: none;
}
.navbar-menu.active {
display: flex;
}
}
`;
document.head.appendChild(responsiveStyle);
return () => {
window.removeEventListener('scroll', handleScroll);
};
}, []);
const Home = () => (
<>
<Navbar />
<Hero />
<About />
<AllProjects />
<Contact />
<Footer />
</>
);
const basename = import.meta.env.PROD ? '/Stan-Radu-Gabriel/' : '/';
return (
<BrowserRouter basename={basename}>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/projects" element={<><Navbar /><Projects /><Footer /></>} />
</Routes>
</BrowserRouter>
);
};
export default App;