Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e5f1fc0
Merge branch 'master' into PLAT-754_tools-config
brooketopcoder Mar 11, 2022
ddad763
PLAT-754 #comment remove commented out tests #time 5m
brooketopcoder Mar 11, 2022
0687f21
PLAT-802 #comment create profile util;
brooketopcoder Mar 11, 2022
9d38a6c
PLAT-825 #comment fix profile styling;
brooketopcoder Mar 14, 2022
20411b1
Merge branch 'PLAT-802_profile-util' into PLAT-825_form-text-fields
brooketopcoder Mar 14, 2022
6373d82
PLAT-825 #comment consolidate font styles; #time 1h
brooketopcoder Mar 14, 2022
3beac2d
PLAT-828 #comment create button component;
brooketopcoder Mar 14, 2022
9d0dc29
PLAT-825 Form Text Fields & Profile - PLAT-802_profile-util (#46)
brooketopcoder Mar 15, 2022
63b1c87
PLAT-828 #comment use axios for xhr;
brooketopcoder Mar 15, 2022
353f0d4
PLAT-828 #comment rename all services to
brooketopcoder Mar 15, 2022
2738b0e
PLAT-828 #comment add update password functions
brooketopcoder Mar 15, 2022
40f51dd
Merge branch 'PLAT-802_profile-util' into PLAT-828_profile-api
brooketopcoder Mar 15, 2022
a5288a7
PLAT-828 #comment clean-up #time 5m
brooketopcoder Mar 15, 2022
da90fd6
PLAT-828 #comment clean-up #time 10m
brooketopcoder Mar 16, 2022
322f729
PLAT-828 #comment use v3 api for pw change
brooketopcoder Mar 16, 2022
3d1e645
PLAT-828 profile api to PLAT-802_profile-util (#50)
brooketopcoder Mar 16, 2022
29b6408
Merge branch 'PLAT-802_profile-util' into PLAT-826_validation
brooketopcoder Mar 16, 2022
cd5d848
PLAT-826 #comment reset pw fields upon submission
brooketopcoder Mar 16, 2022
07a211a
PLAT-826 #comment permit buttons
brooketopcoder Mar 16, 2022
dce60af
PLAT-826 #comment support for fields
brooketopcoder Mar 16, 2022
4e36e0a
PLAT-826 #comment clean-up #time 10m
brooketopcoder Mar 16, 2022
71a7cec
PLAT-826 #comment clean-up #time 5m
brooketopcoder Mar 16, 2022
b2a1f53
PLAT-826 #comment merge dev #time 10m
brooketopcoder Mar 16, 2022
da04ba1
Merge branch 'dev' into PLAT-826_temp-dev
brooketopcoder Mar 16, 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
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"dependencies": {
"@datadog/browser-logs": "^4.5.0",
"@heroicons/react": "^1.0.6",
"axios": "^0.26.1",
"browser-cookies": "^1.2.0",
"classnames": "^2.3.1",
"react": "^17.0.2",
Expand Down Expand Up @@ -51,6 +52,7 @@
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.0.0",
"@testing-library/user-event": "^13.2.1",
"@types/axios": "^0.14.0",
"@types/jest": "^27.0.1",
"@types/node": "^16.7.13",
"@types/react": "^17.0.20",
Expand Down
6 changes: 3 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { Route, Routes } from 'react-router-dom'

import { EnvironmentConfig } from './config'
import { Header } from './header'
import { AnalyticsService, LoggingService, ProfileProvider } from './lib'
import { initializeAnalytics, initializeLogger, ProfileProvider } from './lib'
import { RouteContext, RouteContextData } from './lib/route-provider'

new AnalyticsService().initialize(EnvironmentConfig)
new LoggingService().initialize(EnvironmentConfig)
initializeAnalytics(EnvironmentConfig)
initializeLogger(EnvironmentConfig)

const App: FC<{}> = () => {

Expand Down
1 change: 1 addition & 0 deletions src/config/environments/environment.default.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AppHostEnvironment } from './app-host-environment.enum'

export const EnvironmentConfigDefault: GlobalConfig = {
API: {
V3: 'https://api.topcoder-dev.com/v3',
V5: 'https://api.topcoder-dev.com/v5',
},
ENV: AppHostEnvironment.default,
Expand Down
1 change: 1 addition & 0 deletions src/config/environments/environment.prod.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { EnvironmentConfigDefault } from './environment.default.config'
export const EnvironmentConfigProd: GlobalConfig = {
...EnvironmentConfigDefault,
API: {
V3: 'https://api.topcoder.com/v3',
V5: 'https://api.topcoder.com/v5',
},
ENV: AppHostEnvironment.prod,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$overlaySquare: calc($pad-xxxxl + 2 * $border);

.profile-avater,
.profile-avatar,
.overlay {
cursor: pointer;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Dispatch, FC, SetStateAction, useContext, useState } from 'react'

import { Avatar, IconOutline, LoggingService, ProfileContext, ProfileContextData } from '../../../../../lib'
import { Avatar, IconOutline, logInfo , ProfileContext, ProfileContextData } from '../../../../../lib'

import { ProfilePanel } from './profile-panel'
import styles from './ProfileLoggedIn.module.scss'
Expand All @@ -9,10 +9,9 @@ const ProfileLoggedIn: FC<{}> = () => {

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

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

Expand All @@ -22,7 +21,7 @@ const ProfileLoggedIn: FC<{}> = () => {

return (
<>
<div className={styles['profile-avater']} onClick={() => toggleProfilePanel()} >
<div className={styles['profile-avatar']} onClick={() => toggleProfilePanel()} >
<Avatar
firstName={profile.firstName}
lastName={profile.lastName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { FC, useContext } from 'react'
import { Link } from 'react-router-dom'

import {
AuthenticationUrlConfig,
logoutUrl,
ProfileContext,
ProfileContextData,
ProfileRouteConfig,
profileRoute,
} from '../../../../../../lib'

import styles from './ProfilePanel.module.scss'
Expand All @@ -31,11 +31,11 @@ const ProfilePanel: FC<ProfilePanelProps> = (props: ProfilePanelProps) => {
<Link
className={styles.profile}
onClick={() => props.toggleProfilePanel()}
to={ProfileRouteConfig.profile}
to={profileRoute}
>
My Profile
</Link>
<a href={AuthenticationUrlConfig.logout} className={styles.logout}>
<a href={logoutUrl} className={styles.logout}>
Log Out
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
import classNames from 'classnames'
import { FC } from 'react'

import { AuthenticationUrlConfig, routeRoot } from '../../../../../lib'
import { Button, loginUrl, routeRoot, signupUrl } from '../../../../../lib'
import '../../../../../lib/styles/index.scss'

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

const ProfileNotLoggedIn: FC<{}> = () => {

const buttonClass: string = 'button'

return (
<>
<a
className={classNames(buttonClass, styles.login)}
href={AuthenticationUrlConfig.login(routeRoot)}
>
Log In
</a>
<a
className={classNames(buttonClass, 'all-white', styles.signup)}
href={AuthenticationUrlConfig.signup(routeRoot)}
>
Sign Up
</a>
<Button
className={styles.login}
label='Log In'
size='sm'
buttonStyle='text'
url={loginUrl(routeRoot)}
/>
<Button
className={styles.signup}
label='Sign Up'
size='sm'
buttonStyle='tertiary'
url={signupUrl(routeRoot)}
/>
</>
)
}
Expand Down
52 changes: 52 additions & 0 deletions src/lib/button/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import classNames from 'classnames'
import { FC } from 'react'

interface ButtonProps {
readonly buttonStyle?: 'primary' | 'secondary' | 'tertiary' | 'text'
readonly className?: string
readonly disable?: boolean
readonly label: string
readonly onClick?: (event?: any) => void
readonly size?: 'sm' | 'md' | 'lg' | 'xl'
readonly type?: 'button' | 'submit'
readonly url?: string
}

const Button: FC<ButtonProps> = (props: ButtonProps) => {

const classes: string = classNames(
'button',
props.className,
props.buttonStyle || 'primary',
`button-${props.size || 'md'}`
)

// if there is a url, this is a link button
if (!!props.url) {
return (
<a
className={classes}
href={props.url}
>
{props.label}
</a>
)
}

// if there is no click handler, the button is prob a submit
// button, so just add a blank click handler
const clickHandler: (event: any) => void = props.onClick || (() => undefined)

return (
<button
className={classes}
disabled={!!props.disable}
onClick={event => clickHandler(event)}
type={props.type || 'button'}
>
{props.label}
</button>
)
}

export default Button
6 changes: 6 additions & 0 deletions src/lib/button/Buttons.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import '@testing-library/jest-dom'

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

test('it should render the content', () => { })
})
1 change: 1 addition & 0 deletions src/lib/button/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Button } from './Button'
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
@import '../../styles';

$form-pad-top: calc($pad-md - $border);
$border-xs: 1px;
$error-line-height: 14px;

.form-field-wrapper {
position: relative;
display: flex;
flex-direction: column;
justify-content: flex-start;
padding-bottom: $pad-md;

.form-field {
display: flex;
flex-direction: column;
align-items: flex-start;
padding: $pad-sm $form-pad-top;
height: calc($pad-xxl * 2);
background: $tc-white;
border: $border-xs solid $black-40;
box-sizing: border-box;
border-radius: $pad-xs;
margin-bottom: calc($error-line-height + $pad-xs);

&:hover,
&.focus {
border-color: $turq-160;

&.form-field-error {
border-color: $red-100;
}
}

&.focus,
&.form-field-error {
border-width: $border;
padding: calc($pad-sm - $border-xs) calc($form-pad-top - $border-xs);
}

&.disabled {
background-color: $black-10;
background: $black-10;
border-color: $black-40;
}

&.form-field-error {
border-color: $red-100;
margin-bottom: 0;

.label {
color: $red-100;
}
}

.label {
top: calc(50% - $form-pad-top/2);
color: $turq-160;
margin-bottom: $pad-xs;
// extend ultra-small and override some properties
@extend .ultra-small;
@include font-weight-medium;
line-height: calc($pad-md - $border);
font-style: normal;
}
}

.error {
display: flex;
align-items: center;
color: $red-100;
// extend body ultra small and override it
@extend .body-ultra-small;
line-height: $error-line-height;
margin-top: $pad-xs;

svg {
@include icon-md;
fill: $red-100;
margin-right: $pad-xs;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import '@testing-library/jest-dom'

describe('<FormFieldWrapper /> ', () => {

test('it should display the FormField', () => {})
})
53 changes: 53 additions & 0 deletions src/lib/form-elements/form-field-wrapper/Form-Field-Wrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import classNames from 'classnames'
import { Dispatch, FC, ReactNode, SetStateAction, useState } from 'react'

import { IconSolid } from '../../svgs'

import styles from './Form-Field-Wrapper.module.scss'

interface FormFieldWrapperProps {
children: ReactNode
disabled: boolean
error?: string
label: string
name: string
}

const FormFieldWrapper: FC<FormFieldWrapperProps> = (props: FormFieldWrapperProps) => {

const [focusStyle, setFocusStyle]: [string | undefined, Dispatch<SetStateAction<string | undefined>>] = useState<string | undefined>()
const formFieldClasses: string = classNames(
styles['form-field'],
props.disabled ? styles.disabled : undefined,
focusStyle,
!!props.error ? styles['form-field-error'] : undefined
)

return (
<div className={styles['form-field-wrapper']}>

<div
className={formFieldClasses}
onBlur={() => setFocusStyle(undefined)}
onFocus={() => setFocusStyle(styles.focus)}
>
<label
className={styles.label}
role='presentation'
>
{props.label}
{props.children}
</label>
</div>

{!!props.error && (
<div className={styles.error}>
<IconSolid.ExclamationIcon />
{props.error}
</div>
)}
</div>
)
}

export default FormFieldWrapper
1 change: 1 addition & 0 deletions src/lib/form-elements/form-field-wrapper/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as FormFieldWrapper } from './Form-Field-Wrapper'
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { TextInputModel } from './text-input.model'

export interface FormDefinition {
[input: string]: TextInputModel
}
Loading