Skip to content

Commit d33fd50

Browse files
committed
various sizing tweaks
1 parent aab24f3 commit d33fd50

File tree

8 files changed

+58
-161
lines changed

8 files changed

+58
-161
lines changed

components/minimap.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const projection = geoAlbersUsa().scale(1300).translate([487.5, 305])
88

99
const Minimap = ({ data, states }) => {
1010
return (
11-
<Box sx={{ pl: [0, 0, 8, 8] }}>
11+
<Box sx={{ pt: [2, 0, 0, 0], pl: [0, 0, 8, 8] }}>
1212
<Box
1313
as='svg'
1414
viewBox='0 0 975 500'

components/project.js

+19-9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const Project = ({
1111
year,
1212
zoom,
1313
states,
14+
id,
1415
height = 140,
1516
showStates = true,
1617
showStartDate = true,
@@ -38,9 +39,10 @@ const Project = ({
3839
opacity: zoom === 'far' ? 1 : 0,
3940
})
4041

41-
const { number, id, name } = data
42+
const { number, name } = data
4243

4344
useEffect(() => {
45+
const { id } = data
4446
if (showStates && !states) return
4547
const prefix =
4648
'https://storage.googleapis.com/carbonplan-research/offset-fires/grist/projects/'
@@ -90,28 +92,34 @@ const Project = ({
9092
>
9193
{number}
9294
</Box>
93-
<Box as='span' sx={{ pl: [2], fontSize: [3, 4, 4, 5] }}>
95+
<Box as='span' sx={{ pl: [2], fontSize: [3, 4, 4, 4] }}>
9496
{name}
9597
</Box>
9698
</Box>
9799
)}
98100
<Box
101+
id={id}
99102
sx={{
100103
mt: [2],
101104
mb: [4],
102105
position: 'relative',
103106
borderRadius: '1px',
104107
height: [
105108
'auto',
106-
stretch ? 'calc(100% - 72px)' : 'auto',
107-
stretch ? 'calc(100% - 72px)' : 'auto',
108-
stretch ? 'calc(100% - 72px)' : 'auto',
109+
stretch ? 'calc(100% - 68px)' : 'auto',
110+
stretch ? 'calc(100% - 68px)' : 'auto',
111+
stretch ? 'calc(100% - 68px)' : 'auto',
109112
],
110113
border: ({ colors }) =>
111114
border ? `solid 1px ${colors.muted}` : 'none',
112115
}}
113116
>
114-
<Box as='svg' viewBox={`0 0 400 ${height}`} sx={{ mb: '-4px' }}>
117+
<Box
118+
id={id + '-svg'}
119+
as='svg'
120+
viewBox={`0 0 400 ${height}`}
121+
sx={{ mb: '-4px' }}
122+
>
115123
<animated.g transform={transform}>
116124
<g strokeLinejoin='round' strokeLinecap='round'>
117125
<path
@@ -206,9 +214,11 @@ const Project = ({
206214
}}
207215
>
208216
{metadata &&
209-
((100 * metadata?.burned_acreage) / metadata?.acreage < 1
210-
? '<1%'
211-
: format('.0%')(metadata?.burned_acreage / metadata?.acreage))}
217+
((100 * metadata?.burned_acreage) / metadata?.acreage < 1
218+
? '<1%'
219+
: format('.0%')(
220+
metadata?.burned_acreage / metadata?.acreage
221+
))}
212222
</Box>
213223
</Box>
214224
)}

package-lock.json

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pages/embed/future-risk.js pages/embed/offset-fires/future-risk.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { json } from 'd3-fetch'
66
import { geoPath, geoAlbersUsa } from 'd3-geo'
77
import { scaleLinear } from 'd3-scale'
88
import { feature } from 'topojson-client'
9-
import Project from '../../components/project'
10-
import Layout from '../../components/layout'
9+
import Project from '../../../components/project'
10+
import Layout from '../../../components/layout'
1111

1212
const projection = geoAlbersUsa().scale(1300).translate([487.5, 305])
1313
const years = [2020, 2030, 2040, 2050, 2060, 2070, 2080, 2090]

pages/embed/project-fires.js pages/embed/offset-fires/project-overlap.js

+32-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { useState, useEffect } from 'react'
22
import { Box, Flex } from 'theme-ui'
33
import { Row, Column, Slider } from '@carbonplan/components'
4-
import Layout from '../../components/layout'
5-
import Minimap from '../../components/minimap'
6-
import Project from '../../components/project'
7-
import useStates from '../../components/use-states'
4+
import Layout from '../../../components/layout'
5+
import Minimap from '../../../components/minimap'
6+
import Project from '../../../components/project'
7+
import useStates from '../../../components/use-states'
88

99
const projects = [
1010
{
@@ -55,6 +55,27 @@ const Index = () => {
5555
const [sliderChanging, setSliderChanging] = useState(false)
5656
const states = useStates()
5757

58+
useEffect(() => {
59+
const resize = () => {
60+
if (document.body.clientWidth > 641) {
61+
const target = document.getElementById('project-0')
62+
const targetSvg = document.getElementById('project-0-svg')
63+
const ref1 = document.getElementById('project-1')
64+
const ref2 = document.getElementById('project-2')
65+
const offset = 68
66+
const newHeight = offset + ref1.offsetHeight + ref2.offsetHeight
67+
const newSvgHeight = (0.5 * ((newHeight - 48) - targetSvg.clientHeight))
68+
target.style.height = newHeight + 'px'
69+
targetSvg.style.marginTop = newSvgHeight + 'px'
70+
} else {
71+
const target = document.getElementById('project-0')
72+
target.style.height = 'auto'
73+
}
74+
}
75+
resize()
76+
window.onresize = resize
77+
}, [])
78+
5879
return (
5980
<Layout embed='medium'>
6081
<Box sx={{ width: '100%', height: '100%', bg: 'background', p: [5] }}>
@@ -95,6 +116,7 @@ const Index = () => {
95116
<Row columns={[1, 3, 3, 3]}>
96117
<Column start={1} width={[1, 2, 2, 2]}>
97118
<Project
119+
id={'project-0'}
98120
data={projects[0]}
99121
states={states}
100122
year={year}
@@ -105,12 +127,15 @@ const Index = () => {
105127
</Column>
106128
<Column start={[1, 3, 3, 3]} width={1}>
107129
<Project
130+
id={'project-1'}
108131
data={projects[1]}
109132
states={states}
110133
year={year}
111134
zoom={zoom}
135+
112136
/>
113137
<Project
138+
id={'project-2'}
114139
data={projects[2]}
115140
states={states}
116141
year={year}
@@ -288,7 +313,7 @@ const Index = () => {
288313
textTransform: 'uppercase',
289314
fontFamily: 'heading',
290315
letterSpacing: 'smallcaps',
291-
mt: [5, '-2px', '-2px', '-2px'],
316+
mt: [6, '-2px', '-2px', '7px'],
292317
pr: [2],
293318
}}
294319
>
@@ -309,7 +334,7 @@ const Index = () => {
309334
textTransform: 'uppercase',
310335
fontFamily: 'body',
311336
letterSpacing: 'smallcaps',
312-
mt: ['20px', '-14px', '-14px', '-14px'],
337+
mt: ['36px', '-14px', '-14px', '-14px'],
313338
px: [2],
314339
fontSize: [5, 5, 5, 6],
315340
transition: 'color 0.15s',
@@ -337,7 +362,7 @@ const Index = () => {
337362
textTransform: 'uppercase',
338363
fontFamily: 'body',
339364
letterSpacing: 'smallcaps',
340-
mt: ['20px', '-14px', '-14px', '-14px'],
365+
mt: ['36px', '-14px', '-14px', '-14px'],
341366
px: [2],
342367
fontSize: [5, 5, 5, 6],
343368
transition: 'color 0.15s',

pages/embed/project-focus.js

-139
This file was deleted.

pages/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const Index = () => {
6767
iframe.height =
6868
iframe.contentWindow.document.body.offsetHeight + 1 + 'px'
6969
}}
70-
src='/embed/project-fires'
70+
src='/embed/offset-fires/project-overlap'
7171
sx={{
7272
display: 'block',
7373
width: ['100%', '100%', '100%', '1024px'],
@@ -115,7 +115,7 @@ const Index = () => {
115115
<Box
116116
as='iframe'
117117
id='figure-3'
118-
src='/embed/future-risk'
118+
src='/embed/offset-fires/future-risk'
119119
scrolling='no'
120120
height='750px'
121121
onLoad={(event) => {

theme.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const theme = (embed) => {
55
if (embed == 'small') {
66
breakpoints = ['30em', '40em', '60em']
77
} else if (embed == 'medium') {
8-
breakpoints = ['35em', '80em', '80em']
8+
breakpoints = ['40.063em', '80em', '80em']
99
} else {
1010
breakpoints = ['40em', '66.875em', '90em']
1111
}

0 commit comments

Comments
 (0)