Skip to content

Commit 8c0d5dd

Browse files
committed
fix mobile DrawingPage layout with react-div-100vh
1 parent 32e9abc commit 8c0d5dd

File tree

3 files changed

+38
-29
lines changed

3 files changed

+38
-29
lines changed

explorer/components/DrawingPage.tsx

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { assetPrefix } from '../lib/assetPrefix'
55
import styled from 'styled-components'
66
import { getPreviousSlug, getNextSlug } from '../lib/drawings'
77
import { useRouter } from 'next/router'
8+
import Div100vh from 'react-div-100vh'
89

910
export const DrawingPage: React.FC<{ drawing: Drawing, year: number }> = ({ drawing, year }) => {
1011
const router = useRouter()
@@ -22,36 +23,37 @@ export const DrawingPage: React.FC<{ drawing: Drawing, year: number }> = ({ draw
2223
}
2324

2425
return (
25-
<Container onKeyDown={onKeyDown} tabIndex={-1}>
26-
<Title>{drawing.title}</Title>
27-
<ImageWrap>
28-
<Image src={`${assetPrefix}/images/${drawing.image}`} alt={drawing.title} />
29-
</ImageWrap>
30-
<NavBar>
31-
<Link href="/drawing/[id]" as={`/drawing/${getPreviousSlug(drawing.slug)}`}>
32-
<Arrow>&lt;</Arrow>
33-
</Link>
34-
<Link href="/year/[id]" as={`/year/${year}`}>
35-
<YearLink>{year}</YearLink>
36-
</Link>
37-
<a href={`http://explodingdog.com/title/${drawing.slug}.html`}>
38-
<DrawingId>#{drawing.id.split('.').slice(-1)}</DrawingId>
39-
</a>
40-
<Date>{drawing.date}</Date>
41-
<Link href="/drawing/[id]" as={`/drawing/${getNextSlug(drawing.slug)}`}>
42-
<Arrow>&gt;</Arrow>
43-
</Link>
44-
</NavBar>
45-
</Container>
26+
<Div100vh>
27+
<Container onKeyDown={onKeyDown} tabIndex={-1}>
28+
<Title>{drawing.title}</Title>
29+
<ImageWrap>
30+
<Image src={`${assetPrefix}/images/${drawing.image}`} alt={drawing.title} />
31+
</ImageWrap>
32+
<NavBar>
33+
<Link href="/drawing/[id]" as={`/drawing/${getPreviousSlug(drawing.slug)}`}>
34+
<Arrow>&lt;</Arrow>
35+
</Link>
36+
<Link href="/year/[id]" as={`/year/${year}`}>
37+
<YearLink>{year}</YearLink>
38+
</Link>
39+
<a href={`http://explodingdog.com/title/${drawing.slug}.html`}>
40+
<DrawingId>#{drawing.id.split('.').slice(-1)}</DrawingId>
41+
</a>
42+
<Date>{drawing.date}</Date>
43+
<Link href="/drawing/[id]" as={`/drawing/${getNextSlug(drawing.slug)}`}>
44+
<Arrow>&gt;</Arrow>
45+
</Link>
46+
</NavBar>
47+
</Container>
48+
</Div100vh>
4649
)
4750
}
4851

4952
const Container = styled.main.attrs({ className: 'Explorer__DrawingPage__Container'})`
5053
display: flex;
5154
flex-direction: column;
5255
justify-content: space-between;
53-
min-height: 100vh;
54-
max-height: 100vh;
56+
height: 100%;
5557
`
5658

5759
const Title = styled.h1.attrs({ className: 'Explorer__DrawingPage__Title'})`
@@ -78,17 +80,18 @@ const NavBar = styled.nav.attrs({ className: 'Explorer__DrawingPage__Header'})`
7880
color: #BBB;
7981
display: flex;
8082
justify-content: space-between;
81-
font-size: 14px;
83+
font-size: 18px;
8284
font-weight: bold;
83-
height: 40px;
84-
line-height: 40px;
85+
height: 80px;
86+
line-height: 80px;
8587
`
8688

8789
const Arrow = styled.div.attrs({ className: 'Explorer__DrawingPage__Arrow'})`
8890
color: black;
8991
cursor: pointer;
90-
font-size: 24px;
91-
padding: 0 32px;
92+
font-size: 36px;
93+
line-height: 74px;
94+
padding: 0 5%;
9295
user-select: none;
9396
9497
&:hover {

explorer/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
"build": "next build && next export",
1010
"start": "next start",
1111
"clean": "rm -rf node_module/.cache && rm -rf out",
12-
"deploy": "yarn clean && yarn build && touch out/.nojekyll && gh-pages -t -d out",
12+
"deploy": "yarn clean && yarn build && touch out/.nojekyll && (NODE_DEBUG=gh-pages gh-pages -t -d out)",
1313
"type-check": "tsc"
1414
},
1515
"dependencies": {
1616
"next": "*",
1717
"react": "^16.12.0",
18+
"react-div-100vh": "^0.5.6",
1819
"react-dom": "^16.12.0",
1920
"styled-components": "^5.2.1"
2021
},

explorer/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3357,6 +3357,11 @@ rc@^1.2.7:
33573357
minimist "^1.2.0"
33583358
strip-json-comments "~2.0.1"
33593359

3360+
react-div-100vh@^0.5.6:
3361+
version "0.5.6"
3362+
resolved "https://registry.yarnpkg.com/react-div-100vh/-/react-div-100vh-0.5.6.tgz#1d73866e96379433dea066d3e55026efd77f4b29"
3363+
integrity sha512-foNzJeBwiWp2Xs+pDhKyX2sP9O8UoGfYyz/D+GgZaHCKS3R+lbtJc8OdgMDr03txXgPVsxGEtmjKeDcLW30xwQ==
3364+
33603365
react-dom@^16.12.0:
33613366
version "16.14.0"
33623367
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.14.0.tgz#7ad838ec29a777fb3c75c3a190f661cf92ab8b89"

0 commit comments

Comments
 (0)