@@ -2,7 +2,8 @@ import { useEffect, useState } from "react";
22import { useLocation , useNavigate } from "react-router-dom" ;
33import "./LandingPage.css" ;
44import LandingPageLink from "./LandingPageLink" ;
5- import { animated } from "react-spring" ;
5+ import { animated , useTransition } from "react-spring" ;
6+ import HomeView from "./HomeView" ;
67
78const 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} ;
0 commit comments