generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the User Profile sidebar with test data and cleaned up the Dash…
…board (#78)
- Loading branch information
1 parent
bd79083
commit 70ad032
Showing
6 changed files
with
142 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.profile-image { | ||
border-radius: 50%; | ||
} | ||
|
||
.small { | ||
width: 1.5rem; | ||
height: 1.5rem; | ||
} | ||
|
||
.large { | ||
width: 4rem; | ||
height: 4rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
|
||
import emptyUser from '../../assets/img/emptyUser.jpg'; | ||
import './AvatarImage.scss'; | ||
|
||
type Size = 'small' | 'large'; | ||
|
||
interface AvatarImageProps { | ||
userName: string; | ||
source?: string; | ||
size: Size; | ||
} | ||
|
||
const AvatarImage = ({ userName, source, size }: AvatarImageProps) => ( | ||
<img src={source || emptyUser} alt={`${userName}`} className={`profile-image ${size}`} /> | ||
); | ||
|
||
export default AvatarImage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@use '@bcgov-nr/nr-fsa-theme/design-tokens/variables.scss' as vars; | ||
|
||
.user-info-section { | ||
padding: 1rem; | ||
display: flex; | ||
} | ||
|
||
.user-data { | ||
margin-left: 2rem; | ||
} | ||
|
||
.user-name { | ||
font-weight: bold; | ||
} | ||
|
||
.divisory { | ||
background-color: var(--#{vars.$bcgov-prefix}-border-subtle-01); | ||
border: 0; | ||
height: 1px; | ||
} | ||
|
||
.account-nav a { | ||
width: 100%; | ||
font-weight: bold; | ||
} | ||
|
||
.cursor-pointer { | ||
cursor: pointer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React, { useCallback, useState, useEffect } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import { | ||
SideNavLink | ||
} from '@carbon/react'; | ||
import * as Icons from '@carbon/icons-react'; | ||
|
||
|
||
import AvatarImage from '../AvatarImage'; | ||
|
||
import { useThemePreference } from '../../utils/ThemePreference'; | ||
|
||
import './MyProfile.scss'; | ||
import { logout } from '../../services/AuthService'; | ||
|
||
const MyProfile = () => { | ||
const { theme, setTheme } = useThemePreference(); | ||
const userData = {firstName:'Jazz', lastName:"Grewal", idirUsername:"Jasgrewal", email:"[email protected]"}; | ||
|
||
const [goToURL, setGoToURL] = useState<string>(''); | ||
const [goTo, setGoTo] = useState<boolean>(false); | ||
|
||
const navigate = useNavigate(); | ||
|
||
const changeTheme = () => { | ||
if (theme === 'g10') { | ||
setTheme('g100'); | ||
localStorage.setItem('mode', 'dark'); | ||
} | ||
if (theme === 'g100') { | ||
setTheme('g10'); | ||
localStorage.setItem('mode', 'light'); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
if (goTo) { | ||
setGoTo(false); | ||
navigate(goToURL); | ||
} | ||
}, [goTo]); | ||
|
||
return ( | ||
<> | ||
<div className="user-info-section"> | ||
<div className="user-image"> | ||
<AvatarImage userName={`${userData.firstName} ${userData.lastName}`} size="large" /> | ||
</div> | ||
<div className="user-data"> | ||
<p className="user-name">{`${userData.firstName} ${userData.lastName}`}</p> | ||
<p>{`IDIR: ${userData.idirUsername}`}</p> | ||
<p>{userData.email}</p> | ||
</div> | ||
</div> | ||
<hr className="divisory" /> | ||
<nav className="account-nav"> | ||
<ul> | ||
<SideNavLink | ||
className="cursor-pointer" | ||
renderIcon={theme === 'g10'?Icons.Asleep:Icons.Light} | ||
onClick={() => { changeTheme(); }} | ||
> | ||
Change theme | ||
</SideNavLink> | ||
<SideNavLink | ||
className="cursor-pointer" | ||
renderIcon={Icons.UserFollow} | ||
onClick={()=>{logout()}} | ||
> | ||
Log out | ||
</SideNavLink> | ||
</ul> | ||
</nav> | ||
</> | ||
); | ||
}; | ||
|
||
export default MyProfile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters