Skip to content

Commit 2f388a3

Browse files
authored
Merge pull request #1 from JS-GitRepo/feature/pageTransitions
Placing commit before making major page transition change to LandingP…
2 parents 129708f + 8140613 commit 2f388a3

File tree

6 files changed

+94
-79
lines changed

6 files changed

+94
-79
lines changed

src/App.css

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,3 @@
11
.App {
22
text-align: center;
33
}
4-
5-
.App-logo {
6-
height: 40vmin;
7-
pointer-events: none;
8-
}
9-
10-
@media (prefers-reduced-motion: no-preference) {
11-
.App-logo {
12-
animation: App-logo-spin infinite 20s linear;
13-
}
14-
}
15-
16-
.App-header {
17-
background-color: #282c34;
18-
min-height: 100vh;
19-
display: flex;
20-
flex-direction: column;
21-
align-items: center;
22-
justify-content: center;
23-
font-size: calc(10px + 2vmin);
24-
color: white;
25-
}
26-
27-
.App-link {
28-
color: #61dafb;
29-
}
30-
31-
@keyframes App-logo-spin {
32-
from {
33-
transform: rotate(0deg);
34-
}
35-
to {
36-
transform: rotate(360deg);
37-
}
38-
}

src/App.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ function App() {
1010
<Routes>
1111
<Route path="/" element={<LandingPage />} />
1212
<Route path="/landing" element={<LandingPage />} />
13-
<Route path="/landing/:links" element={<LandingPage />} />
14-
<Route path="/home" element={<HomeView />} />
15-
<Route path="/home/:location/:content" element={<HomeView />} />
13+
<Route path="/landing/:location" element={<LandingPage />} />
14+
<Route path="/landing/:location/:content" element={<LandingPage />} />
15+
<Route path="/home" element={<LandingPage />} />
16+
<Route path="/home/:location/:content" element={<LandingPage />} />
1617
</Routes>
1718
</Router>
1819
</div>

src/components/HomeView.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.HomeView {
2+
position: absolute;
23
display: flex;
34
flex-direction: column;
45
justify-content: center;

src/components/LandingPage.css

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
box-sizing: border-box;
1515
height: 100vh;
1616
width: 100vw;
17-
background-image: url("/src/img/pixelBGWide.png");
18-
background-position: center;
19-
background-size: cover;
2017
/* font-family: "VT323", monospace; */
2118
font-family: "munro";
2219
font-weight: 400;
@@ -36,8 +33,11 @@
3633
align-items: center;
3734
justify-content: center;
3835
box-sizing: border-box;
36+
margin-bottom: 0%;
3937
width: 100%;
40-
margin-bottom: 50px;
38+
background-image: url("/src/img/pixelBGWide.png");
39+
background-origin: content-box;
40+
background-size: auto 100vh;
4141
}
4242

4343
.LandingPage .link-container {
@@ -48,6 +48,10 @@
4848
box-sizing: border-box;
4949
/* margin-top: 80px; */
5050
width: 100%;
51+
background-image: url("/src/img/pixelBGWide.png");
52+
background-origin: content-box;
53+
background-size: auto 100vh;
54+
background-position: 0% -100%;
5155
}
5256

5357
.LandingPage .lp-link h1,

src/components/LandingPage.tsx

Lines changed: 81 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { useEffect, useState } from "react";
22
import { useLocation, useNavigate } from "react-router-dom";
33
import "./LandingPage.css";
44
import LandingPageLink from "./LandingPageLink";
5-
import { animated } from "react-spring";
5+
import { animated, useTransition } from "react-spring";
6+
import HomeView from "./HomeView";
67

78
const LandingPage = () => {
89
// - - - - - STATES / FUNCTIONALITY - - - - -
@@ -15,19 +16,48 @@ const LandingPage = () => {
1516
const [link2Path, setLink2Path] = useState<string>("");
1617
const currentPath = useLocation().pathname;
1718
const navigate = useNavigate();
18-
// const transitionUp = useTransition(isActivePage, {
19-
// initial: {},
20-
// // from: { opacity: 1, transform: "translate(0,0)" },
21-
// // leave: { opacity: 1, transform: "translate(0,100%)" },
22-
// });
19+
const transDuration = 200;
20+
const transitionUp = useTransition(isActivePage, {
21+
initial: {
22+
opacity: 1,
23+
marginBottom: "0%",
24+
config: { duration: transDuration },
25+
},
26+
from: {
27+
opacity: 1,
28+
marginBottom: "0%",
29+
config: { duration: transDuration },
30+
},
31+
leave: {
32+
opacity: 0.5,
33+
marginBottom: "100%",
34+
config: { duration: transDuration },
35+
},
36+
});
37+
const transitionDown = useTransition(isActivePage, {
38+
initial: {
39+
opacity: 1,
40+
marginTop: "0%",
41+
config: { duration: transDuration },
42+
},
43+
from: { opacity: 1, marginTop: "0%", config: { duration: transDuration } },
44+
leave: {
45+
opacity: 0.5,
46+
marginTop: "100%",
47+
config: { duration: transDuration },
48+
},
49+
});
2350

2451
useEffect(() => {
2552
if (firstRender) {
2653
setFirstRender(false);
27-
} else {
54+
} else if (
55+
currentPath.endsWith("/gamedev") ||
56+
currentPath.endsWith("/webdev")
57+
) {
2858
setIsActivePage(false);
2959
}
30-
}, []);
60+
}, [currentPath]);
3161

3262
useEffect(() => {
3363
if (currentPath === "/") {
@@ -41,45 +71,59 @@ const LandingPage = () => {
4171
} else if (currentPath === "/landing/portfolio") {
4272
setCurrentDisplay("Portfolio");
4373
setLink1Text("Web Dev");
44-
setLink1Path("/home/portfolio/webdev");
74+
setLink1Path("/landing/portfolio/webdev");
4575
setLink2Text("Game Dev");
46-
setLink2Path("/home/portfolio/gamedev");
76+
setLink2Path("/landing/portfolio/gamedev");
4777
} else if (currentPath === "/landing/blog") {
4878
setCurrentDisplay("Blog");
4979
setLink1Text("Web Dev");
50-
setLink1Path("/home/blog/webdev");
80+
setLink1Path("/landing/blog/webdev");
5181
setLink2Text("Game Dev");
52-
setLink2Path("/home/blog/gamedev");
82+
setLink2Path("/landing/blog/gamedev");
83+
} else if (currentPath === "/home/:location/:content") {
84+
console.log("made it here");
5385
}
5486
}, [currentPath]);
5587

5688
return (
5789
<div className="LandingPage">
58-
<animated.div className={"header-container"}>
59-
<LandingPageLink
60-
currentDisplay={currentDisplay}
61-
linkText={currentDisplay}
62-
pathName={"/"}
63-
className={"lp-link"}
64-
isH1={true}
65-
/>
66-
</animated.div>
67-
<animated.div className="link-container">
68-
<LandingPageLink
69-
currentDisplay={currentDisplay}
70-
linkText={link1Text}
71-
pathName={link1Path}
72-
className={"lp-link"}
73-
isH1={false}
74-
/>
75-
<LandingPageLink
76-
currentDisplay={currentDisplay}
77-
linkText={link2Text}
78-
pathName={link2Path}
79-
className={"lp-link"}
80-
isH1={false}
81-
/>
82-
</animated.div>
90+
{transitionUp((style, item) =>
91+
item ? (
92+
<animated.div className={"header-container"} style={style}>
93+
<LandingPageLink
94+
currentDisplay={currentDisplay}
95+
linkText={currentDisplay}
96+
pathName={"/"}
97+
className={"lp-link"}
98+
isH1={true}
99+
/>
100+
</animated.div>
101+
) : (
102+
<HomeView />
103+
)
104+
)}
105+
{transitionDown((style, item) =>
106+
item ? (
107+
<animated.div className="link-container" style={style}>
108+
<LandingPageLink
109+
currentDisplay={currentDisplay}
110+
linkText={link1Text}
111+
pathName={link1Path}
112+
className={"lp-link"}
113+
isH1={false}
114+
/>
115+
<LandingPageLink
116+
currentDisplay={currentDisplay}
117+
linkText={link2Text}
118+
pathName={link2Path}
119+
className={"lp-link"}
120+
isH1={false}
121+
/>
122+
</animated.div>
123+
) : (
124+
""
125+
)
126+
)}
83127
</div>
84128
);
85129
};

src/img/pixelBGWide.png

-17.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)