Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions src-ts/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,8 @@ declare module '*.md' {
const value: string
export default value
}

declare module '*.txt' {
const value: string
export default value
}
28 changes: 27 additions & 1 deletion src-ts/lib/modals/base-modal/BaseModal.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,47 @@
import classNames from 'classnames'
import { FC } from 'react'
import { FC, ReactNode } from 'react'
import Modal, { ModalProps } from 'react-responsive-modal'

import { LoadingSpinner } from '../../loading-spinner'
import { IconOutline } from '../../svgs'

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

export interface BaseModalProps extends ModalProps {
contentClassName?: string
contentUrl?: string
size?: 'lg' | 'md'
title: string
}

const BaseModal: FC<BaseModalProps> = ({
children,
title,
contentUrl,
contentClassName,
...props
}: BaseModalProps) => {

const { content }: ModalContentResponse = useFetchModalContent(contentUrl, props.open)

const renterContent: () => ReactNode = () => {
if (children || !contentUrl) {
return
}

if (!content) {
return <LoadingSpinner />
}

return (
<div
className={contentClassName}
dangerouslySetInnerHTML={{__html: content}}
/>
)
}

return (
<Modal
{...props}
Expand All @@ -30,6 +55,7 @@ const BaseModal: FC<BaseModalProps> = ({
<hr className={styles['spacer']} />

<div className={classNames(styles['modal-body'], 'modal-body')}>
{renterContent()}
{children}
</div>
</Modal>
Expand Down
23 changes: 23 additions & 0 deletions src-ts/lib/modals/base-modal/use-fetch-modal-content.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {Dispatch, SetStateAction, useEffect, useState} from 'react'

import { xhrGetAsync } from '../../functions'

export interface ModalContentResponse {
content: string | undefined
}

export function useFetchModalContent(contentUrl?: string, enabled?: boolean): ModalContentResponse {
const [content, setContent]: [string|undefined, Dispatch<SetStateAction<string|undefined>>] = useState()

useEffect(() => {
if (!contentUrl || !enabled) {
return
}

if (!content) {
xhrGetAsync<string>(contentUrl).then(setContent)
}
}, [contentUrl, content, enabled])

return { content }
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@
p {
margin-bottom: 20px;

&.sm {
&:global(.sm) {
font-size: 14px;
}
}
}

.topCoderLink {
text-decoration: underline;
color: $link-blue-light;
}
620 changes: 4 additions & 616 deletions src-ts/lib/modals/order-contract-modal/OrderContractModal.tsx

Large diffs are not rendered by default.

611 changes: 611 additions & 0 deletions src-ts/lib/modals/order-contract-modal/order-contract.content.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,55 +20,18 @@
}
}

ul.a {
list-style-type: disc;
list-style: disc;

li {
padding-left: 0;
margin-left: 20px;
}
}

ul.b {
list-style-type: disc;
list-style: disc;

li {
padding-left: 0;
margin-left: 20px;
}
}

ul.c {
list-style-type: disc;
list-style: disc;

li {
padding-left: 0;
margin-left: 20px;
}
}

ul.d {
list-style-type: disc;
list-style: disc;

li {
padding-left: 0;
margin-left: 20px;
ul {
&:global(.disc) {
list-style-type: disc;
list-style: disc;

li {
padding-left: 0;
margin-left: 20px;
}
}
}

ul.e {
list-style-type: disc;
list-style: disc;

li {
padding-left: 0;
margin-left: 20px;
}
}

a {
text-decoration: underline;
Expand Down
966 changes: 11 additions & 955 deletions src-ts/lib/modals/privacy-policy-modal/PrivacyPolicyModal.tsx

Large diffs are not rendered by default.

Loading