Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
13b9d4d
PROD-1075 #comment remove settings;
brooketopcoder Mar 28, 2022
fcb2e17
PROD-1075 #comment remove more sections #time 5m
brooketopcoder Mar 28, 2022
b850cf9
PROD-1075 #comment remove content
brooketopcoder Mar 29, 2022
6e97d87
PROD-1075 #comment settings
brooketopcoder Mar 29, 2022
2252d36
PROD-1075 #comment clean-up #time 5m
brooketopcoder Mar 29, 2022
7af74ba
PROD-1075 #comment profile settings
brooketopcoder Mar 29, 2022
37b6b7b
PROD-1075 #comment update layout; #time 3h
brooketopcoder Mar 30, 2022
80dfff4
PROD-1075 #comment clean-up #time 5m
brooketopcoder Mar 30, 2022
d74be3f
PROD-1075 #comment PR comments #time 10m
brooketopcoder Mar 30, 2022
7541c8f
Merge pull request #74 from topcoder-platform/PROD-1075_header-layout
testflyjets Mar 30, 2022
9b55a02
PROD-1070 #comment profile settings bg #time 10m
brooketopcoder Mar 30, 2022
5a3b7e6
PROD-1070 #comment add support for link buttons;
brooketopcoder Mar 30, 2022
0bdce65
PROD-1070 #comment change card title
brooketopcoder Mar 30, 2022
6183a56
PROD-1070 #comment button clean-up;
brooketopcoder Mar 30, 2022
9b4cbe5
PROD-1070 #comment modals; update profile
brooketopcoder Mar 30, 2022
062f74f
PROD-1070 clean-up #time 5m
brooketopcoder Mar 30, 2022
e54cc80
PROD-1111 #comment create card component;
brooketopcoder Mar 31, 2022
74abe22
PROD-1111 #comment clean-up #time 5m
brooketopcoder Mar 31, 2022
f6495d1
Merge pull request #76 from topcoder-platform/PROD-1070_restyle-settings
testflyjets Mar 31, 2022
3c96478
PROD-1086 #comment determine if a component
brooketopcoder Mar 31, 2022
80842b8
Merge pull request #78 from topcoder-platform/PROD-1111_cards
testflyjets Mar 31, 2022
bee73ac
PROD-1086 #comment clean-up #time 5mn
brooketopcoder Mar 31, 2022
a40852a
Merge pull request #79 from topcoder-platform/PROD-1086_click-outside
testflyjets Mar 31, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-gtm-module": "^2.0.11",
"react-responsive-modal": "^6.2.0",
"react-router-dom": "^6.2.1",
"react-scripts": "5.0.0",
"react-toastify": "^8.2.0",
Expand Down
1 change: 1 addition & 0 deletions src/config/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const SETTINGS_TITLE: string = 'Profile Settings'
1 change: 1 addition & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './constants'
export * from './environments'
4 changes: 4 additions & 0 deletions src/header/Header.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@
@include xl {
grid-template-columns: $left-col-width-xl 1fr auto;
}

