Skip to content

Commit fe6d5ba

Browse files
Merge pull request #405 from topcoder-platform/TCA-586_page-load-improvements
TCA-586 Page load improvements Part 2 -> dev
2 parents 0bb9c43 + 23ef630 commit fe6d5ba

File tree

81 files changed

+2278
-2403
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+2278
-2403
lines changed

src-ts/declarations.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ declare module '*.md' {
2929
const value: string
3030
export default value
3131
}
32+
33+
declare module '*.txt' {
34+
const value: string
35+
export default value
36+
}

src-ts/lib/modals/base-modal/BaseModal.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,47 @@
11
import classNames from 'classnames'
2-
import { FC } from 'react'
2+
import { FC, ReactNode } from 'react'
33
import Modal, { ModalProps } from 'react-responsive-modal'
44

5+
import { LoadingSpinner } from '../../loading-spinner'
56
import { IconOutline } from '../../svgs'
67

78
import styles from './BaseModal.module.scss'
9+
import { ModalContentResponse, useFetchModalContent } from './use-fetch-modal-content'
810

911
export interface BaseModalProps extends ModalProps {
12+
contentClassName?: string
13+
contentUrl?: string
1014
size?: 'lg' | 'md'
1115
title: string
1216
}
1317

1418
const BaseModal: FC<BaseModalProps> = ({
1519
children,
1620
title,
21+
contentUrl,
22+
contentClassName,
1723
...props
1824
}: BaseModalProps) => {
1925

26+
const { content }: ModalContentResponse = useFetchModalContent(contentUrl, props.open)
27+
28+
const renterContent: () => ReactNode = () => {
29+
if (children || !contentUrl) {
30+
return
31+
}
32+
33+
if (!content) {
34+
return <LoadingSpinner />
35+
}
36+
37+
return (
38+
<div
39+
className={contentClassName}
40+
dangerouslySetInnerHTML={{__html: content}}
41+
/>
42+
)
43+
}
44+
2045
return (
2146
<Modal
2247
{...props}
@@ -30,6 +55,7 @@ const BaseModal: FC<BaseModalProps> = ({
3055
<hr className={styles['spacer']} />
3156

3257
<div className={classNames(styles['modal-body'], 'modal-body')}>
58+
{renterContent()}
3359
{children}
3460
</div>
3561
</Modal>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {Dispatch, SetStateAction, useEffect, useState} from 'react'
2+
3+
import { xhrGetAsync } from '../../functions'
4+
5+
export interface ModalContentResponse {
6+
content: string | undefined
7+
}
8+
9+
export function useFetchModalContent(contentUrl?: string, enabled?: boolean): ModalContentResponse {
10+
const [content, setContent]: [string|undefined, Dispatch<SetStateAction<string|undefined>>] = useState()
11+
12+
useEffect(() => {
13+
if (!contentUrl || !enabled) {
14+
return
15+
}
16+
17+
if (!content) {
18+
xhrGetAsync<string>(contentUrl).then(setContent)
19+
}
20+
}, [contentUrl, content, enabled])
21+
22+
return { content }
23+
}

src-ts/lib/modals/order-contract-modal/OrderContractModal.module.scss

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,8 @@
1313
p {
1414
margin-bottom: 20px;
1515

16-
&.sm {
16+
&:global(.sm) {
1717
font-size: 14px;
1818
}
1919
}
2020
}
21-
22-
.topCoderLink {
23-
text-decoration: underline;
24-
color: $link-blue-light;
25-
}

src-ts/lib/modals/order-contract-modal/OrderContractModal.tsx

Lines changed: 4 additions & 616 deletions
Large diffs are not rendered by default.

src-ts/lib/modals/order-contract-modal/order-contract.content.txt

Lines changed: 611 additions & 0 deletions
Large diffs are not rendered by default.

src-ts/lib/modals/privacy-policy-modal/PrivacyPolicyModal.module.scss

Lines changed: 9 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -20,55 +20,18 @@
2020
}
2121
}
2222

23-
ul.a {
24-
list-style-type: disc;
25-
list-style: disc;
26-
27-
li {
28-
padding-left: 0;
29-
margin-left: 20px;
30-
}
31-
}
32-
33-
ul.b {
34-
list-style-type: disc;
35-
list-style: disc;
36-
37-
li {
38-
padding-left: 0;
39-
margin-left: 20px;
40-
}
41-
}
42-
43-
ul.c {
44-
list-style-type: disc;
45-
list-style: disc;
46-
47-
li {
48-
padding-left: 0;
49-
margin-left: 20px;
50-
}
51-
}
52-
53-
ul.d {
54-
list-style-type: disc;
55-
list-style: disc;
56-
57-
li {
58-
padding-left: 0;
59-
margin-left: 20px;
23+
ul {
24+
&:global(.disc) {
25+
list-style-type: disc;
26+
list-style: disc;
27+
28+
li {
29+
padding-left: 0;
30+
margin-left: 20px;
31+
}
6032
}
6133
}
6234

63-
ul.e {
64-
list-style-type: disc;
65-
list-style: disc;
66-
67-
li {
68-
padding-left: 0;
69-
margin-left: 20px;
70-
}
71-
}
7235

7336
a {
7437
text-decoration: underline;

src-ts/lib/modals/privacy-policy-modal/PrivacyPolicyModal.tsx

Lines changed: 11 additions & 955 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)