This repository has been archived by the owner on May 12, 2023. It is now read-only.
-
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.
feat: created my profile side panel (#29)
* feat: created my profile side panel * fix: adjusting code smells * fix: fixing lint error * fix: adjust user info, no mock data necessary
- Loading branch information
Showing
12 changed files
with
311 additions
and
19 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,18 @@ | ||
import React from 'react'; | ||
|
||
import './style.css'; | ||
import emptyUser from '../../mock-data/img/EmptyUser.jpg'; | ||
|
||
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
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
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,72 @@ | ||
import React from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import { | ||
SideNavLink | ||
} from '@carbon/react'; | ||
import * as Icons from '@carbon/icons-react'; | ||
|
||
import KeycloakService from '../../service/KeycloakService'; | ||
|
||
import AvatarImage from '../AvatarImage'; | ||
import PanelSectionName from '../PanelSectionName'; | ||
|
||
import AccountOptions from '../../mock-data/AccountOptions'; | ||
|
||
import './style.scss'; | ||
|
||
const MyProfile = () => { | ||
const userData = KeycloakService.getUser(); | ||
|
||
const navigate = useNavigate(); | ||
|
||
const goTo = React.useCallback((url: string) => { | ||
navigate(url); | ||
}, []); | ||
|
||
const goOut = React.useCallback(() => { | ||
navigate('/logout'); | ||
}, []); | ||
|
||
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> | ||
<PanelSectionName title="Change account" /> | ||
{AccountOptions.map((option) => { | ||
const IconComponent = Icons[option.icon]; | ||
return ( | ||
<SideNavLink | ||
key={option.header} | ||
renderIcon={IconComponent || ''} | ||
onClick={goTo(option.url)} | ||
> | ||
{option.header} | ||
</SideNavLink> | ||
); | ||
})} | ||
<PanelSectionName title="Options" /> | ||
<SideNavLink | ||
renderIcon={Icons.UserFollow} | ||
onClick={goOut} | ||
> | ||
Sign 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
@use '../../theme/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; | ||
} |
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,7 @@ | ||
import React from 'react'; | ||
|
||
const NotificationsCentral = () => ( | ||
<span> Placeholder </span> | ||
); | ||
|
||
export default NotificationsCentral; |
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 @@ | ||
import React from 'react'; | ||
|
||
import { IconButton } from '@carbon/react'; | ||
import { Settings, Close } from '@carbon/icons-react'; | ||
|
||
import './styles.css'; | ||
|
||
interface RightPanelTitleProps { | ||
title: string; | ||
closeFn: Function; | ||
} | ||
|
||
const RightPanelTitle = ({ title, closeFn }: RightPanelTitleProps) => ( | ||
<div className="title-section"> | ||
<h4> | ||
{title} | ||
</h4> | ||
<div className="title-buttons"> | ||
<IconButton kind="ghost" label="Settings" align="bottom"> | ||
<Settings /> | ||
</IconButton> | ||
<IconButton kind="ghost" label="Close" onClick={closeFn} align="bottom"> | ||
<Close /> | ||
</IconButton> | ||
</div> | ||
</div> | ||
); | ||
|
||
export default RightPanelTitle; |
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,6 @@ | ||
.title-section { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: 1rem; | ||
} |
Oops, something went wrong.