@include xxl {
grid-template-columns: $left-col-width-xl 1fr auto;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { FC, useContext } from 'react'

import { SETTINGS_TITLE } from '../../../../config'
import { profileContext, ProfileContextData } from '../../../../lib'
import '../../../../lib/styles/index.scss'

Expand All @@ -23,7 +24,7 @@ const ProfileSelector: FC<{}> = () => {
return (
<div className={styles['profile-selector']}>
{!isLoggedIn && <ProfileNotLoggedIn />}
{isLoggedIn && <ProfileLoggedIn />}
{isLoggedIn && <ProfileLoggedIn settingsTitle={SETTINGS_TITLE} />}
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,73 @@ import { Dispatch, FC, SetStateAction, useContext, useState } from 'react'

import {
Avatar,
ComponentVisible,
IconOutline,
logInfo,
profileContext,
ProfileContextData,
useHideClickOutside,
} from '../../../../../lib'

import { ProfilePanel } from './profile-panel'
import styles from './ProfileLoggedIn.module.scss'

const ProfileLoggedIn: FC<{}> = () => {
interface ProfileLoggedInProps {
settingsTitle: string
}

const ProfileLoggedIn: FC<ProfileLoggedInProps> = (props: ProfileLoggedInProps) => {

const { profile }: ProfileContextData = useContext(profileContext)
const [profilePanelOpen, setProfilePanelOpen]: [boolean, Dispatch<SetStateAction<boolean>>] = useState<boolean>(false)

const {
isComponentVisible,
ref,
setIsComponentVisible,
}: ComponentVisible = useHideClickOutside(false)

if (!profile) {
logInfo('tried to render the logged in profile w/out a profile')
return <></>
}

function toggleProfilePanel(): void {
setProfilePanelOpen(!profilePanelOpen)
const toggleTo: boolean = !profilePanelOpen
setProfilePanelOpen(toggleTo)
setIsComponentVisible(toggleTo)
}

if (!isComponentVisible && profilePanelOpen) {
setProfilePanelOpen(isComponentVisible)
}

return (
<>
<div className={styles['profile-avatar']} onClick={() => toggleProfilePanel()} >
<div
className={styles['profile-avatar']}
onClick={toggleProfilePanel}
>
<Avatar
firstName={profile.firstName}
lastName={profile.lastName}
handle={profile.handle}
photoUrl={profile.photoURL}
size='sm'
/>
{profilePanelOpen && (
<div className={styles.overlay}>
<IconOutline.XIcon />
</div>
)}
</div>
{profilePanelOpen && <ProfilePanel toggleProfilePanel={toggleProfilePanel} />}
{profilePanelOpen && (
<ProfilePanel
refObject={ref}
settingsTitle={props.settingsTitle}
toggleProfilePanel={toggleProfilePanel}
/>
)}
</>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, useContext } from 'react'
import { FC, MutableRefObject, useContext } from 'react'
import { Link } from 'react-router-dom'

import {
Expand All @@ -12,32 +12,35 @@ import {
import styles from './ProfilePanel.module.scss'

interface ProfilePanelProps {
refObject: MutableRefObject<any>
settingsTitle: string
toggleProfilePanel: () => void
}

const ProfilePanel: FC<ProfilePanelProps> = (props: ProfilePanelProps) => {

const { profile }: ProfileContextData = useContext(profileContext)
const { getPath }: RouteContextData = useContext(routeContext)
const { getPath }: RouteContextData = useContext(routeContext)

if (!profile) {
// this should never happen
return <></>
}

const settingsTitle: string = 'Settings'

return (
<div className={styles['profile-panel']}>
<div
className={styles['profile-panel']}
ref={props.refObject}
>
<div className={styles.handle}>
{profile.handle}
</div>
<Link
className={styles.profile}
onClick={() => props.toggleProfilePanel()}
to={getPath(settingsTitle)}
to={getPath(props.settingsTitle)}
>
{settingsTitle}
{props.settingsTitle}
</Link>
<a href={authUrlLogout} className={styles.logout}>
Log Out
Expand Down
42 changes: 36 additions & 6 deletions src/lib/avatar/Avatar.module.scss
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
@import '../../lib/styles';

$avatar-size: 32px;
$avatar-size-sm: 32px;
$border-size-sm: $border;
$avatar-size-xl: 120px;
$border-size-xl: $pad-xs;

.avatar-container {
overflow: hidden;
background-color: $tc-white;
border-radius: 50%;
height: 36px;

&.sm {
height: calc($avatar-size-sm + 2 * $border-size-sm);
width: calc($avatar-size-sm + 2 * $border-size-sm);
}

&.xl {
height: calc($avatar-size-xl + 2 * $border-size-xl);
width: calc($avatar-size-xl + 2 * $border-size-xl);
}

.avatar {
height: $avatar-size;
width: $avatar-size;
background-color: $tc-white;
border-radius: 50%;
border: 2px solid $tc-white;
border: solid $tc-white;

&.sm {
border-width: $border-size-sm;
height: $avatar-size-sm;
width: $avatar-size-sm;
}

&.xl {
border-width: $border-size-xl;
height: $avatar-size-xl;
width: $avatar-size-xl;
}
}

.avatar-letters {
Expand All @@ -24,6 +46,14 @@ $avatar-size: 32px;
color: $tc-white;
background-color: $blue-100;
@include font-weight-medium;
@extend .medium-subtitle;

&.sm {
@extend .medium-subtitle;
}

&.xl {
@extend h1;
padding: 0;
}
}
}
12 changes: 9 additions & 3 deletions src/lib/avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { FC } from 'react'
import styles from './Avatar.module.scss'

interface AvatarProps {
containerClass?: string
firstName?: string
handle?: string
lastName?: string
photoUrl?: string
size: 'sm' | 'xl'
}

const Avatar: FC<AvatarProps> = (props: AvatarProps) => {
Expand All @@ -19,17 +21,21 @@ const Avatar: FC<AvatarProps> = (props: AvatarProps) => {

const avatarElement: JSX.Element = !!props.photoUrl
? (
<img src={props.photoUrl} alt={`${props.handle} avatar`} className={styles.avatar} />
<img
alt={`${props.handle} avatar`}
className={classNames(styles.avatar, styles[props.size])}
src={props.photoUrl}
/>
)
: (
<span className={classNames(styles.avatar, styles['avatar-letters'])}>
<span className={classNames(styles.avatar, styles['avatar-letters'], styles[props.size])}>
{props.firstName?.charAt(0)}
{props.lastName?.charAt(0)}
</span>
)

return (
<div className={styles['avatar-container']}>
<div className={classNames(styles['avatar-container'], styles[props.size], props.containerClass)}>
{avatarElement}
</div>
)
Expand Down
39 changes: 38 additions & 1 deletion src/lib/button/Button.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
line-height: 24px;

&:focus {
outline: 2px solid $turq-140;
outline: $border solid $turq-140;
}

&.button-sm {
Expand Down Expand Up @@ -98,6 +98,43 @@
}
}

&.link {
margin: 0;
padding: 0;
display: flex;
align-items: center;
font-size: 16px;
color: $turq-160;
background-color: $tc-white;
border: none;
outline: none;
border-radius: 0;

&:focus {
outline: $border solid $turq-140;
}

&:hover {
color: $turq-120;
}

&:active {
color: $turq-180;
}

&.disabled {
color: $black-60;
background-color: $tc-white;
border-color: $black-5;
}

svg {
margin-left: $pad-xs;
height: $pad-lg;
width: $pad-lg;
}
}

&.text {
border-color: transparent;
}
Expand Down
5 changes: 4 additions & 1 deletion src/lib/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import classNames from 'classnames'
import { FC } from 'react'
import { Link } from 'react-router-dom'

import { IconOutline } from '../svgs'

import styles from './Button.module.scss'

export type ButtonSize = 'sm' | 'md' | 'lg' | 'xl'
export type ButtonStyle = 'primary' | 'secondary' | 'tertiary' | 'text'
export type ButtonStyle = 'link' | 'primary' | 'secondary' | 'tertiary' | 'text'
export type ButtonType = 'button' | 'submit'

export interface ButtonProps {
Expand Down Expand Up @@ -61,6 +63,7 @@ const Button: FC<ButtonProps> = (props: ButtonProps) => {
type={props.type || 'button'}
>
{props.label}
{props.buttonStyle === 'link' && <IconOutline.ArrowRightIcon />}
</button>
)
}
Expand Down
21 changes: 21 additions & 0 deletions src/lib/card/Card.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@import '../styles';

.card {
padding: $pad-lg $pad-lg $pad-xxxxl $pad-lg;
border: solid $border-xs $black-10;
border-radius: $pad-sm;

.card-title {
@include font-weight-semi-bold;
@include font-barlow;
text-transform: uppercase;
display: flex;
justify-content: space-between;
margin-bottom: $pad-xl;

svg {
height: $pad-xl;
width: $pad-xl;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '@testing-library/jest-dom'

describe('<Button />', () => {
describe('<Card />', () => {

test('it should render the content', () => { })
})
Loading