-
Notifications
You must be signed in to change notification settings - Fork 162
/
MainDisplayMarkdown.js
119 lines (101 loc) · 2.41 KB
/
MainDisplayMarkdown.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import React, { Suspense, lazy } from "react";
import { connect } from "react-redux";
import styled from 'styled-components';
import { dataFont } from "../../globalStyles";
const MarkdownDisplay = lazy(() => import("../markdownDisplay"));
/**
* The following code borrows heavily from the Footer
* but is here in order to allow modifications with no side
* effects to the Footer. This work was done in an expedited fashion
* for nCoV but this should be revisited and improved when we have
* time. james. Jan 24 2020
*/
const Container = styled.div`
margin: ${(props) => props.mobile ? `10px 5% 5% 5%` : `50px 30px 30px 30px`};
font-family: ${dataFont};
font-weight: 300;
color: ${(props) => props.theme.unselectedColor};
line-height: 1.4;
width: ${(props) => props.width-30}px;
/* Use media queries to modify the font size so things look ok
on a range of screen sizes */
font-size: 14px;
line-height: 1.4;
@media (max-width: 1080px) {
line-height: 1.2;
}
h1 {
font-weight: 700;
font-size: 2em;
margin: 0.3em 0;
}
h2 {
font-weight: 600;
font-size: 1.8em;
margin: 0.3em 0;
}
h3 {
font-weight: 500;
font-size: 1.6em;
margin: 0.3em 0;
}
h4 {
font-weight: 500;
font-size: 1.4em;
margin: 0.2em 0;
}
h5 {
font-weight: 500;
font-size: 1.2em;
margin: 0.2em 0;
}
h6 {
font-weight: 500;
font-size: 1.2em;
margin: 0.2em 0;
}
pre {
padding: 16px;
overflow: auto;
font-size: 85%;
line-height: 1.45;
background-color: #f6f8fa;
border-radius: 3px;
}
.line {
margin-top: 20px;
margin-bottom: 20px;
border-bottom: 1px solid #CCC;
}
.imageContainer {
display: flex;
justify-content: center;
align-items: center;
flex-wrap: wrap;
}
img {
margin-left: 30px;
margin-right: 30px;
margin-top: 2px;
margin-bottom: 2px;
max-width: 100%;
}
table, th, td {
border: 1px solid;
}
td, th {
padding: 3px;
}
`;
const MainDisplayMarkdown = ({ narrativeBlock, width, mobile }) => {
return (
<Container width={width} mobile={mobile}>
<Suspense>
<MarkdownDisplay dir="auto" mdstring={narrativeBlock.mainDisplayMarkdown} />
</Suspense>
</Container>
);
};
export default connect((state) => ({
narrativeBlock: state.narrative.blocks[state.narrative.blockIdx]
}))(MainDisplayMarkdown);