-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
212 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,36 @@ | ||
import { atom } from "recoil" | ||
import { atom } from "recoil"; | ||
|
||
/** | ||
* Interface which describes the state of the authentication modal. | ||
* The modal has 2 properties: | ||
* | ||
* - `open` (boolean): whether it is open or not | ||
* - `view` ("login" | "signup" | "resetPassword"): which specific view of the modal should be displayed | ||
*/ | ||
export interface AuthModalState { | ||
open: boolean; | ||
view: "login" | "signup" | "resetPassword"; | ||
}; | ||
open: boolean; | ||
view: "login" | "signup" | "resetPassword"; | ||
} | ||
|
||
/** | ||
* Describes the default state of the authentication modal. | ||
* By default, the modal is closed and | ||
* if no state is specified, it will open in the log in view. | ||
*/ | ||
const defaultModalState: AuthModalState = { | ||
open: false, | ||
view: "login", | ||
open: false, | ||
view: "login", | ||
}; | ||
|
||
/** | ||
* Atom which describes the state of the authentication modal. | ||
* The atom has the state options defined by `AuthModalState` and | ||
* uses the default state defined in `AuthModalState`. | ||
* @requires AuthModalState | ||
* @requires defaultModalState | ||
* @see https://recoiljs.org/docs/basic-tutorial/atoms/ | ||
*/ | ||
export const authModalState = atom<AuthModalState>({ | ||
key: "authModalState", | ||
default: defaultModalState, | ||
}); | ||
key: "authModalState", // unique identifier for the atom | ||
default: defaultModalState, | ||
}); |
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
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
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
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 |
---|---|---|
@@ -1,29 +1,41 @@ | ||
import { auth } from '@/firebase/clientApp'; | ||
import { Flex, Image } from '@chakra-ui/react'; | ||
import React from 'react'; | ||
import { useAuthState } from 'react-firebase-hooks/auth'; | ||
import RightContent from './RightContent/RightContent'; | ||
import SearchInput from './SearchInput'; | ||
|
||
const Navbar:React.FC = () => { | ||
const [user, loading, error] = useAuthState(auth); // will be passed to child components | ||
return ( | ||
<Flex bg="white" height="44px" padding="6px 12px"> | ||
<Flex align="center"> | ||
<Image src="/images/logo.svg" height="30px" alt="Website logo"/> | ||
|
||
{/* When screen size is mobile, SVG bellow is not displayed */} | ||
<Image | ||
src="/images/logo_text.svg" | ||
height="46px" | ||
display={{ base: "none", md: "unset" }} | ||
alt="Website text logo" | ||
/> | ||
</Flex> | ||
<SearchInput /> | ||
{/* <Directory/> */} | ||
<RightContent user={user}/> | ||
</Flex> | ||
); | ||
} | ||
export default Navbar; | ||
import { auth } from "@/firebase/clientApp"; | ||
import { Flex, Image } from "@chakra-ui/react"; | ||
import React from "react"; | ||
import { useAuthState } from "react-firebase-hooks/auth"; | ||
import RightContent from "./RightContent/RightContent"; | ||
import SearchInput from "./SearchInput"; | ||
|
||
/** | ||
* Creates a navbar component which contains the following elements: | ||
* | ||
* - Logo which is visible on mobile and desktop sizes | ||
* - Logo name which is visible only on desktop sizes | ||
* - Search bar which is visible on mobile and desktop sizes and resizes dynamically | ||
* @returns navbar component | ||
* @requires ./RightContent/RightContent | ||
* @requires ./SearchInput | ||
*/ | ||
const Navbar: React.FC = () => { | ||
const [user, loading, error] = useAuthState(auth); // will be passed to child components | ||
return ( | ||
<Flex bg="white" height="44px" padding="6px 12px"> | ||
<Flex align="center"> | ||
{/* Logo which is always visible */} | ||
<Image src="/images/logo.svg" height="30px" alt="Website logo" /> | ||
|
||
{/* Logo name not visible on mobile */} | ||
<Image | ||
src="/images/logo_text.svg" | ||
height="46px" | ||
display={{ base: "none", md: "unset" }} | ||
alt="Website text logo" | ||
/> | ||
</Flex> | ||
<SearchInput /> | ||
{/* <Directory/> */} | ||
{/* Changes depending on whether user is authenticated or not */} | ||
<RightContent user={user} /> | ||
</Flex> | ||
); | ||
}; | ||
export default Navbar; |
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
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
Oops, something went wrong.