mirror of
https://github.com/bubblecup-12/VogelSocialMedia.git
synced 2025-07-06 15:18:48 +00:00
change header height, change header icon margin for mobile
This commit is contained in:
parent
f9bcb861ed
commit
75d77ba5d9
1 changed files with 142 additions and 83 deletions
|
@ -1,93 +1,152 @@
|
||||||
import "./header.css";
|
import "./header.css";
|
||||||
import React, { useState, useRef } from "react";
|
import React, { useState } from "react";
|
||||||
import { List, ListItem, ListItemButton, ListItemIcon, ListItemText, StyledEngineProvider, SwipeableDrawer, ThemeProvider } from '@mui/material';
|
import {
|
||||||
import Box from '@mui/material/Box';
|
List,
|
||||||
import AddAPhotoIcon from '@mui/icons-material/AddAPhoto';
|
ListItem,
|
||||||
import DynamicFeedIcon from '@mui/icons-material/DynamicFeed';
|
ListItemButton,
|
||||||
import PersonIcon from '@mui/icons-material/Person';
|
ListItemIcon,
|
||||||
import InfoIcon from '@mui/icons-material/Info';
|
ListItemText,
|
||||||
import LogoutIcon from '@mui/icons-material/Logout';
|
SwipeableDrawer,
|
||||||
import ExitToAppIcon from '@mui/icons-material/ExitToApp';
|
} from "@mui/material";
|
||||||
import FollowTheSignsIcon from '@mui/icons-material/FollowTheSigns';
|
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 { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import { useAuth } from "../api/Auth";
|
import { useAuth } from "../api/Auth";
|
||||||
import { ExitToApp } from "@mui/icons-material";
|
|
||||||
|
|
||||||
function Header() {
|
function Header() {
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const toggleMenu = () => {
|
const toggleMenu = () => {
|
||||||
setIsOpen(!isOpen);
|
setIsOpen(!isOpen);
|
||||||
};
|
};
|
||||||
const { logout, user } = useAuth();
|
const { logout, user } = useAuth();
|
||||||
const iconList = [DynamicFeedIcon, AddAPhotoIcon, PersonIcon, InfoIcon, LogoutIcon, ExitToAppIcon, FollowTheSignsIcon];
|
const iconList = [
|
||||||
const routerLinksList = ["/feed","/createpost","/profile","/about","/login","/register"]
|
DynamicFeedIcon,
|
||||||
|
AddAPhotoIcon,
|
||||||
|
PersonIcon,
|
||||||
|
InfoIcon,
|
||||||
|
LogoutIcon,
|
||||||
|
ExitToAppIcon,
|
||||||
|
FollowTheSignsIcon,
|
||||||
|
];
|
||||||
|
const routerLinksList = [
|
||||||
|
"/feed",
|
||||||
|
"/createpost",
|
||||||
|
"/profile",
|
||||||
|
"/about",
|
||||||
|
"/login",
|
||||||
|
"/register",
|
||||||
|
];
|
||||||
|
|
||||||
// TODO: Logout nur anzeigen wenn user eingeloggt ist
|
const DrawerList = (
|
||||||
|
<Box role="menu" onClick={() => setIsOpen(false)}>
|
||||||
|
<List className="drawer-list">
|
||||||
|
{["Feed", "Create Post", "Profile", "About Us"].map((text, index) => (
|
||||||
|
<ListItem className="drawer-list-item" key={text} disablePadding>
|
||||||
|
<ListItemButton
|
||||||
|
className="drawer-list-item-button"
|
||||||
|
component={Link}
|
||||||
|
to={routerLinksList[index]}
|
||||||
|
>
|
||||||
|
<ListItemIcon className="drawer-list-item">
|
||||||
|
{React.createElement(iconList[index])}
|
||||||
|
</ListItemIcon>
|
||||||
|
<ListItemText className="drawer-list-item" primary={text} />
|
||||||
|
</ListItemButton>
|
||||||
|
</ListItem>
|
||||||
|
))}
|
||||||
|
{user && (
|
||||||
|
<ListItem
|
||||||
|
className="drawer-list-item-button"
|
||||||
|
key={"Log Out"}
|
||||||
|
disablePadding
|
||||||
|
>
|
||||||
|
<ListItemButton
|
||||||
|
className="drawer-list-item-button"
|
||||||
|
onClick={logout}
|
||||||
|
>
|
||||||
|
<ListItemIcon className="drawer-list-item">
|
||||||
|
{React.createElement(iconList[4])}
|
||||||
|
</ListItemIcon>
|
||||||
|
<ListItemText className="drawer-list-item" primary={"Log Out"} />
|
||||||
|
</ListItemButton>
|
||||||
|
</ListItem>
|
||||||
|
)}
|
||||||
|
{!user && (
|
||||||
|
<>
|
||||||
|
<ListItem
|
||||||
|
className="drawer-list-item-button"
|
||||||
|
key={"Login"}
|
||||||
|
disablePadding
|
||||||
|
>
|
||||||
|
<ListItemButton
|
||||||
|
className="drawer-list-item-button"
|
||||||
|
component={Link}
|
||||||
|
to={routerLinksList[4]}
|
||||||
|
>
|
||||||
|
<ListItemIcon className="drawer-list-item">
|
||||||
|
{React.createElement(iconList[5])}
|
||||||
|
</ListItemIcon>
|
||||||
|
<ListItemText className="drawer-list-item" primary={"Login"} />
|
||||||
|
</ListItemButton>
|
||||||
|
</ListItem>
|
||||||
|
<ListItem
|
||||||
|
className="drawer-list-item-button"
|
||||||
|
key={"Sign up"}
|
||||||
|
disablePadding
|
||||||
|
>
|
||||||
|
<ListItemButton
|
||||||
|
className="drawer-list-item-button"
|
||||||
|
component={Link}
|
||||||
|
to={routerLinksList[5]}
|
||||||
|
>
|
||||||
|
<ListItemIcon className="drawer-list-item">
|
||||||
|
{React.createElement(iconList[6])}
|
||||||
|
</ListItemIcon>
|
||||||
|
<ListItemText
|
||||||
|
className="drawer-list-item"
|
||||||
|
primary={"Sign up"}
|
||||||
|
/>
|
||||||
|
</ListItemButton>
|
||||||
|
</ListItem>{" "}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</List>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
|
||||||
const DrawerList = (
|
return (
|
||||||
<Box role="menu" onClick={() => setIsOpen(false)}>
|
<>
|
||||||
<List className="drawer-list">
|
<header className="base-header blue-background">
|
||||||
{["Feed", "Create Post", "Profile", "About Us"].map((text, index) => (
|
<img
|
||||||
<ListItem className="drawer-list-item" key={text} disablePadding>
|
className="header-icon header-icon-feather"
|
||||||
<ListItemButton className="drawer-list-item-button" component={Link} to={routerLinksList[index]} >
|
src="/assets/icons/BirdIconO.ico"
|
||||||
<ListItemIcon className="drawer-list-item">
|
alt="featherIcon"
|
||||||
{React.createElement(iconList[index])}
|
/>
|
||||||
</ListItemIcon>
|
<p className="header-title small-title">Feather Feed</p>
|
||||||
<ListItemText className="drawer-list-item" primary={text}/>
|
<img
|
||||||
</ListItemButton>
|
className="header-icon header-icon-menu"
|
||||||
</ListItem>
|
src="/assets/icons/menu_orange.svg"
|
||||||
))}
|
alt="menu"
|
||||||
{user && <ListItem className="drawer-list-item-button" key={"Log Out"} disablePadding>
|
onClick={toggleMenu}
|
||||||
<ListItemButton className="drawer-list-item-button" onClick={logout}>
|
/>
|
||||||
<ListItemIcon className="drawer-list-item">
|
</header>
|
||||||
{React.createElement(iconList[4])}
|
<SwipeableDrawer
|
||||||
</ListItemIcon>
|
anchor={"right"}
|
||||||
<ListItemText className="drawer-list-item" primary={"Log Out"}/>
|
open={isOpen}
|
||||||
</ListItemButton>
|
onClose={() => setIsOpen(false)}
|
||||||
</ListItem> }
|
onOpen={() => setIsOpen(true)}
|
||||||
{!user && <> <ListItem className="drawer-list-item-button" key={"Login"} disablePadding>
|
>
|
||||||
<ListItemButton className="drawer-list-item-button" component={Link} to={routerLinksList[4]}>
|
{DrawerList}
|
||||||
<ListItemIcon className="drawer-list-item">
|
</SwipeableDrawer>
|
||||||
{React.createElement(iconList[5])}
|
</>
|
||||||
</ListItemIcon>
|
);
|
||||||
<ListItemText className="drawer-list-item" primary={"Login"}/>
|
|
||||||
</ListItemButton>
|
|
||||||
</ListItem>
|
|
||||||
<ListItem className="drawer-list-item-button" key={"Sign up"} disablePadding>
|
|
||||||
<ListItemButton className="drawer-list-item-button" component={Link} to={routerLinksList[5]}>
|
|
||||||
<ListItemIcon className="drawer-list-item">
|
|
||||||
{React.createElement(iconList[6])}
|
|
||||||
</ListItemIcon>
|
|
||||||
<ListItemText className="drawer-list-item" primary={"Sign up"}/>
|
|
||||||
</ListItemButton>
|
|
||||||
</ListItem> </> }
|
|
||||||
|
|
||||||
</List>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<header className="base-header blue-background">
|
|
||||||
<div className="header-icon"> <img className="header-icon-feather" src='/assets/icons/BirdIconO.ico' alt="featherIcon" /> </div>
|
|
||||||
<p className="header-title small-title">
|
|
||||||
Feather Feed
|
|
||||||
</p>
|
|
||||||
<div className="header-icon header-icon-menu"> <img src='/assets/icons/menu_orange.svg' alt="menu" onClick={toggleMenu} /> </div>
|
|
||||||
</header>
|
|
||||||
<SwipeableDrawer
|
|
||||||
anchor={"right"}
|
|
||||||
open={isOpen}
|
|
||||||
onClose={() => setIsOpen(false)}
|
|
||||||
onOpen={() => setIsOpen(true)}
|
|
||||||
>
|
|
||||||
{DrawerList}
|
|
||||||
</SwipeableDrawer>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// EXPORT VARIABLES
|
// EXPORT VARIABLES
|
||||||
export default Header;
|
export default Header;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue