From a4ada5fb792a37c57f905edfbf1f018bff5e11bb Mon Sep 17 00:00:00 2001 From: maciekglowacki Date: Wed, 10 Jun 2020 21:40:33 +0200 Subject: [PATCH] Added profile component --- src/components/Profile/index.scss | 0 src/components/Profile/index.tsx | 27 +++++ src/components/TopBar/index.tsx | 169 +++++++++++++----------------- 3 files changed, 97 insertions(+), 99 deletions(-) create mode 100644 src/components/Profile/index.scss create mode 100644 src/components/Profile/index.tsx diff --git a/src/components/Profile/index.scss b/src/components/Profile/index.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/components/Profile/index.tsx b/src/components/Profile/index.tsx new file mode 100644 index 0000000..8b0a920 --- /dev/null +++ b/src/components/Profile/index.tsx @@ -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 = ({anchorEl, handleClose, ...restProps}) => { + + return ( + + Profile + My account + Logout + + ); +}; diff --git a/src/components/TopBar/index.tsx b/src/components/TopBar/index.tsx index ac961a0..ed9e16b 100644 --- a/src/components/TopBar/index.tsx +++ b/src/components/TopBar/index.tsx @@ -9,117 +9,88 @@ 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) => void; + handleTransfer: (e: React.MouseEvent) => void; + onLangChange: (lang: boolean) => void; + textChangeHandler: (e: React.ChangeEvent) => void; } interface TopBarState { - isOpenProfile: boolean; - anchorEl: HTMLElement | null; - isPolish: boolean; + isPolish: boolean; + anchorEl: HTMLElement | null; } export default class TopBar extends React.Component { - constructor(props: TopBarProps) { - super(props); - this.handleProfile = this.handleProfile.bind(this); - this.handleClose = this.handleClose.bind(this); - this.onLangChange = this.onLangChange.bind(this); - this.handleTransfer = this.handleTransfer.bind(this); - this.state = { - isOpenProfile: false, - anchorEl:null, - isPolish:true, - }; - } + constructor(props: TopBarProps) { + super(props); + this.handleProfile = this.handleProfile.bind(this); + this.handleClose = this.handleClose.bind(this); + this.onLangChange = this.onLangChange.bind(this); + this.handleTransfer = this.handleTransfer.bind(this); + this.state = { + isPolish: true, + anchorEl: null, + }; + } - handleChange(e: React.ChangeEvent) { - this.props.textChangeHandler(e); - } + handleChange(e: React.ChangeEvent) { + this.props.textChangeHandler(e); + } - handleTransfer(e: React.MouseEvent) { - this.props.handleTransfer(e); - } + handleTransfer(e: React.MouseEvent) { + this.props.handleTransfer(e); + } - onLangChange(e: React.MouseEvent) { - this.setState({ - isPolish:!this.state.isPolish, - }) - this.props.onLangChange(this.state.isPolish); - } + onLangChange(e: React.MouseEvent) { + this.setState({ + isPolish: !this.state.isPolish, + }); + this.props.onLangChange(this.state.isPolish); + } - handleProfile(e: React.MouseEvent) { - this.setState({ - isOpenProfile: !this.state.isOpenProfile, - anchorEl:e.currentTarget as HTMLElement, - }); - } + handleProfile(event: React.MouseEvent) { + this.setState({ + anchorEl: event.currentTarget, + }); + } - handleClose(e: React.MouseEvent) { - this.setState({ - isOpenProfile: !this.state.isOpenProfile, - }); - } + handleClose() { + this.setState({ + anchorEl: null, + }); + } - render() { - return ( -
-
- logo -
plan na plan
-
-
- search - - this.handleChange(e as ChangeEvent) - } - /> - close -
-
- transfer - change_language - profile - - Profile - My account - Logout - -
-
- ); - } + render() { + return ( +
+
+ logo +
plan na plan
+
+
+ search + this.handleChange(e)} + /> + close +
+
+ transfer + change_language + profile + +
+
+ ); + } }