-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject-overview.js
More file actions
212 lines (199 loc) · 5.71 KB
/
Copy pathproject-overview.js
File metadata and controls
212 lines (199 loc) · 5.71 KB
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
import { Button, Column, Expander } from '@carbonplan/components'
import { QuestionCircle, RotatingArrow } from '@carbonplan/icons'
import { Box, Flex } from 'theme-ui'
import { COLORS, LABELS } from './constants'
import TooltipWrapper from './tooltip-wrapper'
import { getProjectCategory } from './utils'
const Empty = ({ label = 'Unknown' }) => {
return <Box>{label}</Box>
}
const ProjectOverview = ({ project, columns = 4 }) => {
const {
category,
country,
status,
protocol,
protocol_unassigned,
is_compliance,
proponent,
project_url,
registry,
project_type,
project_type_source,
} = project
const color = COLORS[getProjectCategory(project)] ?? COLORS.other
const sx = {
label: {
color,
fontFamily: 'mono',
letterSpacing: 'mono',
textTransform: 'uppercase',
},
value: {
fontFamily: 'faux',
letterSpacing: 'faux',
fontSize: 1,
mt: 2,
mb: 5,
},
tooltipWrapper: {
justifyContent: 'flex-start',
alignItems: 'center',
gap: 1,
width: 'fit-content',
'& svg': { stroke: color },
},
}
return (
<>
<Column start={[1]} width={[3, 2, 2, 2]}>
<TooltipWrapper
top='-0.5px'
color={color}
tooltip='Location of project'
sx={sx.tooltipWrapper}
>
<Box sx={sx.label}>Country</Box>
</TooltipWrapper>
<Box sx={sx.value}>{country ?? <Empty />}</Box>
</Column>
<Column start={[4, 3, 3, 3]} width={[3, 2, 2, 2]}>
<TooltipWrapper
top='-0.5px'
color={color}
tooltip='Stage in project lifecycle'
sx={sx.tooltipWrapper}
>
<Box sx={sx.label}>Status</Box>
</TooltipWrapper>
<Box sx={{ ...sx.value, textTransform: 'capitalize' }}>
{status ?? <Empty />}
</Box>
</Column>
<Column
start={[1, 5, columns === 4 ? 1 : 5, columns === 4 ? 1 : 5]}
width={[3, 2, 2, 2]}
>
<TooltipWrapper
top='-0.5px'
color={color}
tooltip='Project category inferred from protocol(s)'
sx={sx.tooltipWrapper}
>
<Box sx={sx.label}>Category</Box>
</TooltipWrapper>
<Box sx={sx.value}>
{(Array.isArray(category) ? category : [category]).map((c) => (
<Box key={c} sx={{ width: 'fit-content' }}>
{LABELS.category[c] ?? <Empty />}
</Box>
))}
</Box>
</Column>
<Column
start={[4, 1, columns === 4 ? 3 : 1, columns === 4 ? 3 : 1]}
width={[3, 2, 2, 2]}
>
<TooltipWrapper
top='-0.5px'
color={color}
tooltip={
LABELS.project_type_source[project_type_source] ??
LABELS.project_type_source.empty
}
sx={sx.tooltipWrapper}
>
<Box sx={sx.label}>Project type</Box>
</TooltipWrapper>
<Box sx={sx.value}>{project_type ?? <Empty label='N/A' />}</Box>
</Column>
<Column
start={[1, 3, columns === 4 ? 1 : 3, columns === 4 ? 1 : 3]}
width={[3, 2, 2, 2]}
>
<TooltipWrapper
top='-0.5px'
color={color}
tooltip='Methodology used to issue credits'
sx={sx.tooltipWrapper}
>
<Box sx={sx.label}>Protocol</Box>
</TooltipWrapper>
<Box sx={sx.value}>
{protocol?.length > 0 ? (
<Flex sx={{ flexDirection: 'column', gap: 2 }}>
{protocol.map((d) => (
<Box key={d} sx={{ textTransform: 'uppercase' }}>
{d}
</Box>
))}
</Flex>
) : (
<TooltipWrapper
color={'primary'}
Icon={QuestionCircle}
tooltip={
protocol_unassigned?.length > 0
? `Reported as ${protocol_unassigned.join(', ')}`
: 'No information reported'
}
sx={{
...sx.tooltipWrapper,
'& svg': { stroke: 'primary' },
}}
>
<Empty />
</TooltipWrapper>
)}
</Box>
</Column>
<Column
start={[4, 5, columns === 4 ? 3 : 5, columns === 4 ? 3 : 5]}
width={[3, 2, 2, 2]}
>
<TooltipWrapper
top='-0.5px'
color={color}
tooltip='Project proponent listed on registry'
sx={sx.tooltipWrapper}
>
<Box sx={sx.label}>Proponent</Box>
</TooltipWrapper>
<Box sx={{ ...sx.value, mr: columns === 4 ? [0, 0, 2, 2] : 0 }}>
{proponent ?? <Empty label='N/A' />}
</Box>
</Column>
<Column start={[1, 1, 1, 1]} width={[3, 2, 2, 2]}>
<TooltipWrapper
top='-0.5px'
color={color}
tooltip='Whether project is enrolled in a compliance program'
sx={sx.tooltipWrapper}
>
<Box sx={sx.label}>Compliance</Box>
</TooltipWrapper>
<Box sx={sx.value}>{is_compliance ? 'Yes' : 'No'}</Box>
</Column>
<Column start={[4, 3, 3, 3]} width={[3, 2, 2, 2]}>
<TooltipWrapper
top='-0.5px'
color={color}
tooltip='Link to project registry page'
sx={sx.tooltipWrapper}
>
<Box sx={sx.label}>Registry</Box>
</TooltipWrapper>
<Box sx={sx.value}>
<Button
href={project_url}
suffix={<RotatingArrow sx={{ mt: -1, height: 13, width: 13 }} />}
sx={sx.value}
>
{LABELS.registry[registry]}
</Button>
</Box>
</Column>
</>
)
}
export default ProjectOverview