Skip to content

Commit 3372072

Browse files
authored
Merge pull request #187 from carbonplan/freeman-lab/stripe-2021
add new entries for stripe sprint 2021
2 parents e2679d1 + 88e2ac0 commit 3372072

35 files changed

+9009
-5757
lines changed

.isort.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[settings]
2-
known_third_party = click,gspread,msft2021,oauth2client,pandas,strp2020,utils
2+
known_third_party = click,gspread,msft2021,oauth2client,pandas,strp2020,strp2021,utils

components/main.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ const initFilters = {
1111
soil: true,
1212
biomass: true,
1313
ocean: true,
14-
STRP2020: true,
15-
MSFT2021: true,
14+
stripe: true,
15+
microsoft: true,
1616
avoided: true,
1717
removal: true,
1818
group: false,
19+
2020: true,
20+
2021: true,
1921
search: '',
2022
rating: 3,
2123
}
@@ -25,6 +27,10 @@ const initBounds = {
2527
permanence: [],
2628
}
2729

30+
const near = (a, b) => {
31+
return Math.abs(a - b) < 0.000001
32+
}
33+
2834
const Main = ({ projects, metrics, settingsExpanded }) => {
2935
const [filters, setFilters] = useState(initFilters)
3036
const [filtered, setFiltered] = useState({ count: 0, init: false })
@@ -49,9 +55,10 @@ const Main = ({ projects, metrics, settingsExpanded }) => {
4955
function checkBounds(value, bounds, min, max) {
5056
if (bounds.length == 0) return true
5157
return (
52-
(value > bounds[0] && value < bounds[1]) ||
53-
(bounds[1] === max && value >= max) ||
54-
(bounds[0] === min && value <= min)
58+
((near(value, bounds[0]) || value > bounds[0]) &&
59+
(near(value, bounds[1]) || value < bounds[1])) ||
60+
((near(max, bounds[1]) || bounds[1] > max) && value >= max) ||
61+
((near(min, bounds[0]) || bounds[0] < min) && value <= min)
5562
)
5663
}
5764

@@ -66,9 +73,11 @@ const Main = ({ projects, metrics, settingsExpanded }) => {
6673
(filters.biomass && d.tags.length > 0 && d.tags[0] == 'biomass') ||
6774
(filters.ocean && d.tags.length > 0 && d.tags[0] == 'ocean')
6875
const inSource =
69-
(filters.STRP2020 &&
70-
d.source.name == 'Stripe 2020 Negative Emissions Purchase') ||
71-
(filters.MSFT2021 && d.source.name == 'Microsoft 2021 CDR RFP')
76+
(filters.stripe && d.source.id.includes('STRP')) ||
77+
(filters.microsoft && d.source.id.includes('MSFT'))
78+
const inYear =
79+
(filters['2020'] && d.source.date.includes('2020')) ||
80+
(filters['2021'] && d.source.date.includes('2021'))
7281
const inMechanism =
7382
(filters.removal && d.metrics[0].value == 0) ||
7483
(filters.avoided && d.metrics[0].value == 1) ||
@@ -86,7 +95,7 @@ const Main = ({ projects, metrics, settingsExpanded }) => {
8695
(d.tags.length > 1 && d.tags[1].toLowerCase().includes(searchTerm)))
8796
const isValidated = d.rating >= filters.rating
8897
const inFilter =
89-
inTags && inSource && inBounds && inMechanism && isValidated
98+
inTags && inSource && inYear && inBounds && inMechanism && isValidated
9099
if (filters.search.length > 0 && inSearch && inFilter) return true
91100
if (filters.search.length == 0 && inFilter) return true
92101
else return false

components/methods/intro.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@ const Intro = ({ setSection }) => {
3838
<InternalLink href='/research/stripe-2020-insights'>
3939
Stripe in 2020
4040
</InternalLink>{' '}
41-
and to{' '}
41+
,{' '}
4242
<InternalLink href='/research/microsoft-2021-insights'>
4343
Microsoft in 2021
4444
</InternalLink>
45+
, or{' '}
46+
<InternalLink href='/research/stripe-2021-insights'>
47+
Stripe in 2021
48+
</InternalLink>
4549
. If you have questions or want to get in touch. check out the{' '}
4650
<Link
4751
sx={{

components/methods/table.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const Table = ({ one, two, three, type, children }) => {
4646
>
4747
<TableRow final={type == 'icons'}>
4848
<Column start={[starts[0]]} width={[widths[0]]}>
49-
{type == 'icons' && <Check sx={{ width: 48, height: 48 }} />}
49+
{type == 'icons' && <Check sx={{ width: 36, height: 36 }} />}
5050
{type == 'squares' && (
5151
<Box sx={{ mt: ['9px'] }}>
5252
<Squares data={2} />

components/projects/report/graphics/rating.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,16 @@ const { Check } = Icons
55

66
const Rating = ({ sx, value }) => {
77
return (
8-
<Box sx={{ ml: ['-5px'], mt: ['6px'] }}>
8+
<Box sx={{ ml: ['-5px'], mt: ['5px'] }}>
99
{[0, 1, 2, 3, 4].map((d, i) => (
1010
<Box key={'rating-' + i} sx={{ display: 'inline-block' }}>
1111
<Check
1212
sx={{
1313
position: 'relative',
1414
cursor: 'pointer',
15-
width: '21px',
16-
ml: ['-1px'],
15+
width: '28px',
16+
ml: ['0px'],
1717
mr: ['0px'],
18-
strokeWidth: 2.25,
1918
opacity: d < value ? 1 : 0.3,
2019
zIndex: -1,
2120
...sx,

components/projects/report/graphics/scales.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = {
1414
min: 10,
1515
max: 1000,
1616
},
17-
cost: {
17+
price: {
1818
type: 'log',
1919
min: 3,
2020
max: 3000,

components/projects/report/index.js

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const showMetrics = [
1818
'volume',
1919
'negativity',
2020
'permanence',
21-
'cost',
21+
'price',
2222
'additionality',
2323
'specificity',
2424
]
@@ -39,19 +39,22 @@ const Report = ({ data, setHighlighted, tooltips, embed }) => {
3939
metrics,
4040
location,
4141
rating,
42+
notes,
4243
} = data
4344

4445
metrics = showMetrics.map((metric) => {
4546
return metrics.filter((m) => m.name == metric)[0]
4647
})
4748

48-
metrics.push({
49-
name: 'rating',
50-
value: rating,
51-
units: '',
52-
notes: '',
53-
comment: '',
54-
})
49+
metrics = [
50+
{
51+
name: 'rating',
52+
value: rating,
53+
units: '',
54+
notes: '',
55+
comment: '',
56+
},
57+
].concat(metrics)
5558

5659
const ml = embed ? [0, 0, 0] : [0, 0, '24px', '36px']
5760
const pl = embed ? [0, 0, 0] : [0, 0, '24px', '36px']
@@ -206,8 +209,13 @@ const Report = ({ data, setHighlighted, tooltips, embed }) => {
206209
color: 'secondary',
207210
}}
208211
>
209-
{id.includes('STRP') && 'Stripe 2020'}
210-
{id.includes('MSFT') && 'Microsoft 2021'}
212+
{id.includes('STRP') & (parseInt(id.split('STRP')[1]) <= 24)
213+
? 'Stripe 2020'
214+
: ''}
215+
{id.includes('STRP') & (parseInt(id.split('STRP')[1]) > 24)
216+
? 'Stripe 2021'
217+
: ''}
218+
{id.includes('MSFT') ? 'Microsoft 2021' : ''}
211219
<Box as='span' sx={{ mx: [2] }}>
212220
/
213221
</Box>
@@ -241,6 +249,17 @@ const Report = ({ data, setHighlighted, tooltips, embed }) => {
241249
cursor: 'default',
242250
}}
243251
>
252+
{!(notes === '') && (
253+
<Box
254+
sx={{
255+
color: 'secondary',
256+
mt: [2],
257+
mb: [3],
258+
}}
259+
>
260+
Note: {notes}
261+
</Box>
262+
)}
244263
<Box sx={{ display: 'inline-block', color: 'secondary' }}>
245264
<Box as='span' sx={{ mr: [2] }}>
246265
<Link

components/projects/report/metric/desktop.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ const sx = {
2727
fontFamily: 'mono',
2828
fontSize: [3],
2929
textAlign: 'right',
30-
mt: ['5px'],
30+
mt: ['6px'],
3131
},
3232
label: {
3333
fontFamily: 'mono',
3434
fontSize: [2, 2, 2, 3],
35-
mt: ['6px'],
35+
mt: ['8px', '8px', '8px', '6px'],
3636
textTransform: 'capitalize',
3737
},
3838
units: {
@@ -70,15 +70,15 @@ const MetricDesktop = ({
7070
<Box
7171
onClick={hasDetails ? toggle : (e) => e.stopPropagation()}
7272
sx={{
73-
cursor: hasDetails ? 'pointer' : 'inherit',
73+
cursor: hasDetails ? 'pointer' : 'initial',
7474
pointerEvents: 'all',
7575
'&:hover > #grid > #container > #expander': {
7676
fill: 'primary',
7777
stroke: 'primary',
7878
},
79-
pt: [2],
79+
pt: [1],
8080
pb: ['6px'],
81-
pl: embed ? [2, 2, 2] : [0, 0, '24px'],
81+
pl: embed ? [2, 2, 2] : [0, 0, '24px', '38px'],
8282
}}
8383
>
8484
<Grid id='grid' gap={['16px']} columns={['55px 95px 1fr 15px 30px']}>
@@ -112,8 +112,8 @@ const MetricDesktop = ({
112112
scale={scales['negativity']}
113113
></Bar>
114114
)}
115-
{metric.name == 'cost' && (
116-
<Bar tag={tag} data={metric.value} scale={scales['cost']}></Bar>
115+
{metric.name == 'price' && (
116+
<Bar tag={tag} data={metric.value} scale={scales['price']}></Bar>
117117
)}
118118
{metric.name == 'additionality' && (
119119
<Box sx={{ mt: '13px' }}>
@@ -126,7 +126,7 @@ const MetricDesktop = ({
126126
</Box>
127127
)}
128128
{metric.name == 'rating' && (
129-
<Box sx={{ mb: '6px' }}>
129+
<Box sx={{ width: 'calc(100% + 40px)', ml: '-40px', mb: '0px' }}>
130130
<Rating
131131
sx={{ color: theme.tags[tag] }}
132132
value={metric.value}
@@ -161,7 +161,8 @@ const MetricDesktop = ({
161161
)}
162162
</Text>
163163
<Text sx={{ mt: ['3px'] }}>
164-
{metric.rating === 1 && (
164+
{(metric.rating === 1 ||
165+
(metric.name === 'additionality' && metric.value === 2)) && (
165166
<Check sx={{ width: '28px', color: theme.tags[tag] }} />
166167
)}
167168
{metric.rating === 0 && <Box />}
@@ -185,7 +186,7 @@ const MetricDesktop = ({
185186
ml={'0px'}
186187
sx={{
187188
cursor: 'text',
188-
pl: embed ? ['190px'] : ['182px', '182px', '206px'],
189+
pl: embed ? ['190px'] : ['182px', '182px', '206px', '220px'],
189190
pr: ['30px'],
190191
mt: ['-4px'],
191192
pb: ['10px'],
@@ -202,7 +203,7 @@ const MetricDesktop = ({
202203
sx={{
203204
pb: [1],
204205
cursor: 'text',
205-
pl: embed ? [2, 2, 2] : [0, 0, '24px'],
206+
pl: embed ? [2, 2, 2] : [0, 0, '24px', '38px'],
206207
}}
207208
onClick={(e) => e.stopPropagation()}
208209
>
@@ -272,7 +273,7 @@ const MetricDesktop = ({
272273
</AnimateHeight>
273274
<Divider
274275
sx={{
275-
ml: embed ? [0, 0, 0] : [0, 0, '24px'],
276+
ml: embed ? [0, 0, 0] : [0, 0, '24px', '38px'],
276277
mr: [0],
277278
mt: [0],
278279
mb: [0],

components/projects/report/metric/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useState } from 'react'
22
import { Box } from 'theme-ui'
3+
import { format as _format } from 'd3-format'
34
import { useMeasure } from 'react-use'
45
import MetricMobile from './mobile'
56
import MetricDesktop from './desktop'
@@ -37,8 +38,13 @@ const Metric = ({ metric, tag, tooltips, embed }) => {
3738
if (key == 'mechanism' && value == 1) return 'AVD'
3839
}
3940
if (key == 'mechanism' && value == 2) return 'BOTH'
40-
else if (key == 'cost') return '$' + parseFloat(value).toFixed(0)
41-
else if (key == 'negativity') return parseFloat(value).toFixed(2)
41+
else if (key == 'price') {
42+
if (parseFloat(value) < 1000) {
43+
return '$' + _format('.3~s')(parseFloat(value).toFixed(0))
44+
} else {
45+
return '$' + _format('.2~s')(parseFloat(value).toFixed(0))
46+
}
47+
} else if (key == 'negativity') return parseFloat(value).toFixed(2)
4248
else if (key == 'volume') {
4349
if (value < 1000) return value
4450
else if (value >= 1000 && value < 1000000)

components/projects/report/metric/mobile.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ const MetricMobile = ({
8484
</Text>
8585
)}
8686
</Text>
87-
{metric.rating === 1 && (
87+
{(metric.rating === 1 ||
88+
(metric.name === 'additionality' && metric.value === 2)) && (
8889
<Check
8990
sx={{
9091
position: 'relative',
@@ -96,7 +97,10 @@ const MetricMobile = ({
9697
}}
9798
/>
9899
)}
99-
{!(metric.rating === 1) && <Box />}
100+
{!(
101+
metric.rating === 1 ||
102+
(metric.name === 'additionality' && metric.value === 2)
103+
) && <Box />}
100104
{hasDetails && (
101105
<Box id='container' sx={{ mt: ['10px'], ml: ['-5px'] }}>
102106
<Expander

0 commit comments

Comments
 (0)