Skip to content

Commit 979d311

Browse files
committed
Create PolicyContainer component, add terms of use
1 parent 9cbe79d commit 979d311

File tree

5 files changed

+84
-39
lines changed

5 files changed

+84
-39
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import React from 'react';
2+
import styled from 'styled-components';
3+
import ReactMarkdown from 'react-markdown';
4+
import remarkSlug from 'remark-slug';
5+
import PropTypes from 'prop-types';
6+
import { remSize } from '../../../theme';
7+
8+
const PolicyContainerMain = styled.main`
9+
max-width: ${remSize(700)};
10+
margin: 0 auto;
11+
padding: ${remSize(10)};
12+
line-height: 1.5em;
13+
& p {
14+
margin-bottom: ${remSize(10)};
15+
}
16+
font-size: ${remSize(16)};
17+
& h1 {
18+
font-size: 2em;
19+
}
20+
& h2 {
21+
font-size: 1.5em;
22+
margin-block-start: 0.83em;
23+
margin-block-end: 0.83em;
24+
}
25+
& h3 {
26+
font-size: 1.17em;
27+
margin-block-start: 1em;
28+
margin-block-end: 1em;
29+
font-weight: bold;
30+
}
31+
& ul {
32+
list-style: initial;
33+
padding-inline-start: 40px;
34+
margin-block-start: 1em;
35+
margin-block-end: 1em;
36+
}
37+
`;
38+
39+
function PolicyContainer({ policy }) {
40+
return (
41+
<PolicyContainerMain>
42+
<ReactMarkdown remarkPlugins={[remarkSlug]}>{policy}</ReactMarkdown>
43+
</PolicyContainerMain>
44+
);
45+
}
46+
47+
PolicyContainer.propTypes = {
48+
policy: PropTypes.string.isRequired
49+
};
50+
51+
export default PolicyContainer;

client/modules/IDE/pages/PrivacyPolicy.jsx

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,8 @@
11
import React, { useEffect, useState } from 'react';
22
import Helmet from 'react-helmet';
3-
import ReactMarkdown from 'react-markdown';
4-
import remarkSlug from 'remark-slug';
5-
import styled from 'styled-components';
63
import axios from 'axios';
74
import Nav from '../../../components/Nav';
8-
import { remSize } from '../../../theme';
9-
10-
const PrivacyPolicyContainer = styled.main`
11-
max-width: ${remSize(700)};
12-
margin: 0 auto;
13-
padding: ${remSize(10)};
14-
& p {
15-
margin-bottom: ${remSize(10)};
16-
}
17-
font-size: ${remSize(16)};
18-
& h1 {
19-
font-size: 2em;
20-
}
21-
& h2 {
22-
font-size: 1.5em;
23-
margin-block-start: 0.83em;
24-
margin-block-end: 0.83em;
25-
}
26-
& h3 {
27-
font-size: 1.17em;
28-
margin-block-start: 1em;
29-
margin-block-end: 1em;
30-
font-weight: bold;
31-
}
32-
& ul {
33-
list-style: initial;
34-
padding-inline-start: 40px;
35-
margin-block-start: 1em;
36-
margin-block-end: 1em;
37-
}
38-
`;
5+
import PolicyContainer from '../components/PolicyContainer';
396

407
function PrivacyPolicy() {
418
const [privacyPolicy, setPrivacyPolicy] = useState('');
@@ -50,11 +17,7 @@ function PrivacyPolicy() {
5017
<title>Privacy Policy</title>
5118
</Helmet>
5219
<Nav layout="dashboard" />
53-
<PrivacyPolicyContainer>
54-
<ReactMarkdown remarkPlugins={[remarkSlug]}>
55-
{privacyPolicy}
56-
</ReactMarkdown>
57-
</PrivacyPolicyContainer>
20+
<PolicyContainer policy={privacyPolicy} />
5821
</>
5922
);
6023
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React, { useEffect, useState } from 'react';
2+
import Helmet from 'react-helmet';
3+
import axios from 'axios';
4+
import Nav from '../../../components/Nav';
5+
import PolicyContainer from '../components/PolicyContainer';
6+
7+
function TermsOfUse() {
8+
const [termsOfUse, setTermsOfUse] = useState('');
9+
useEffect(() => {
10+
axios.get('terms-of-use.md').then((response) => {
11+
setTermsOfUse(response.data);
12+
});
13+
}, []);
14+
return (
15+
<>
16+
<Helmet>
17+
<title>Terms of Use</title>
18+
</Helmet>
19+
<Nav layout="dashboard" />
20+
<PolicyContainer policy={termsOfUse} />
21+
</>
22+
);
23+
}
24+
25+
export default TermsOfUse;

client/routes.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import DashboardView from './modules/User/pages/DashboardView';
1818
import createRedirectWithUsername from './components/createRedirectWithUsername';
1919
import MobileDashboardView from './modules/Mobile/MobileDashboardView';
2020
import PrivacyPolicy from './modules/IDE/pages/PrivacyPolicy';
21+
import TermsOfUse from './modules/IDE/pages/TermsOfUse';
2122
import { getUser } from './modules/User/actions';
2223
import { stopSketch } from './modules/IDE/actions/ide';
2324
import {
@@ -119,6 +120,7 @@ const routes = (store) => (
119120
<Route path="/preview" component={MobileSketchView} />
120121
<Route path="/preferences" component={MobilePreferences} />
121122
<Route path="privacy-policy" component={PrivacyPolicy} />
123+
<Route path="terms-of-use" component={TermsOfUse} />
122124
</Route>
123125
);
124126

server/routes/server.routes.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,8 @@ router.get('/privacy-policy', (req, res) => {
137137
res.send(renderIndex());
138138
});
139139

140+
router.get('/terms-of-use', (req, res) => {
141+
res.send(renderIndex());
142+
});
143+
140144
export default router;

0 commit comments

Comments
 (0)