Skip to content

Commit 715946f

Browse files
authored
Setup page "Terms of service" (#550)
* refactor: convert current info dialogs to full screen pages * feat: setup terms of service page * feat: make term titles anchor links * feat: add terms of service message to project overview page * fix: tweak copy * fix: mark message as seen when component unmounts
1 parent 30a6741 commit 715946f

File tree

21 files changed

+1164
-124
lines changed

21 files changed

+1164
-124
lines changed

ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"react-error-boundary": "^4.0.11",
3535
"react-hook-form": "^7.43.9",
3636
"react-leaflet": "^4.2.1",
37+
"react-markdown": "^9.0.1",
3738
"react-plotly.js": "^2.6.0",
3839
"react-router-dom": "^6.8.2",
3940
"typescript": "^4.4.2",

ui/public/index.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ button,
3737
fieldset,
3838
input,
3939
li,
40-
ul {
40+
ul,
41+
ol {
4142
all: unset;
4243
}
4344

ui/src/app.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import { Analytics } from 'components/analytics'
66
import { CookieDialog } from 'components/cookie-dialog/cookie-dialog'
77
import { ErrorBoundary } from 'components/error-boundary/error-boundary'
88
import { Header } from 'components/header/header'
9+
import { InfoPage } from 'components/info-page/info-page'
910
import { Menu } from 'components/menu/menu'
11+
import { TermsOfServiceInfo } from 'components/terms-of-service-info/terms-of-service-info'
1012
import { useProjectDetails } from 'data-services/hooks/projects/useProjectDetails'
1113
import { Auth } from 'pages/auth/auth'
1214
import { Login } from 'pages/auth/login'
@@ -82,6 +84,7 @@ export const App = () => (
8284
<Route path="collections/:id" element={<CollectionDetails />} />
8385
<Route path="*" element={<UnderConstruction />} />
8486
</Route>
87+
<Route path="/:slug" element={<InfoPageContainer />} />
8588
</Routes>
8689
</div>
8790
<ReactQueryDevtools initialIsOpen={false} />
@@ -122,6 +125,7 @@ const ProjectsContainer = () => {
122125

123126
return (
124127
<main className={styles.main}>
128+
<TermsOfServiceInfo />
125129
<div className={styles.content}>
126130
<ErrorBoundary>
127131
<Projects />
@@ -183,3 +187,17 @@ const ProjectContainer = () => {
183187
</>
184188
)
185189
}
190+
191+
const InfoPageContainer = () => {
192+
const { slug } = useParams()
193+
194+
return (
195+
<main className={styles.main}>
196+
<div className={styles.content}>
197+
<ErrorBoundary>
198+
<InfoPage slug={slug as string} />
199+
</ErrorBoundary>
200+
</div>
201+
</main>
202+
)
203+
}

ui/src/components/header/header.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { InfoDialog } from 'components/info-dialog/info-dialog'
21
import { useLogout } from 'data-services/hooks/auth/useLogout'
3-
import { usePages } from 'data-services/hooks/pages/usePages'
42
import { Button, ButtonTheme } from 'design-system/components/button/button'
53
import { Link, useLocation, useNavigate } from 'react-router-dom'
64
import { APP_ROUTES } from 'utils/constants'
@@ -15,7 +13,6 @@ import { UserInfoDialog } from './user-info-dialog/user-info-dialog'
1513
export const Header = () => {
1614
const location = useLocation()
1715
const navigate = useNavigate()
18-
const { pages = [] } = usePages()
1916
const { user } = useUser()
2017
const { logout, isLoading: isLogoutLoading } = useLogout()
2118

@@ -35,11 +32,12 @@ export const Header = () => {
3532
<BetaInfo />
3633
<div className={styles.rightContent}>
3734
<div className={styles.infoPages}>
38-
{pages.map((page) => (
39-
<InfoDialog key={page.id} name={page.name} slug={page.slug} />
40-
))}
35+
<Button
36+
label="Terms of Service"
37+
theme={ButtonTheme.Plain}
38+
onClick={() => navigate(APP_ROUTES.TERMS_OF_SERVICE)}
39+
/>
4140
</div>
42-
4341
{user.loggedIn ? (
4442
<>
4543
<Button

ui/src/components/info-dialog/info-dialog.module.scss

Lines changed: 0 additions & 33 deletions
This file was deleted.

ui/src/components/info-dialog/info-dialog.tsx

Lines changed: 0 additions & 35 deletions
This file was deleted.

ui/src/components/info-dialog/useActiveInfoPage.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
@import 'src/design-system/variables/colors.scss';
2+
@import 'src/design-system/variables/typography.scss';
3+
@import 'src/design-system/variables/variables.scss';
4+
5+
.wrapper {
6+
position: relative;
7+
width: 100%;
8+
min-height: 320px;
9+
margin: 16px auto;
10+
}
11+
12+
.loadingWrapper {
13+
position: absolute;
14+
width: 100%;
15+
height: 100%;
16+
top: 0;
17+
right: 0;
18+
display: flex;
19+
align-items: center;
20+
justify-content: center;
21+
}
22+
23+
.container {
24+
padding: 64px;
25+
border-radius: 8px;
26+
border: 1px solid $color-neutral-100;
27+
background: $color-generic-white;
28+
color: $color-neutral-800;
29+
}
30+
31+
.content {
32+
max-width: $small-screen-breakpoint;
33+
min-height: 320px;
34+
margin: 0 auto;
35+
36+
h1 {
37+
@include heading-5();
38+
margin: 0;
39+
40+
&:not(:last-child) {
41+
margin-bottom: 32px;
42+
}
43+
}
44+
45+
h2 {
46+
@include heading-6();
47+
margin: 0;
48+
49+
&:not(:last-child) {
50+
margin-bottom: 32px;
51+
}
52+
}
53+
54+
h3 {
55+
@include paragraph-large();
56+
margin: 0;
57+
58+
&:not(:last-child) {
59+
margin-bottom: 32px;
60+
}
61+
}
62+
63+
p {
64+
@include paragraph-small();
65+
margin: 0;
66+
67+
&:not(:last-child) {
68+
margin-bottom: 32px;
69+
}
70+
}
71+
72+
a {
73+
color: $color-primary-1-600;
74+
font-weight: 600;
75+
}
76+
77+
strong {
78+
font-weight: 600;
79+
}
80+
81+
ol {
82+
display: block;
83+
list-style-type: decimal;
84+
margin: 0 0 32px 64px;
85+
86+
li {
87+
display: list-item;
88+
@include paragraph-small();
89+
90+
&:not(:last-child) {
91+
margin-bottom: 32px;
92+
}
93+
}
94+
95+
&:has(h2) {
96+
margin: 0 0 8px;
97+
98+
li {
99+
@include heading-6();
100+
}
101+
}
102+
}
103+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { usePageDetails } from 'data-services/hooks/pages/usePageDetails'
2+
import { LoadingSpinner } from 'design-system/components/loading-spinner/loading-spinner'
3+
import { Error } from 'pages/error/error'
4+
import styles from './info-page.module.scss'
5+
import { TERMS_OF_SERVICE_SLUG } from './terms-of-service-page/constants'
6+
import { TermsOfServicePage } from './terms-of-service-page/terms-of-service-page'
7+
8+
export const InfoPage = ({ slug }: { slug: string }) => {
9+
if (slug === TERMS_OF_SERVICE_SLUG) {
10+
return <TermsOfServicePage />
11+
}
12+
13+
return <InfoPageContent slug={slug} />
14+
}
15+
16+
const InfoPageContent = ({ slug }: { slug: string }) => {
17+
const { page, isLoading, error } = usePageDetails(slug)
18+
19+
if (isLoading) {
20+
return (
21+
<div className={styles.wrapper}>
22+
<div className={styles.loadingWrapper}>
23+
<LoadingSpinner />
24+
</div>
25+
</div>
26+
)
27+
}
28+
29+
if (error) {
30+
return (
31+
<div className={styles.wrapper}>
32+
<Error error={error} />
33+
</div>
34+
)
35+
}
36+
37+
return (
38+
<div className={styles.wrapper}>
39+
<div className={styles.container}>
40+
{page ? (
41+
<div
42+
dangerouslySetInnerHTML={{ __html: page.html }}
43+
className={styles.content}
44+
/>
45+
) : null}
46+
</div>
47+
</div>
48+
)
49+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const TERMS_OF_SERVICE_SLUG = 'terms-of-service'

0 commit comments

Comments
 (0)