From 77ac7a0f1600679a5768abbc55ccbf6831dd9f40 Mon Sep 17 00:00:00 2001 From: mattyl006 Date: Tue, 30 Aug 2022 14:48:08 +0200 Subject: [PATCH] LoggedBar component --- src/App.js | 12 ++++- src/assets/user_ico.svg | 3 ++ src/components/elements/LoggedBar.js | 62 ++++++++++++++++++++++++ src/components/elements/NavBar/NavBar.js | 11 ++--- 4 files changed, 80 insertions(+), 8 deletions(-) create mode 100644 src/assets/user_ico.svg create mode 100644 src/components/elements/LoggedBar.js diff --git a/src/App.js b/src/App.js index d5a32e8..d8e5416 100644 --- a/src/App.js +++ b/src/App.js @@ -12,12 +12,22 @@ import Login from './pages/auth/Login'; import LoginWithEmail from './pages/auth/LoginWithEmail'; import RegisterWithEmail from './pages/auth/RegisterWithEmail'; import KeyCloakService from './services/KeyCloakService'; +import React from 'react'; +import LoggedBar from './components/elements/LoggedBar'; const App = () => { + const [loggedBarVisible, setLoggedBarVisible] = React.useState(false); + + const loggedBarVisibleHandler = () => { + let newLoggedBarVisible = !loggedBarVisible; + setLoggedBarVisible(newLoggedBarVisible); + }; + return ( - + + }/> }/> diff --git a/src/assets/user_ico.svg b/src/assets/user_ico.svg new file mode 100644 index 0000000..a784ff0 --- /dev/null +++ b/src/assets/user_ico.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/components/elements/LoggedBar.js b/src/components/elements/LoggedBar.js new file mode 100644 index 0000000..2fcac1c --- /dev/null +++ b/src/components/elements/LoggedBar.js @@ -0,0 +1,62 @@ +import React from 'react'; +import {Container, FlexColumn, FlexRow, Svg} from '../../utils/containers'; +import {Body, H3} from '../../utils/fonts'; +import theme from '../../utils/theme'; +import userIco from '../../assets/user_ico.svg'; +import KeyCloakService from '../../services/KeyCloakService'; +import loginIco from '../../assets/login_ico.svg'; +import styled from 'styled-components'; + +const LoggedBarStyle = styled(FlexColumn)` + width: 260px; + height: calc(100vh - 48px); + position: fixed; + top: 48px; + right: 0; + align-items: flex-start; + justify-content: flex-start; + background-color: ${({theme}) => theme.colors.white}; + box-shadow: ${({theme}) => theme.shadow}; + z-index: 3; + + button { + cursor: pointer; + + * { + cursor: pointer; + } + } +`; + +const LoggedBar = (props) => { + if (props.visible) { + return ( + + + +

+ {props.username} +

+
+ + + + + + Profile + + + + + + Sign out + + + +
+ ); + } +}; + +export default LoggedBar; \ No newline at end of file diff --git a/src/components/elements/NavBar/NavBar.js b/src/components/elements/NavBar/NavBar.js index a6215eb..de7929d 100644 --- a/src/components/elements/NavBar/NavBar.js +++ b/src/components/elements/NavBar/NavBar.js @@ -6,6 +6,7 @@ import menuButtonIcon from '../../../assets/menu-button.svg'; import MobileNavMenu from '../MobileNavMenu'; import {Link} from 'react-router-dom'; import loginIco from '../../../assets/login_ico.svg'; +import userIco from '../../../assets/user_ico.svg'; import {Menu} from '../../../utils/fonts'; import registerIco from '../../../assets/register_ico.svg'; import {CHALLENGES_PAGE} from '../../../utils/globals'; @@ -28,7 +29,7 @@ const MenuButton = styled(Container)` } `; -const NavBar = () => { +const NavBar = (props) => { const [navMenuTranslateY, setNavMenuTranslateY] = React.useState('calc(-100vh - 42px)'); const toggleNavMenu = () => { @@ -58,12 +59,8 @@ const NavBar = () => { : ''} {KeyCloakService.isLoggedIn() ? - - - - Sign out - - : + :