diff --git a/pages/profile/index.jsx b/pages/profile/index.jsx index 8bb5467b..4ccdb670 100644 --- a/pages/profile/index.jsx +++ b/pages/profile/index.jsx @@ -21,7 +21,7 @@ const HomePageWrapper = styled.div` `; const StyledTab = styled(Tab)(({ isActive, mobileScreen }) => ({ - width: `${mobileScreen ? '50%' : '100%'}`, + width: `${mobileScreen ? '33%' : '100%'}`, color: '#536166', borderRadius: '8px', '&.Mui-selected': { diff --git a/shared/components/Navigation_v2/MainNav/Hamberger/MenuItem.jsx b/shared/components/Navigation_v2/MainNav/Hamberger/MenuItem.jsx index 64e5dbb2..6d158123 100644 --- a/shared/components/Navigation_v2/MainNav/Hamberger/MenuItem.jsx +++ b/shared/components/Navigation_v2/MainNav/Hamberger/MenuItem.jsx @@ -37,47 +37,32 @@ const MenuItemWrapper = styled.li` `; const ItemWrapper = styled.div` - font-size: 30px; - padding: 1rem 0; - margin: 0 5%; + font-size: 18px; + padding: 12px 24px; + border-radius: 8px; cursor: pointer; - color: #fafafa; transition: color 0.2s ease-in-out; animation: 0.5s ${slideInFrames} forwards; + color: #536166; ${(props) => css` animation-delay: ${props.delay}; `} &:hover { - color: 'gray'; + background-color: #def5f5; + font-weight: bold; } `; -const LineStyle = styled.div` - width: '90%'; - height: '1px'; - background: '#fafafa'; - margin: '0 auto'; - animation: 0.5s ${shrinkFrames} forwards; - ${(props) => css` - animation-delay: ${props.delay}; - `} -`; - const MenuItem = ({ delay, text, link, onClick }) => { - if (link) { - return ( - - - {text} - - - - ); - } return ( - {text} - + {link ? ( + + {text} + + ) : ( + {text} + )} ); }; diff --git a/shared/components/Navigation_v2/MainNav/Hamberger/MenuList.jsx b/shared/components/Navigation_v2/MainNav/Hamberger/MenuList.jsx index add3b866..d0212b87 100644 --- a/shared/components/Navigation_v2/MainNav/Hamberger/MenuList.jsx +++ b/shared/components/Navigation_v2/MainNav/Hamberger/MenuList.jsx @@ -1,45 +1,55 @@ -// import { keyframes, css } from '@emotion/react'; import styled from '@emotion/styled'; -import { Box } from '@mui/material'; import { useRouter } from 'next/router'; import MenuItem from './MenuItem'; import UserAvatar from '../SubList/UserAvatar'; import { useSelector } from 'react-redux'; +import { Button } from '@mui/material'; const MenuWrapper = styled.div` position: fixed; - top: 0; + top: ${(props) => props.shiftTop}; left: 0; - height: ${(props) => (props.open ? '100%' : 0)}; + height: ${(props) => (props.open ? '100dvh' : 0)}; width: 100vw; display: flex; flex-direction: column; - background: #16b9b3; - opacity: 0.95; - color: #fafafa; + background: white; transition: height 0.3s ease; z-index: 100; overflow: auto; `; const MenuListWrapper = styled.div` - padding: 3rem; - margin-top: 30px; + padding: 1rem; position: relative; z-index: 100; + height: inherit; `; -const Menu = ({ open, list, onCloseMenu }) => { - const router = useRouter(); +const MenuDivider = styled.div` + height: 1px; + width: 100%; + background-color: #def5f5; + margin: 1rem 0; +`; +const LoginButton = styled(Button)` + width: 100%; + height: 40px; + padding: 5px 20px; + color: #536166; + font-size: 16px; + line-height: 1.4; + border-radius: 20px; + border: 1px solid #16b9b3; +`; +const Menu = ({ open, list, onCloseMenu, shiftTop = '80px' }) => { const user = useSelector((state) => state.user); - console.log("MenuList", user); return ( - + {open && ( - {list.map((value, index) => { return ( { /> ); })} + + {user._id ? ( + + ) : ( + 登入 + )} )} diff --git a/shared/components/Navigation_v2/MainNav/Hamberger/index.jsx b/shared/components/Navigation_v2/MainNav/Hamberger/index.jsx index 7db6c736..ee6d8bc3 100644 --- a/shared/components/Navigation_v2/MainNav/Hamberger/index.jsx +++ b/shared/components/Navigation_v2/MainNav/Hamberger/index.jsx @@ -19,7 +19,10 @@ const MobileLinkListWrapper = styled.ul` li { flex: none; width: 100%; - border-bottom: solid 1px white; + } + + li a { + color: #536166; } svg[type='menu']:checked + ul { @@ -39,13 +42,14 @@ const MobileLinkListWrapper = styled.ul` } `; -const MainNav = () => { +const MainNav = ({ shiftTop = 0 }) => { const [isMenuOpen, setIsMenuOpen] = useState(false); const avatar = ''; const isUserLogin = true; return ( { +const slideInFrames = keyframes` + 0% { + transform: translateX(-2%); + } + 100% { + transform: translateX(0); + } +`; + +const StyledMenuItem = styled(MenuItem)` + animation: 0.5s ${slideInFrames} forwards; + transition: color 0.2s ease-in-out; + color: #536166; + border-radius: 4px; + ${(props) => css` + animation-delay: ${props.delay}; + padding: ${props.isPadScreen} ? 12px : 12px 52px; + font-size: ${props.isPadScreen} ? 18px : 16px; + magrin: ${props.isPadScreen} ? 8px 0; : '0'; + &:hover { + background-color: #DEF5F5; + } + `} +`; + +const UserAvatar = ({ onCloseMenu = () => {}, user }) => { + const isPadScreen = useMediaQuery('(max-width: 767px)'); + const { push } = useRouter(); - const user = useSelector((state) => state.user); const [isOpenMenu, setIsOpenMenu] = useState(null); - const handleSignOut = () => { - console.log('handleSignOut'); + const logout = () => { + dispatch(userLogout()); + setIsOpenMenu(false); + onCloseMenu(); + push('/'); }; - if (!user._id) { - return ( - { - push('/login'); - }} - > - - - ); - } return ( - - setIsOpenMenu(event.currentTarget)} - onClick={() => { - setIsOpenMenu(false); - push('/profile'); + + setIsOpenMenu(!isOpenMenu)} + > + {user.name && ( + + )} + {isPadScreen && ( + <> + + {user.name} + + {isOpenMenu ? : } + + )} + + - setIsOpenMenu(false)} > - { - setIsOpenMenu(false); - push('/profile'); - }} - > - 個人頁面 - - { - setIsOpenMenu(false); - push('/profile'); - }} - > - 帳號設定 - - { - handleSignOut(); - push('/'); - setIsOpenMenu(false); - }} - > - 登出 - - - + + {[ + { name: '個人資料', id: 'person-setting' }, + { name: '我的揪團', id: 'my-group' }, + { name: '帳號設定', id: 'account-setting' }, + ].map((v, i) => ( + { + setIsOpenMenu(false); + onCloseMenu(); + push('/profile?id=' + v.id); + }} + > + {v.name} + + ))} + + 登出 + + + ); }; diff --git a/shared/components/Navigation_v2/MainNav/SubList/index.jsx b/shared/components/Navigation_v2/MainNav/SubList/index.jsx index cde450ff..a3ec13bd 100644 --- a/shared/components/Navigation_v2/MainNav/SubList/index.jsx +++ b/shared/components/Navigation_v2/MainNav/SubList/index.jsx @@ -1,14 +1,10 @@ import React from 'react'; import styled from '@emotion/styled'; import Link from 'next/link'; -import { Typography } from '@mui/material'; -import useFirebase from '../../../../../hooks/useFirebase'; import UserAvatar from './UserAvatar'; -// import { useAuthState } from "react-firebase-hooks/auth"; -// import { signInWithPopup } from "firebase/auth"; -// import { useDispatch, useSelector } from "react-redux"; -// import { userLogin } from "../../../../../redux/actions/user"; -// import { useCollectionData } from "react-firebase-hooks/firestore"; +import { useSelector } from 'react-redux'; +import { Button } from '@mui/material'; +import { BASE_URL } from '@/constants/common'; const LinkListWrapper = styled.ul` display: flex; @@ -50,8 +46,7 @@ const SubListWrapper = styled.div` `; const SubList = () => { - // const dispatch = useDispatch(); - const { auth, user } = useFirebase(); + const user = useSelector((state) => state.user); return ( @@ -64,7 +59,23 @@ const SubList = () => {
  • - + {user._id ? ( + + ) : ( + + )}
  • diff --git a/shared/components/Navigation_v2/MainNav/index.jsx b/shared/components/Navigation_v2/MainNav/index.jsx index 26b8731f..e929694f 100644 --- a/shared/components/Navigation_v2/MainNav/index.jsx +++ b/shared/components/Navigation_v2/MainNav/index.jsx @@ -24,7 +24,7 @@ const BoxWrapper = styled(Box)` } `; -const MainNav = () => { +const MainNav = ({ height }) => { return ( @@ -34,7 +34,7 @@ const MainNav = () => { {/* right list */} {/* mobile only */} - + ); diff --git a/shared/components/Navigation_v2/PromotionBar.jsx b/shared/components/Navigation_v2/PromotionBar.jsx index 8320649a..20aa552b 100644 --- a/shared/components/Navigation_v2/PromotionBar.jsx +++ b/shared/components/Navigation_v2/PromotionBar.jsx @@ -2,6 +2,10 @@ import { useState, useEffect } from 'react'; import styled from '@emotion/styled'; const PromotionBarWrapper = styled.div` + width: 100%; + position: fixed; + top: 0; + padding-bottom: 20px; background-color: #f37b5f; color: #fff; padding: 7px; @@ -46,25 +50,15 @@ const CloseButton = styled.span` } `; -const PromotionBar = ({ link, text }) => { - const [show, setShow] = useState(undefined); - - useEffect(() => { - setShow(true); - }, []); - - const handleClose = () => { - setShow(false); - }; - +const PromotionBar = ({ isShow, link, text, toggleAction }) => { return ( <> - {show && ( + {isShow && ( {text} - + toggleAction(false)} /> )} diff --git a/shared/components/Navigation_v2/index.jsx b/shared/components/Navigation_v2/index.jsx index ba84470c..942dedad 100644 --- a/shared/components/Navigation_v2/index.jsx +++ b/shared/components/Navigation_v2/index.jsx @@ -1,20 +1,23 @@ -import React from 'react'; +import { useEffect, useState } from 'react'; import styled from '@emotion/styled'; import { AppBar } from '@mui/material'; import MainNav from './MainNav'; import PromotionBar from './PromotionBar'; -const NavigationWrapper = styled(AppBar)` - display: flex; - justify-content: center; - align-items: center; - height: 80px; - padding-left: 5%; - padding-right: 5%; - .MuiToolbar-root { - padding: 0; - } -`; +const NavigationWrapper = styled(AppBar)(({ hasPromote }) => ({ + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + height: '80px', + padding: '0 5%', + ...(hasPromote && { + padding: '38px 5% 0', + height: '118px', + }), + '.MuiToolbar-root': { + padding: '0', + }, +})); const donateTexts = [ '✨島島阿學需要你的支持,讓人人都享有同等資源✨', @@ -32,12 +35,19 @@ const buildRandomText = () => { // `; // 問卷 https://docs.google.com/forms/d/e/1FAIpQLSeyU9-Q-kIWp5uutcik3h-RO4o5VuG6oG0m-4u1Ua18EOu3aw/viewform const Navigation = () => { + const [showPromotetionBar, setShowPromotionBar] = useState(true); + return ( <> - - + + {/* */} - + {/* */}