mirror of
https://github.com/bubblecup-12/VogelSocialMedia.git
synced 2025-07-06 15:18:48 +00:00
remove space between Feather Feed in title
This commit is contained in:
parent
b491847c49
commit
00acfa3301
1 changed files with 0 additions and 141 deletions
|
@ -1,141 +0,0 @@
|
||||||
import "./header.css";
|
|
||||||
import React, { useState } from "react";
|
|
||||||
import {
|
|
||||||
List,
|
|
||||||
ListItem,
|
|
||||||
ListItemButton,
|
|
||||||
ListItemIcon,
|
|
||||||
ListItemText,
|
|
||||||
SwipeableDrawer,
|
|
||||||
} from "@mui/material";
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import AddAPhotoIcon from "@mui/icons-material/AddAPhoto";
|
|
||||||
import DynamicFeedIcon from "@mui/icons-material/DynamicFeed";
|
|
||||||
import PersonIcon from "@mui/icons-material/Person";
|
|
||||||
import InfoIcon from "@mui/icons-material/Info";
|
|
||||||
import LogoutIcon from "@mui/icons-material/Logout";
|
|
||||||
import ExitToAppIcon from "@mui/icons-material/ExitToApp";
|
|
||||||
import FollowTheSignsIcon from "@mui/icons-material/FollowTheSigns";
|
|
||||||
import { useNavigate, replace } from "react-router-dom";
|
|
||||||
import { useAuth } from "../api/Auth";
|
|
||||||
|
|
||||||
// TODO: Dinge so umstrukturieren, dass der State für das offene menü in Header ist und das Menü auch in Header, sodass es mit width 100% die volle breite einnehmen kann
|
|
||||||
|
|
||||||
function Header() {
|
|
||||||
interface ListItemAttributes {
|
|
||||||
text: string;
|
|
||||||
icon: React.ElementType;
|
|
||||||
onClick: () => void;
|
|
||||||
onlyShowWhen: "loggedIn" | "loggedOut" | "always";
|
|
||||||
}
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
|
||||||
const toggleMenu = () => {
|
|
||||||
setIsOpen(!isOpen);
|
|
||||||
};
|
|
||||||
const { logout, user } = useAuth();
|
|
||||||
const ListItems: ListItemAttributes[] = [
|
|
||||||
{
|
|
||||||
text: "Feed",
|
|
||||||
icon: DynamicFeedIcon,
|
|
||||||
onClick: () => navigate("/feed", { replace: true }),
|
|
||||||
onlyShowWhen: "always",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "Create Post",
|
|
||||||
icon: AddAPhotoIcon,
|
|
||||||
onClick: () => navigate("/createpost", { replace: true }),
|
|
||||||
onlyShowWhen: "loggedIn",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "Profile",
|
|
||||||
icon: PersonIcon,
|
|
||||||
onClick: () => navigate("/profile", { replace: true }),
|
|
||||||
onlyShowWhen: "loggedIn",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "About",
|
|
||||||
icon: InfoIcon,
|
|
||||||
onClick: () => navigate("/about", { replace: true }),
|
|
||||||
onlyShowWhen: "always",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "Log Out",
|
|
||||||
icon: LogoutIcon,
|
|
||||||
onClick: logout,
|
|
||||||
onlyShowWhen: "loggedIn",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "Log In",
|
|
||||||
icon: ExitToAppIcon,
|
|
||||||
onClick: () => navigate("/login", { replace: true }),
|
|
||||||
onlyShowWhen: "loggedOut",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "Sign Up",
|
|
||||||
icon: FollowTheSignsIcon,
|
|
||||||
onClick: () => navigate("/register", { replace: true }),
|
|
||||||
onlyShowWhen: "loggedOut",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const DrawerList = (
|
|
||||||
<Box role="menu" onClick={() => setIsOpen(false)}>
|
|
||||||
<List className="drawer-list">
|
|
||||||
{ListItems.map((ListItemObject, index) =>
|
|
||||||
ListItemObject.onlyShowWhen == "always" ||
|
|
||||||
(ListItemObject.onlyShowWhen == "loggedIn" && user) ||
|
|
||||||
(ListItemObject.onlyShowWhen == "loggedOut" && !user) ? (
|
|
||||||
<ListItem
|
|
||||||
className="drawer-list-item"
|
|
||||||
key={ListItemObject.text}
|
|
||||||
disablePadding
|
|
||||||
>
|
|
||||||
<ListItemButton
|
|
||||||
className="drawer-list-item-button"
|
|
||||||
onClick={ListItemObject.onClick}
|
|
||||||
>
|
|
||||||
<ListItemIcon className="drawer-list-item">
|
|
||||||
{React.createElement(ListItemObject.icon)}
|
|
||||||
</ListItemIcon>
|
|
||||||
<ListItemText
|
|
||||||
className="drawer-list-item"
|
|
||||||
primary={ListItemObject.text}
|
|
||||||
/>
|
|
||||||
</ListItemButton>
|
|
||||||
</ListItem>
|
|
||||||
) : null
|
|
||||||
)}
|
|
||||||
</List>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<header className="base-header blue-background">
|
|
||||||
<img
|
|
||||||
className="header-icon header-icon-feather"
|
|
||||||
src="/assets/icons/BirdIconO.ico"
|
|
||||||
alt="featherIcon"
|
|
||||||
/>
|
|
||||||
<p className="header-title small-title">Feather Feed</p>
|
|
||||||
<img
|
|
||||||
className="header-icon header-icon-menu"
|
|
||||||
src="/assets/icons/menu_orange.svg"
|
|
||||||
alt="menu"
|
|
||||||
onClick={toggleMenu}
|
|
||||||
/>
|
|
||||||
</header>
|
|
||||||
<SwipeableDrawer
|
|
||||||
anchor={"right"}
|
|
||||||
open={isOpen}
|
|
||||||
onClose={() => setIsOpen(false)}
|
|
||||||
onOpen={() => setIsOpen(true)}
|
|
||||||
>
|
|
||||||
{DrawerList}
|
|
||||||
</SwipeableDrawer>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Header;
|
|
Loading…
Add table
Add a link
Reference in a new issue