-
Notifications
You must be signed in to change notification settings - Fork 1
/
helpers.js
121 lines (112 loc) · 2.98 KB
/
helpers.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
120
121
import { OverlayTrigger, Tooltip } from 'react-bootstrap'
import {Row, Col} from 'react-bootstrap'
import '@fortawesome/fontawesome-svg-core/styles.css';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faEnvelope } from '@fortawesome/free-solid-svg-icons'
import { faLink } from '@fortawesome/free-solid-svg-icons'
export function obfuscate( domain, em_name ) {
// Credit to Dan Jurafsky for this function.
return em_name + '@' + domain;
}
export function leftTooltip(component, text) {
return (
<>
<OverlayTrigger
key={"left"}
placement={"left"}
overlay={
<Tooltip id={`tooltip-${"left"}`}>
{text}
</Tooltip>
}
>
{component}
</OverlayTrigger>
</>
)
}
export function bottomTooltip(component, text) {
return (
<>
<OverlayTrigger
key={"bottom"}
placement={"bottom"}
overlay={
<Tooltip id={`tooltip-${"bottom"}`} style={{ whiteSpace: 'pre-line' }}>
{text}
</Tooltip>
}
>
{component}
</OverlayTrigger>
</>
)
}
export function instructorProfileImgName(name, image_path) {
return (
<>
<Row>
<img src={image_path} id="profile" alt={name}/>
</Row>
<Row style={{paddingTop: '3px'}}>
<div id="name">{name}</div>
</Row>
<style jsx>{`
#profile {
width: 125px;
height: 100px;
display: block;
margin-left: auto;
margin-right: auto;
}
#name {
text-align: center;
}
`}</style>
</>
)
}
export function instructorProfile(name, image_path, homepage, em_domain, em_name) {
return (
<>
<Row>
<img src={image_path} id="profile" alt={name}/>
</Row>
<Row style={{paddingTop: '3px'}}>
<div id="name">{name}</div>
</Row>
<Row>
<Col></Col>
{/* Email icon */}
<Col className='d-flex justify-content-center'>
{bottomTooltip(<a href={"mailto:" + obfuscate(em_domain, em_name)}>
<FontAwesomeIcon
icon={faEnvelope}
size="1x"/>
</a>, obfuscate(em_domain, em_name))}
</Col>
{/* Homepage icon */}
<Col className='d-flex justify-content-center'>
{bottomTooltip(<a href={homepage} target="_blank">
<FontAwesomeIcon
icon={faLink}
size="1x"/>
</a>, homepage)}
</Col>
<Col></Col>
</Row>
<style jsx>{`
#profile {
width: 125px;
height: 100px;
display: block;
margin-left: auto;
margin-right: auto;
}
#name {
text-align: center;
}
`}</style>
</>
)
}