diff --git a/components/BottomHeader/index.tsx b/components/BottomHeader/index.tsx new file mode 100644 index 00000000..e850489b --- /dev/null +++ b/components/BottomHeader/index.tsx @@ -0,0 +1,55 @@ +import React, { useContext, useEffect, useState } from 'react' +import { useCookies } from 'react-cookie' +import { useRouter } from 'next/router' + +import AppContext from '~context/AppContext' + +import Header from '~components/Header' +import Button from '~components/Button' + +import { ButtonType } from '~utils/enums' + +const BottomHeader = () => { + const { editable, setEditable, authenticated, setAuthenticated } = useContext(AppContext) + + const [username, setUsername] = useState(undefined) + const [cookies, _, removeCookie] = useCookies(['user']) + + const router = useRouter() + + useEffect(() => { + if (cookies.user) { + setAuthenticated(true) + setUsername(cookies.user.username) + } else { + setAuthenticated(false) + } + }, [cookies, setUsername, setAuthenticated]) + + const leftNav = () => { + return ( + + ) + } + + const rightNav = () => { + return ( +
+ { (editable && router.route === '/p/[party]') ? + : '' + } +
+ ) + } + + + return ( +
+ ) +} + +export default BottomHeader \ No newline at end of file diff --git a/components/Header/index.scss b/components/Header/index.scss index 5eb0d7cc..d5f5afea 100644 --- a/components/Header/index.scss +++ b/components/Header/index.scss @@ -1,8 +1,13 @@ -#Header { +.Header { display: flex; height: 34px; width: 100%; + &.bottom { + position: sticky; + bottom: $unit * 2; + } + #right { display: flex; gap: 8px; diff --git a/components/Header/index.tsx b/components/Header/index.tsx index 0ae20284..d82d83e3 100644 --- a/components/Header/index.tsx +++ b/components/Header/index.tsx @@ -1,82 +1,19 @@ -import React, { useContext, useEffect, useState } from 'react' -import { useCookies } from 'react-cookie' -import { useRouter } from 'next/router' - -import AppContext from '~context/AppContext' - -import Button from '~components/Button' -import HeaderMenu from '~components/HeaderMenu' +import React from 'react' import './index.scss' -interface Props {} +interface Props { + position: 'top' | 'bottom' + left: JSX.Element, + right: JSX.Element +} -const Header = (props: Props) => { - const { editable, setEditable, authenticated, setAuthenticated } = useContext(AppContext) - - const [username, setUsername] = useState(undefined) - const [cookies, _, removeCookie] = useCookies(['user']) - - const router = useRouter() - - useEffect(() => { - if (cookies.user) { - setAuthenticated(true) - setUsername(cookies.user.username) - console.log(`Logged in as user "${cookies.user.username}"`) - } else { - setAuthenticated(false) - console.log('You are currently not logged in.') - } - }, [cookies, setUsername, setAuthenticated]) - - function copyToClipboard() { - const el = document.createElement('input') - el.value = window.location.href - el.id = 'url-input' - document.body.appendChild(el) - - el.select() - document.execCommand('copy') - el.remove() - } - - function newParty() { - router.push('/') - } - - function logout() { - removeCookie('user') - - setAuthenticated(false) - if (editable) setEditable(false) - - // How can we log out without navigating to root - router.push('/') - return false - } - +const Header = (props: Props) => { return ( -