Added profile component
This commit is contained in:
parent
19f75f2253
commit
a4ada5fb79
0
src/components/Profile/index.scss
Normal file
0
src/components/Profile/index.scss
Normal file
27
src/components/Profile/index.tsx
Normal file
27
src/components/Profile/index.tsx
Normal file
@ -0,0 +1,27 @@
|
||||
import { Menu, MenuItem } from "@material-ui/core";
|
||||
import React, { FC } from "react";
|
||||
|
||||
|
||||
interface ProfileProps {
|
||||
anchorEl: HTMLElement | null;
|
||||
handleClose: () => void
|
||||
|
||||
}
|
||||
|
||||
export const Profile : FC<ProfileProps> = ({anchorEl, handleClose, ...restProps}) => {
|
||||
|
||||
return (
|
||||
<Menu
|
||||
className="top-bar__menu"
|
||||
id="simple-menu"
|
||||
anchorEl={anchorEl}
|
||||
keepMounted
|
||||
open={Boolean(anchorEl)}
|
||||
onClose={handleClose}
|
||||
>
|
||||
<MenuItem>Profile</MenuItem>
|
||||
<MenuItem>My account</MenuItem>
|
||||
<MenuItem>Logout</MenuItem>
|
||||
</Menu>
|
||||
);
|
||||
};
|
@ -9,17 +9,17 @@ import User from "./user.png";
|
||||
import CloseIcon from "./close.svg";
|
||||
import Menu from "@material-ui/core/Menu";
|
||||
import MenuItem from "@material-ui/core/MenuItem";
|
||||
import { Profile } from "../Profile";
|
||||
|
||||
interface TopBarProps {
|
||||
handleTransfer: (e: React.MouseEvent) => void;
|
||||
onLangChange: (lang:boolean) => void;
|
||||
textChangeHandler: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
||||
onLangChange: (lang: boolean) => void;
|
||||
textChangeHandler: (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
|
||||
}
|
||||
|
||||
interface TopBarState {
|
||||
isOpenProfile: boolean;
|
||||
anchorEl: HTMLElement | null;
|
||||
isPolish: boolean;
|
||||
anchorEl: HTMLElement | null;
|
||||
}
|
||||
|
||||
export default class TopBar extends React.Component<TopBarProps, TopBarState> {
|
||||
@ -30,13 +30,12 @@ export default class TopBar extends React.Component<TopBarProps, TopBarState> {
|
||||
this.onLangChange = this.onLangChange.bind(this);
|
||||
this.handleTransfer = this.handleTransfer.bind(this);
|
||||
this.state = {
|
||||
isOpenProfile: false,
|
||||
anchorEl:null,
|
||||
isPolish:true,
|
||||
isPolish: true,
|
||||
anchorEl: null,
|
||||
};
|
||||
}
|
||||
|
||||
handleChange(e: React.ChangeEvent<HTMLInputElement>) {
|
||||
handleChange(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) {
|
||||
this.props.textChangeHandler(e);
|
||||
}
|
||||
|
||||
@ -46,21 +45,20 @@ export default class TopBar extends React.Component<TopBarProps, TopBarState> {
|
||||
|
||||
onLangChange(e: React.MouseEvent) {
|
||||
this.setState({
|
||||
isPolish:!this.state.isPolish,
|
||||
})
|
||||
isPolish: !this.state.isPolish,
|
||||
});
|
||||
this.props.onLangChange(this.state.isPolish);
|
||||
}
|
||||
|
||||
handleProfile(e: React.MouseEvent) {
|
||||
handleProfile(event: React.MouseEvent<HTMLImageElement>) {
|
||||
this.setState({
|
||||
isOpenProfile: !this.state.isOpenProfile,
|
||||
anchorEl:e.currentTarget as HTMLElement,
|
||||
anchorEl: event.currentTarget,
|
||||
});
|
||||
}
|
||||
|
||||
handleClose(e: React.MouseEvent) {
|
||||
handleClose() {
|
||||
this.setState({
|
||||
isOpenProfile: !this.state.isOpenProfile,
|
||||
anchorEl: null,
|
||||
});
|
||||
}
|
||||
|
||||
@ -68,11 +66,7 @@ export default class TopBar extends React.Component<TopBarProps, TopBarState> {
|
||||
return (
|
||||
<div className="top-bar">
|
||||
<div className="top-bar__logo">
|
||||
<img
|
||||
className="top-bar__logo-image"
|
||||
alt="logo"
|
||||
src="https://plannaplan.pl/img/logo.svg"
|
||||
/>
|
||||
<img className="top-bar__logo-image" alt="logo" src="https://plannaplan.pl/img/logo.svg" />
|
||||
<div className="top-bar__tekst"> plan na plan </div>
|
||||
</div>
|
||||
<div className="top-bar__input-div">
|
||||
@ -81,43 +75,20 @@ export default class TopBar extends React.Component<TopBarProps, TopBarState> {
|
||||
placeholder="Wyszukaj..."
|
||||
inputProps={{ "aria-label": "description" }}
|
||||
className="top-bar__input-field"
|
||||
onChange={(e) =>
|
||||
this.handleChange(e as ChangeEvent<HTMLInputElement>)
|
||||
}
|
||||
onChange={(e) => this.handleChange(e)}
|
||||
/>
|
||||
<img className="top-bar__input-icon" alt="close" src={CloseIcon} />
|
||||
</div>
|
||||
<div className="top-bar__icon-box">
|
||||
<img
|
||||
className="top-bar__icon"
|
||||
alt="transfer"
|
||||
src={Transfer}
|
||||
onClick={this.handleTransfer}
|
||||
/>
|
||||
<img className="top-bar__icon" alt="transfer" src={Transfer} onClick={this.handleTransfer} />
|
||||
<img
|
||||
className="top-bar__icon"
|
||||
alt="change_language"
|
||||
src={this.state.isPolish ? UK : PL}
|
||||
onClick={this.onLangChange}
|
||||
/>
|
||||
<img
|
||||
className="top-bar__icon"
|
||||
alt="profile"
|
||||
src={User}
|
||||
onClick={this.handleProfile}
|
||||
/>
|
||||
<Menu
|
||||
className="top-bar__menu"
|
||||
id="simple-menu"
|
||||
anchorEl={this.state.anchorEl}
|
||||
keepMounted
|
||||
open={this.state.isOpenProfile}
|
||||
onClose={this.handleClose}
|
||||
>
|
||||
<MenuItem>Profile</MenuItem>
|
||||
<MenuItem>My account</MenuItem>
|
||||
<MenuItem>Logout</MenuItem>
|
||||
</Menu>
|
||||
<img className="top-bar__icon" alt="profile" src={User} onClick={this.handleProfile} />
|
||||
<Profile anchorEl={this.state.anchorEl} handleClose={this.handleClose} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user