-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from yoshiya0503/development
🎉Release v1.1
- Loading branch information
Showing
40 changed files
with
539 additions
and
188 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
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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import _ from "lodash"; | ||
import { useNavigate, useLocation } from "react-router-dom"; | ||
import Avatar from "@mui/material/Avatar"; | ||
import Fab from "@mui/material/Fab"; | ||
import Paper from "@mui/material/Paper"; | ||
import BottomNavigation from "@mui/material/BottomNavigation"; | ||
import BottomNavigationAction from "@mui/material/BottomNavigationAction"; | ||
import Badge from "@mui/material/Badge"; | ||
import Home from "@mui/icons-material/HomeRounded"; | ||
import Search from "@mui/icons-material/SearchRounded"; | ||
import Tag from "@mui/icons-material/TagRounded"; | ||
import Notifications from "@mui/icons-material/NotificationsRounded"; | ||
import Create from "@mui/icons-material/CreateRounded"; | ||
import DialogPost from "@/components/DialogPost"; | ||
import useMe from "@/hooks/useMe"; | ||
import useRealtime from "@/hooks/useRealtime"; | ||
import useDialog from "@/hooks/useDialog"; | ||
|
||
export const BottomMenu = () => { | ||
const me = useMe(); | ||
const { unreadCount, unreadTimeline } = useRealtime(); | ||
const navigate = useNavigate(); | ||
const location = useLocation(); | ||
const [isOpen, openPostDialog, closePostDialog] = useDialog(); | ||
|
||
const menus = [ | ||
{ | ||
name: "Home", | ||
icon: ( | ||
<Badge color="primary" variant="dot" invisible={!_.size(unreadTimeline)}> | ||
<Home sx={{ width: 32, height: 32 }} /> | ||
</Badge> | ||
), | ||
href: "/", | ||
}, | ||
{ name: "Search", icon: <Search sx={{ width: 32, height: 32 }} />, href: "/search" }, | ||
{ name: "Feeds", icon: <Tag sx={{ width: 32, height: 32 }} />, href: "/feeds" }, | ||
{ | ||
name: "Notifications", | ||
icon: ( | ||
<Badge badgeContent={unreadCount} color="primary"> | ||
<Notifications sx={{ width: 32, height: 32 }} /> | ||
</Badge> | ||
), | ||
href: "/notifications", | ||
}, | ||
{ name: "Profile", icon: <Avatar sx={{ width: 32, height: 32 }} src={me.avatar} />, href: `/profile/${me.handle}` }, | ||
]; | ||
|
||
const onClickMenu = (href: string) => { | ||
if (location.pathname !== href) { | ||
navigate(href); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<Fab | ||
sx={{ position: "absolute", bottom: 72, right: 32, width: 64, height: 64 }} | ||
color="primary" | ||
onClick={openPostDialog} | ||
> | ||
<Create /> | ||
</Fab> | ||
<Paper sx={{ position: "fixed", bottom: 0, left: 0, right: 0, zIndex: 1 }} elevation={8}> | ||
<BottomNavigation | ||
sx={{ pb: 2 }} | ||
value={location.pathname} | ||
onChange={(_, href) => { | ||
onClickMenu(href); | ||
}} | ||
> | ||
{_.map(menus, (menu, key) => ( | ||
<BottomNavigationAction key={key} icon={menu.icon} value={menu.href} /> | ||
))} | ||
</BottomNavigation> | ||
</Paper> | ||
<DialogPost title="Post" open={isOpen} onClose={closePostDialog} /> | ||
</> | ||
); | ||
}; | ||
|
||
export default BottomMenu; |
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 |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import _ from "lodash"; | ||
import { useNavigate, useLocation } from "react-router-dom"; | ||
import { grey } from "@mui/material/colors"; | ||
import Drawer from "@mui/material/SwipeableDrawer"; | ||
import IconButton from "@mui/material/IconButton"; | ||
import List from "@mui/material/List"; | ||
import ListItem from "@mui/material/ListItem"; | ||
import ListItemIcon from "@mui/material/ListItemIcon"; | ||
import ListItemText from "@mui/material/ListItemText"; | ||
import ListItemButton from "@mui/material/ListItemButton"; | ||
import Badge from "@mui/material/Badge"; | ||
import Home from "@mui/icons-material/HomeRounded"; | ||
import Search from "@mui/icons-material/SearchRounded"; | ||
import Tag from "@mui/icons-material/TagRounded"; | ||
import MenuRoundedIcon from "@mui/icons-material/MenuRounded"; | ||
import Notifications from "@mui/icons-material/NotificationsRounded"; | ||
import AccountCircle from "@mui/icons-material/AccountCircleRounded"; | ||
import Settings from "@mui/icons-material/SettingsRounded"; | ||
import ProfileHeader from "@/components/ProfileHeader"; | ||
import useMe from "@/hooks/useMe"; | ||
import useRealtime from "@/hooks/useRealtime"; | ||
import useDrawer from "@/hooks/useDrawer"; | ||
|
||
export const DrawerMenu = () => { | ||
const me = useMe(); | ||
const { unreadCount, unreadTimeline } = useRealtime(); | ||
const navigate = useNavigate(); | ||
const location = useLocation(); | ||
const [open, onOpenDrawer, onCloseDrawer] = useDrawer(); | ||
|
||
const menus = [ | ||
{ | ||
name: "Home", | ||
icon: ( | ||
<Badge color="primary" variant="dot" invisible={!_.size(unreadTimeline)}> | ||
<Home /> | ||
</Badge> | ||
), | ||
href: "/", | ||
}, | ||
{ name: "Search", icon: <Search />, href: "/search" }, | ||
{ name: "Feeds", icon: <Tag />, href: "/feeds" }, | ||
{ | ||
name: "Notifications", | ||
icon: ( | ||
<Badge badgeContent={unreadCount} color="primary"> | ||
<Notifications /> | ||
</Badge> | ||
), | ||
href: "/notifications", | ||
}, | ||
{ name: "Profile", icon: <AccountCircle />, href: `/profile/${me.handle}` }, | ||
{ name: "Settings", icon: <Settings />, href: "/settings" }, | ||
]; | ||
|
||
const onClickMenu = (href: string) => () => { | ||
if (location.pathname !== href) { | ||
navigate(href); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<IconButton onClick={onOpenDrawer}> | ||
<MenuRoundedIcon sx={{ width: 32, height: 32, color: grey[400] }} /> | ||
</IconButton> | ||
<Drawer | ||
sx={{ zIndex: 1300 }} | ||
component="nav" | ||
anchor="left" | ||
open={open} | ||
onOpen={onOpenDrawer} | ||
onClose={onCloseDrawer} | ||
> | ||
<List> | ||
<ListItem> | ||
<ProfileHeader profile={me} size="large" /> | ||
</ListItem> | ||
{_.map(menus, (menu, key) => ( | ||
<ListItem key={key} onClick={onClickMenu(menu.href)}> | ||
<ListItemButton sx={{ borderRadius: 6 }}> | ||
<ListItemIcon>{menu.icon}</ListItemIcon> | ||
<ListItemText primary={menu.name} /> | ||
</ListItemButton> | ||
</ListItem> | ||
))} | ||
</List> | ||
</Drawer> | ||
</> | ||
); | ||
}; | ||
|
||
export default DrawerMenu; |
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { useCallback } from "react"; | ||
import { useNavigate, useLocation } from "react-router-dom"; | ||
import { useTheme } from "@mui/material/styles"; | ||
import useMediaQuery from "@mui/material/useMediaQuery"; | ||
import { grey } from "@mui/material/colors"; | ||
import AppBar from "@mui/material/AppBar"; | ||
import Toolbar from "@mui/material/Toolbar"; | ||
import IconButton from "@mui/material/IconButton"; | ||
import Typography from "@mui/material/Typography"; | ||
import Settings from "@mui/icons-material/SettingsRounded"; | ||
import ArrowBackIosNewRoundedIcon from "@mui/icons-material/ArrowBackIosNewRounded"; | ||
import Search from "@/components/Search"; | ||
import DrawerMenu from "@/components/DrawerMenu"; | ||
|
||
type Props = { | ||
search?: boolean; | ||
history?: boolean; | ||
menu?: boolean; | ||
}; | ||
|
||
export const HeaderMenu = (props: Props) => { | ||
const navigate = useNavigate(); | ||
const location = useLocation(); | ||
const theme = useTheme(); | ||
const isPhone = useMediaQuery(theme.breakpoints.down("sm")); | ||
|
||
const back = useCallback(() => { | ||
navigate(-1); | ||
}, [navigate]); | ||
|
||
const setting = useCallback(() => { | ||
if (location.pathname !== "/settings") { | ||
navigate("/settings"); | ||
} | ||
}, [navigate, location]); | ||
|
||
return ( | ||
<AppBar | ||
sx={{ | ||
position: "sticky", | ||
backdropFilter: "blur(12px)", | ||
}} | ||
component="nav" | ||
elevation={0} | ||
enableColorOnDark | ||
color="transparent" | ||
> | ||
<Toolbar variant={isPhone ? undefined : "dense"} disableGutters={isPhone ? false : true}> | ||
{props.history && ( | ||
<IconButton size="small" color="primary" onClick={back}> | ||
<ArrowBackIosNewRoundedIcon fontSize="small" /> | ||
</IconButton> | ||
)} | ||
{props.menu && <DrawerMenu />} | ||
{isPhone && !props.search && ( | ||
<Typography variant="h5" sx={{ flexGrow: 1, textAlign: "center" }}> | ||
☔ | ||
</Typography> | ||
)} | ||
{props.search && <Search />} | ||
{isPhone && ( | ||
<IconButton onClick={setting}> | ||
<Settings sx={{ width: 32, height: 32, color: grey[400] }} /> | ||
</IconButton> | ||
)} | ||
</Toolbar> | ||
</AppBar> | ||
); | ||
}; | ||
|
||
export default HeaderMenu; |
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.