From 53e10049a01ec7fa7074cb1cdca2370e856adedc Mon Sep 17 00:00:00 2001 From: spencerwooo Date: Mon, 30 Aug 2021 15:51:19 +0100 Subject: [PATCH] navbar logout and other custom icons --- components/Auth.tsx | 1 + components/Navbar.tsx | 68 ++++++++++++++++++++++++++++++------------- config/site.json | 10 +++++++ pages/_app.tsx | 8 ++++- 4 files changed, 66 insertions(+), 21 deletions(-) diff --git a/components/Auth.tsx b/components/Auth.tsx index ea226b5..aacb6dc 100644 --- a/components/Auth.tsx +++ b/components/Auth.tsx @@ -27,6 +27,7 @@ const Auth: FunctionComponent<{ redirect: string }> = ({ redirect }) => { { const router = useRouter() + const [tokenPresent, setTokenPresent] = useState(false) const [isOpen, setIsOpen] = useState(false) + useEffect(() => { + const storedToken = () => { + for (const r of siteConfig.protectedRoutes) { + if (localStorage.hasOwnProperty(r)) { + return true + } + } + return false + } + setTokenPresent(storedToken()) + }, []) + const clearTokens = () => { setIsOpen(false) @@ -30,25 +44,39 @@ const Navbar = () => {
-

- {siteConfig.title} -

-
- - - + + + + {siteConfig.title} + + +
+ {siteConfig.contacts.map((c, i) => ( + + {c.platform === 'email' ? ( + + ) : ( + + )} + + ))} + + {tokenPresent && ( + + )}
@@ -64,7 +92,7 @@ const Navbar = () => { leaveFrom="opacity-100" leaveTo="opacity-0" > - + {/* This element is to trick the browser into centering the modal contents. */} diff --git a/config/site.json b/config/site.json index d5947ef..f54993b 100644 --- a/config/site.json +++ b/config/site.json @@ -4,5 +4,15 @@ "protectedRoutes": [ "/🌞 Private folder/u-need-a-password", "/🥟 Some test files/Protected route" + ], + "contacts": [ + { + "platform": "email", + "link": "mailto:spencer.wushangbo@gmail.com" + }, + { + "platform": "github", + "link": "https://github.com/spencerwooo/onedrive-vercel-index" + } ] } diff --git a/pages/_app.tsx b/pages/_app.tsx index 46d0d08..704ae31 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -19,6 +19,7 @@ import { faCopy, faArrowAltCircleDown, faTrashAlt, + faEnvelope, } from '@fortawesome/free-regular-svg-icons' import { faPlus, @@ -32,6 +33,8 @@ import { faUndo, faBook, faKey, + faSignOutAlt, + faCloud, } from '@fortawesome/free-solid-svg-icons' import { faGithub, faMarkdown } from '@fortawesome/free-brands-svg-icons' @@ -65,7 +68,10 @@ library.add( faBook, faArrowAltCircleDown, faKey, - faTrashAlt + faTrashAlt, + faSignOutAlt, + faEnvelope, + faCloud ) function MyApp({ Component, pageProps }: AppProps) {