|
| 1 | +import React from 'react' |
| 2 | +import { Drawing } from '../types' |
| 3 | +import Link from 'next/link' |
| 4 | +import { assetPrefix } from '../lib/assetPrefix' |
| 5 | +import styled from 'styled-components' |
| 6 | +import { getPreviousSlug, getNextSlug } from '../lib/drawings' |
| 7 | + |
| 8 | +export const DrawingPage: React.FC<{ drawing: Drawing, year: number }> = ({ drawing, year }) => { |
| 9 | + return ( |
| 10 | + <Container> |
| 11 | + <Title>{drawing.title}</Title> |
| 12 | + <ImageWrap> |
| 13 | + <Image src={`${assetPrefix}/images/${drawing.image}`} alt={drawing.title} /> |
| 14 | + </ImageWrap> |
| 15 | + <NavBar> |
| 16 | + <Link href="/drawing/[id]" as={`/drawing/${getPreviousSlug(drawing.slug)}`}> |
| 17 | + <Arrow><</Arrow> |
| 18 | + </Link> |
| 19 | + <Link href="/year/[id]" as={`/year/${year}`}> |
| 20 | + <YearLink>{year}</YearLink> |
| 21 | + </Link> |
| 22 | + <a href={`http://explodingdog.com/title/${drawing.slug}.html`}> |
| 23 | + <DrawingId>#{drawing.id.split('.').slice(-1)}</DrawingId> |
| 24 | + </a> |
| 25 | + <Date>{drawing.date}</Date> |
| 26 | + <Link href="/drawing/[id]" as={`/drawing/${getNextSlug(drawing.slug)}`}> |
| 27 | + <Arrow>></Arrow> |
| 28 | + </Link> |
| 29 | + </NavBar> |
| 30 | + </Container> |
| 31 | + ) |
| 32 | +} |
| 33 | + |
| 34 | +const Container = styled.main.attrs({ className: 'Explorer__DrawingPage__Container'})` |
| 35 | + display: flex; |
| 36 | + flex-direction: column; |
| 37 | + justify-content: space-between; |
| 38 | + min-height: 100vh; |
| 39 | + max-height: 100vh; |
| 40 | +` |
| 41 | + |
| 42 | +const Title = styled.h1.attrs({ className: 'Explorer__DrawingPage__Title'})` |
| 43 | + font-size: 32px; |
| 44 | + font-weight: bold; |
| 45 | + padding: 16px 24px; |
| 46 | + text-align: center; |
| 47 | +` |
| 48 | + |
| 49 | +const ImageWrap = styled.figure.attrs({ className: 'Explorer__DrawingPage__ImageWrap'})` |
| 50 | + flex-grow: 1; |
| 51 | + position: relative; |
| 52 | +` |
| 53 | + |
| 54 | +const Image = styled.img.attrs({ className: 'Explorer__DrawingPage__Image'})` |
| 55 | + display: block; |
| 56 | + height: 100%; |
| 57 | + object-fit: contain; |
| 58 | + position: absolute; |
| 59 | + width: 100%; |
| 60 | +` |
| 61 | + |
| 62 | +const NavBar = styled.nav.attrs({ className: 'Explorer__DrawingPage__Header'})` |
| 63 | + color: #BBB; |
| 64 | + display: flex; |
| 65 | + justify-content: space-between; |
| 66 | + font-size: 14px; |
| 67 | + font-weight: bold; |
| 68 | + height: 40px; |
| 69 | + line-height: 40px; |
| 70 | +` |
| 71 | + |
| 72 | +const Arrow = styled.div.attrs({ className: 'Explorer__DrawingPage__Arrow'})` |
| 73 | + color: black; |
| 74 | + cursor: pointer; |
| 75 | + font-size: 24px; |
| 76 | + padding: 0 32px; |
| 77 | + user-select: none; |
| 78 | +
|
| 79 | + &:hover { |
| 80 | + background: #f8f8f8; |
| 81 | + } |
| 82 | +` |
| 83 | + |
| 84 | +const YearLink = styled.a.attrs({ className: 'Explorer__DrawingPage__YearLink'})` |
| 85 | + cursor: pointer; |
| 86 | + color: black; |
| 87 | +` |
| 88 | + |
| 89 | +const DrawingId = styled.span.attrs({ className: 'Explorer__DrawingPage__DrawingId'})`` |
| 90 | + |
| 91 | +const Date = styled.span.attrs({ classNamne: 'Explorer__DrawingPage__Date'})`` |
0 commit comments