This repository has been archived by the owner on Oct 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
person-notes.js
100 lines (91 loc) · 2.12 KB
/
person-notes.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
import {PropTypes} from 'react'
import {StyleSheet, css} from 'aphrodite'
import {upToSmall, upToMedium, upToMediumBig, atLeastMediumBig} from '<styles>/media-queries'
import Person from '<components>/person'
export default PersonNotes
function PersonNotes({person}) {
const {linksHTML, tipsHTML, picksHTML} = person
const nothing = !linksHTML.length && !tipsHTML.length && !picksHTML.length
const notesSections = [
{label: 'Links', notes: linksHTML},
{label: 'Tips', notes: tipsHTML},
{label: 'Picks', notes: picksHTML},
]
const {styles} = PersonNotes
const personClassNames = {root: css(styles.personRoot)}
return (
<div className={css(styles.personNotes)}>
<Person {...person} personClassNames={personClassNames} />
{
nothing ?
<p>No links, tips, or picks this week</p> :
(
<div className={css(styles.notesContainer)}>
{
notesSections.map((section, index) => (
<Notes {...section} key={index} />
))
}
</div>
)
}
</div>
)
}
PersonNotes.propTypes = {
person: PropTypes.object,
}
PersonNotes.styles = StyleSheet.create({
personNotes: {
display: 'flex',
[upToMedium]: {
flexDirection: 'column',
},
},
notesContainer: {
flex: 1,
[upToMediumBig]: {
marginLeft: '10',
marginRight: '10',
},
[atLeastMediumBig]: {
marginLeft: '28',
marginRight: '28',
},
},
personRoot: {
minWidth: 220,
[upToSmall]: {
minWidth: 150,
},
},
})
function Notes({notes, label}) {
if (!notes.length) {
return <span />
}
const {styles} = Notes
return (
<div>
<strong>{label}</strong>
<ul className={css(styles.list)}>
{
notes.map((note, index) => (
<li key={index} dangerouslySetInnerHTML={note} />
))
}
</ul>
</div>
)
}
Notes.propTypes = {
notes: PropTypes.array,
label: PropTypes.string,
}
Notes.styles = StyleSheet.create({
list: {
listStyle: 'disc',
padding: '10px 0px 10px 40px',
lineHeight: '1.2em',
},
})