Skip to content

Commit 43a238d

Browse files
committed
one third for story; arrow up/down for last/next section
1 parent 83a94b9 commit 43a238d

1 file changed

Lines changed: 45 additions & 14 deletions

File tree

index.html

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
top: 0;
6363
left: 0;
6464
height: 100vh;
65-
width: 60vw;
65+
width: 67vw;
6666
position: fixed;
6767
background-color: #fff;
6868
border: 0;
@@ -74,53 +74,53 @@
7474
transition: opacity 0.1s ease-in;
7575
}
7676

77-
h1 { font-size: 2.4em; font-weight: 200; margin-bottom: 0;}
78-
h2 { font-size: 1.8em; }
77+
h1 { font-size: 2.25em; font-weight: 200; margin-bottom: 0;}
78+
h2 { font-size: 1.5em; }
7979
h3 { font-size: 1.4em; }
8080
h4 { font-size: 1.2em; }
8181
h2, h3, h4 { font-weight: 500; }
82+
h1, h2, h3, h4 { margin: .25em 0; }
8283

8384
main {
8485
box-sizing: border-box;
8586
position: absolute;
8687
right: 0;
87-
width: 40vw;
88-
padding: 0 5vh;
88+
width: 33vw;
89+
padding: 0 3vh;
8990
margin: 0;
9091
}
9192

9293
section {
9394
margin-top: 100vh;
94-
margin-bottom: 100vh;
95-
}
96-
97-
section:first-of-type, section:last-of-type {
95+
padding: 1vh 0 0 0;
96+
margin-bottom: 100vh;
97+
min-height: 100vh;
9898
display: flex;
9999
justify-content: center;
100100
flex-direction: column;
101101
}
102102

103-
section:first-of-type {
104-
min-height: 100vh;
103+
section:first-of-type {
105104
margin-top: 0;
106105
}
107106

108107
section:last-of-type {
109-
min-height: 93vh;
110108
margin-bottom: 0;
111109
}
112110

113111
p {
114112
font-size: 1em;
115113
line-height: 1.5em;
114+
margin: .5em 0;
116115
}
117-
116+
118117
a {
119118
color: #000;
120119
}
121120

122121
ul, ol {
123-
padding-left: 1em;
122+
padding-left: 1.25em;
123+
margin: .5em 0;
124124
}
125125

126126
li {
@@ -350,6 +350,37 @@
350350
if (event.key === 'Escape') {
351351
window.scrollTo({ top: 0, behavior: 'smooth' });
352352
}
353+
354+
else if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
355+
const sections = Array.from(document.querySelectorAll('main section'));
356+
if (sections.length === 0) return;
357+
358+
const currentY = window.scrollY;
359+
const viewportHeight = window.innerHeight;
360+
361+
let targetSection = null;
362+
363+
if (event.key === 'ArrowDown') {
364+
targetSection = sections.find(section => {
365+
const rect = section.getBoundingClientRect();
366+
return rect.top > 1; // more than 1px below the viewport top
367+
});
368+
} else if (event.key === 'ArrowUp') {
369+
for (let i = sections.length - 1; i >= 0; i--) {
370+
const rect = sections[i].getBoundingClientRect();
371+
if (rect.bottom < -1) { // completely above the viewport
372+
targetSection = sections[i];
373+
break;
374+
}
375+
}
376+
}
377+
378+
if (targetSection) {
379+
event.preventDefault();
380+
targetSection.scrollIntoView({ behavior: 'smooth' });
381+
}
382+
}
383+
353384
});
354385

355386
// Load, parse, and display markdown on page load

0 commit comments

Comments
 (0)