Skip to content

Commit

Permalink
feat:add hamberger marathonLIst and update nav tyle
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentxuu committed Dec 13, 2024
1 parent 032aa2e commit 26d5479
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 25 deletions.
30 changes: 15 additions & 15 deletions constants/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,26 +273,26 @@ export const NAV_LINK_MOBILE = [
// link: '/activities',
// target: '_self',
// },
{
name: '找故事',
link: 'https://blog.daoedu.tw',
target: '_blank',
},
// {
// name: '找故事',
// link: 'https://blog.daoedu.tw',
// target: '_blank',
// },
// {
// name: '找場域',
// link: '/locations',
// target: '_self',
// },
{
name: '新增資源',
link: '/contribute/resource',
target: '_self',
},
{
name: '關於島島',
link: '/about',
target: '_self',
},
// {
// name: '新增資源',
// link: '/contribute/resource',
// target: '_self',
// },
// {
// name: '關於島島',
// link: '/about',
// target: '_self',
// },
{
name: '加入社群',
link: '/join',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import React, { useState } from 'react';
import { keyframes, css } from '@emotion/react';
import styled from '@emotion/styled';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';
import { useDispatch } from 'react-redux';
import { userLogout } from '@/redux/actions/user';
import useMediaQuery from '@mui/material/useMediaQuery';

import { Avatar, Box, MenuItem, Typography } from '@mui/material';
import { useRouter } from 'next/router';

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;
border-radius: 4px;
${(props) => css`
color: ${props.isDisabled ? 'rgba(83, 97, 102, 0.5)' : '#536166'};
cursor: ${props.isDisabled ? 'not-allowed' : 'pointer'};
animation-delay: ${props.delay};
min-width: 126px;
padding: 12px;
font-size: 18px;
&:hover {
background-color: #def5f5;
}
`}
`;

const MarathonList = ({ onCloseMenu = () => {}, user }) => {
const dispatch = useDispatch();
const isPadScreen = useMediaQuery('(max-width: 767px)');

const { push } = useRouter();

const [isOpenMenu, setIsOpenMenu] = useState(true);


return (
<Box sx={{ margin: '8px 32px 8px 24px', cursor: 'pointer', position: 'relative' }}>
<Box
sx={{
fontSize: '18px',
display: 'flex',
color: '#16b9b3',
borderRadius: '4px',
transition: 'background-color 0.3s ease, padding 0.3s ease',
}}
onClick={() => setIsOpenMenu(!isOpenMenu)}
>
島島盃-春季學習馬拉松
{isOpenMenu ? <KeyboardArrowUpIcon /> : <KeyboardArrowDownIcon />}
</Box>
<Box
sx={{
display: isOpenMenu ? 'block' : 'none',
position: 'relative',
borderRadius: '8px',
backgroundColor: 'white',
right: '0',
zIndex: 1,
}}
>
<Box sx={{ marginTop: '6px' }}>
{[
{ name: '活動詳情', id: 'marathon-detail' },
{ name: '學習計畫分享區', id: 'marathon-sharing' },
{ name: '活動公告', id: 'marathon-announcement' },
{ name: '成果分享(暫不公開)', id: 'project-sharing' },
].map((v, i) => (
<StyledMenuItem
as="div"
key={v.id}
delay={`${i * 0.1}s`}
isPadScreen={isPadScreen}
isDisabled={v.id === 'project-sharing'}
onClick={() => {
setIsOpenMenu(false);
onCloseMenu();
push('/learning-marathon?id=' + v.id);
}}
>
{v.name}
</StyledMenuItem>
))}
</Box>
</Box>
</Box>
);
};

export default MarathonList;
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Button } from '@mui/material';
import openLoginWindow from '@/utils/openLoginWindow';
import UserAvatar from '../SubList/UserAvatar';
import MenuItem from './MenuItem';
import MarathonList from './MarathonList';

const MenuWrapper = styled.div`
position: fixed;
Expand Down Expand Up @@ -62,6 +63,7 @@ const Menu = ({ open, list, onCloseMenu, shiftTop = '80px' }) => {
/>
);
})}
<MarathonList/>
<MenuDivider />
{user._id ? (
<UserAvatar user={user} onCloseMenu={onCloseMenu} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ const slideInFrames = keyframes`
const StyledMenuItem = styled(MenuItem)`
animation: 0.5s ${slideInFrames} forwards;
transition: color 0.2s ease-in-out;
color: #536166;
border-radius: 4px;
${(props) => css`
color: ${props.isDisabled ? 'rgba(83, 97, 102, 0.5)' : '#536166'};
cursor: ${props.isDisabled ? 'not-allowed' : 'pointer'};
animation-delay: ${props.delay};
min-width: 126px;
padding: ${props.isPadScreen ? '12px 52px' : '12px'};
Expand Down Expand Up @@ -54,17 +55,25 @@ const MarathonList = ({ onCloseMenu = () => {}, user }) => {
return (
<Box sx={{ margin: '8px 32px', cursor: 'pointer', position: 'relative' }}>
<Box
sx={{ display: 'flex', alignItems: 'center' }}
sx={{
display: 'flex',
alignItems: 'center',
backgroundColor: isOpenMenu ? '#def5f5' : 'transparent',
color: isOpenMenu ? '#16b9b3':'#def5f5',
padding: '8px',
borderRadius: '8px',
transition: 'background-color 0.3s ease, padding 0.3s ease',
}}
onClick={() => setIsOpenMenu(!isOpenMenu)}
>
島島盃2025<br/>春季學習馬拉松
島島盃-春季學習馬拉松
{isOpenMenu ? <KeyboardArrowUpIcon /> : <KeyboardArrowDownIcon />}
</Box>
<Box
sx={{
display: isOpenMenu ? 'block' : 'none',
position: isPadScreen ? 'relative' : 'absolute',
top: isPadScreen ? 0 : '55px',
top: isPadScreen ? 0 : '50px',
borderRadius: '8px',
backgroundColor: 'white',
right: '0',
Expand All @@ -76,14 +85,14 @@ const MarathonList = ({ onCloseMenu = () => {}, user }) => {
{ name: '活動詳情', id: 'marathon-detail' },
{ name: '學習計畫分享區', id: 'marathon-sharing' },
{ name: '活動公告', id: 'marathon-announcement' },
{ name: '報名資料修改', id: 'marathon-edit' },
{ name: '成果分享(暫不公開)', id: 'project-sharing' },
].map((v, i) => (
<StyledMenuItem
as="div"
key={v.id}
delay={`${i * 0.1}s`}
isPadScreen={isPadScreen}
isDisabled={v.id === 'project-sharing'}
onClick={() => {
setIsOpenMenu(false);
onCloseMenu();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const UserAvatar = ({ onCloseMenu = () => {}, user }) => {
{ name: '個人資料', id: 'person-setting' },
{ name: '我的揪團', id: 'my-group' },
{ name: '帳號設定', id: 'account-setting' },
{ name: '學習馬拉松', id: 'my-marathon' },
].map((v, i) => (
<StyledMenuItem
as="div"
Expand Down
3 changes: 2 additions & 1 deletion shared/components/Navigation_v2/PromotionBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const PromotionBarWrapper = styled.div`
background-color: #FE9D35;
color: #fff;
padding: 10px 12% 10px 5%;
text-align: center;
text-align: left;
align-items: center;
font-size: 16px;
a:hover {
text-decoration: underline;
Expand Down
6 changes: 2 additions & 4 deletions shared/components/Navigation_v2/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const NavigationWrapper = styled(AppBar)(({ hasPromote }) => ({
justifyContent: 'center',
alignItems: 'center',
height: 'auto',
minHeight: '68px',
minHeight: '64px',
padding: '0',
...(hasPromote && {
padding: '0',
Expand Down Expand Up @@ -47,12 +47,10 @@ const Navigation = () => {
const [currentIndex, setCurrentIndex] = useState(0);

useEffect(() => {
// 設置一個定時器,每 5 秒更換一次文字
const interval = setInterval(() => {
setCurrentIndex((prevIndex) => (prevIndex + 1) % texts.length);
}, 8000);

// 清除定時器以防止內存洩漏
return () => clearInterval(interval);
}, [texts.length]);

Expand All @@ -66,7 +64,7 @@ const Navigation = () => {
toggleAction={setShowPromotionBar}
/>
{/* <Toolbar> */}
<MainNav height={showPromotetionBar ? '118px' : '80px'} />
<MainNav height={showPromotetionBar ? '124px' : '80px'} />
{/* </Toolbar> */}
</NavigationWrapper>
</>
Expand Down

0 comments on commit 26d5479

Please sign in to comment.