-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from TravelMemories/Frontend
Page navigation and basic log in/out
- Loading branch information
Showing
15 changed files
with
286 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from "react"; | ||
import { motion } from "framer-motion"; | ||
import { useUserContext } from "../../context/UserContext"; | ||
function LoginButton() { | ||
const { isLoggedIn, LogIn, LogOut } = useUserContext(); | ||
return ( | ||
<motion.button | ||
className="bg-action-400 whitespace-nowrap px-4 py-1 rounded-2xl tracking-tight text-background-50 shadow-md hover:bg-action-500 transition-colors" | ||
animate={{ scale: 1 }} | ||
whileHover={{ scale: 1.03 }} | ||
whileTap={{ scale: 1.01 }} | ||
onClick={() => { | ||
if (isLoggedIn) LogOut(); | ||
else LogIn(); | ||
}} | ||
> | ||
{isLoggedIn ? "Log out" : "Log in"} | ||
</motion.button> | ||
); | ||
} | ||
|
||
export default LoginButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from "react"; | ||
import { motion } from "framer-motion"; | ||
import { useUserContext } from "../../context/UserContext"; | ||
|
||
function RegisterButton() { | ||
const { isLoggedIn, LogIn, LogOut } = useUserContext(); | ||
return ( | ||
<motion.button | ||
className="bg-background-50 px-4 py-1 rounded-2xl tracking-tight text-primary-950 shadow-md hover:bg-background-100 transition-colors" | ||
animate={{ scale: 1 }} | ||
whileHover={{ scale: 1.03 }} | ||
whileTap={{ scale: 1.01 }} | ||
onClick={() => { | ||
if (isLoggedIn) LogOut(); | ||
else LogIn(); | ||
}} | ||
> | ||
Register | ||
</motion.button> | ||
); | ||
} | ||
|
||
export default RegisterButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React, { ReactNode, createContext, useContext, useState } from "react"; | ||
|
||
interface UserContextProviderProps { | ||
children: ReactNode; | ||
} | ||
interface UserContextProps { | ||
isLoggedIn: boolean; | ||
LogIn: () => void; | ||
LogOut: () => void; | ||
} | ||
const UserContext = createContext({} as UserContextProps); | ||
|
||
export function useUserContext() { | ||
return useContext(UserContext); | ||
} | ||
|
||
export function UserContextProvider({ children }: UserContextProviderProps) { | ||
const [isLoggedIn, setIsLoggedIn] = useState(false); | ||
|
||
const LogIn = () => { | ||
setIsLoggedIn(true); | ||
}; | ||
const LogOut = () => { | ||
setIsLoggedIn(false); | ||
}; | ||
return ( | ||
<UserContext.Provider value={{ isLoggedIn, LogIn, LogOut }}> | ||
{children} | ||
</UserContext.Provider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ | |
@tailwind utilities; | ||
|
||
body { | ||
@apply bg-primary-200 font-primary; | ||
@apply bg-primary-50 font-primary; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export interface UserData {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from "react"; | ||
|
||
function LoginPage() { | ||
return <div>LoginPage</div>; | ||
} | ||
|
||
export default LoginPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from "react"; | ||
|
||
function NewMemoryPage() { | ||
return <div>NewMemoryPage</div>; | ||
} | ||
|
||
export default NewMemoryPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from "react"; | ||
|
||
function ProfilePage() { | ||
return <div>ProfilePage</div>; | ||
} | ||
|
||
export default ProfilePage; |
Oops, something went wrong.