File tree Expand file tree Collapse file tree 4 files changed +57
-21
lines changed Expand file tree Collapse file tree 4 files changed +57
-21
lines changed Original file line number Diff line number Diff line change @@ -17,24 +17,7 @@ export const AppStyle = createGlobalStyle`
1717 text-decoration: none;
1818
1919 &:visited {
20- color: lightgrey;
21- }
22-
23- &::after {
24- background: currentColor;
25- bottom: -2px;
26- display: block;
27- content: '';
28- height: 1px;
29- left: 0;
30- opacity: 0.2;
31- position: absolute;
32- right: 0;
33-
34- }
35-
36- &:hover {
37- background: rgba(128,128,128,0.07);
20+ color: #BBB;
3821 }
3922 }
4023`
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export const HomePage = () => (
1515
1616 < DrawingsByYearSection >
1717 < h2 > drawings by year:</ h2 >
18- < ol className = "years" >
18+ < ol >
1919 { drawingYears . sort ( ) . reverse ( ) . map ( year => (
2020 < li key = { year } >
2121 < Link href = "/year/[id]" as = { `/year/${ year } ` } >
Original file line number Diff line number Diff line change 1+ import React from 'react'
2+ import { drawingYears } from '../__fixtures__/drawings'
3+ import styled from 'styled-components'
4+ import Link from 'next/link'
5+
6+ export const YearBar : React . FC < { activeYear : number } > = ( { activeYear } ) => {
7+ return (
8+ < YearList >
9+ { drawingYears . sort ( ) . reverse ( ) . map ( year => (
10+ < YearItem key = { year } isActive = { year === activeYear } >
11+ { year === activeYear ? (
12+ < b > { year } </ b >
13+ ) : (
14+ < Link href = "/year/[id]" as = { `/year/${ year } ` } >
15+ < a > { year } </ a >
16+ </ Link >
17+ ) }
18+ </ YearItem >
19+ ) ) }
20+ </ YearList >
21+ )
22+ }
23+
24+ const YearList = styled . ol . attrs ( { className : 'Explorer__YearBar__YearList' } ) `
25+ background: white;
26+ padding: 0 16px;
27+ position: sticky;
28+ top: 0;
29+ z-index: 100;
30+ `
31+
32+ const YearItem = styled . li . attrs ( { className : 'Explorer__YearBar__YearItem' } ) < { isActive : boolean } > `
33+ display: inline-block;
34+ font-size: 12px;
35+ margin: 8px 10px;
36+ position: relative;
37+
38+ ${ o => o . isActive && `
39+ &::after {
40+ background: currentColor;
41+ bottom: -2px;
42+ display: block;
43+ content: '';
44+ height: 2px;
45+ left: 0;
46+ opacity: 0.8;
47+ position: absolute;
48+ right: 0;
49+ }
50+ ` }
51+ `
Original file line number Diff line number Diff line change @@ -2,14 +2,16 @@ import { Drawing } from '../types/drawing-models'
22import { PageLayout } from './PageLayout'
33import { DrawingTile } from './DrawingTile'
44import styled from 'styled-components'
5+ import { YearBar } from './YearBar'
56
67export const YearPage = ( { year, drawings } : {
78 year : number
89 drawings ?: Drawing [ ]
910} ) => {
1011 return (
1112 < PageLayout title = { `explodingdog ${ year } ` } >
12- < Heading > { year } </ Heading >
13+ < YearBar activeYear = { year } />
14+ < YearHeading > { year } </ YearHeading >
1315 < DrawingSection >
1416 { drawings && drawings . map ( drawing => (
1517 < DrawingTile key = { drawing . slug } { ...drawing } />
@@ -19,7 +21,7 @@ export const YearPage = ({ year, drawings }: {
1921 )
2022}
2123
22- const Heading = styled . h1 . attrs ( { className : 'Explorer__YearPage__Heading ' } ) `
24+ const YearHeading = styled . h1 . attrs ( { className : 'Explorer__YearPage__YearHeading ' } ) `
2325 font-size: 64px;
2426 text-indent: 48px;
2527`
You can’t perform that action at this time.
0 commit comments