Skip to content

Commit 41dbd6a

Browse files
committed
Let the page scroll
1 parent 759dc28 commit 41dbd6a

8 files changed

Lines changed: 24 additions & 13 deletions

File tree

src/components/DeclarationsPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export default function DeclarationsPage({
138138
const ContentColumn = styled.div`
139139
display: flex;
140140
flex-direction: column;
141-
overflow: hidden;
141+
min-height: 0;
142142
`;
143143

144144
const MobileSidebarOverlay = styled.div`
@@ -182,7 +182,7 @@ const SidebarPanel = styled.div`
182182
const PageGrid = styled.div`
183183
display: grid;
184184
grid-template-columns: 340px 1fr;
185-
height: 100dvh;
185+
min-height: 100dvh;
186186
187187
@media (max-width: 768px) {
188188
grid-template-columns: 1fr;

src/components/Docs/SchemaClass.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ const FieldRow = styled.div`
6363
}
6464
`;
6565

66-
6766
const FieldOffset = styled.button`
6867
background: none;
6968
border: none;
@@ -410,8 +409,9 @@ function SchemaFieldView({
410409
</FieldRow>
411410
{bitfield && bitfield.totalBits > 0 && (
412411
<BitfieldPadding>
413-
{Math.ceil(bitfield.totalBits / 8)} byte{Math.ceil(bitfield.totalBits / 8) !== 1 ? "s" : ""}{" "}
414-
({bitfield.totalBits} bit{bitfield.totalBits !== 1 ? "s" : ""}
412+
{Math.ceil(bitfield.totalBits / 8)} byte
413+
{Math.ceil(bitfield.totalBits / 8) !== 1 ? "s" : ""} ({bitfield.totalBits} bit
414+
{bitfield.totalBits !== 1 ? "s" : ""}
415415
{bitfield.padding > 0 ? ` + ${bitfield.padding} padding` : ""})
416416
</BitfieldPadding>
417417
)}

src/components/Docs/SchemaEnum.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ const EnumMemberWrapper = styled.div`
6060
}
6161
`;
6262

63-
6463
const EnumMemberHex = styled.span`
6564
font-family: var(--font-mono);
6665
font-size: 14px;

src/components/Lists.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useRef } from "react";
2-
import { useVirtualizer } from "@tanstack/react-virtual";
2+
import { useVirtualizer, useWindowVirtualizer } from "@tanstack/react-virtual";
33

44
interface Props<T> {
55
data: T[];
@@ -8,14 +8,22 @@ interface Props<T> {
88

99
export function LazyList<T>({ data, render }: Props<T>) {
1010
const parentRef = useRef<HTMLDivElement>(null);
11+
const parentOffsetRef = useRef(0);
1112

12-
const virtualizer = useVirtualizer({
13+
const virtualizer = useWindowVirtualizer({
1314
count: data.length,
14-
getScrollElement: () => parentRef.current?.parentElement ?? null,
1515
estimateSize: () => 80,
1616
overscan: 10,
17+
scrollMargin: parentOffsetRef.current,
1718
});
1819

20+
// Capture offset once on mount
21+
React.useLayoutEffect(() => {
22+
if (parentRef.current) {
23+
parentOffsetRef.current = parentRef.current.getBoundingClientRect().top + window.scrollY;
24+
}
25+
}, []);
26+
1927
return (
2028
<div ref={parentRef}>
2129
<div style={{ height: virtualizer.getTotalSize(), position: "relative" }}>
@@ -29,7 +37,7 @@ export function LazyList<T>({ data, render }: Props<T>) {
2937
top: 0,
3038
left: 0,
3139
width: "100%",
32-
transform: `translateY(${virtualRow.start}px)`,
40+
transform: `translateY(${virtualRow.start - parentOffsetRef.current}px)`,
3341
}}
3442
>
3543
{render(data[virtualRow.index])}

src/components/layout/Content.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { styled } from "@linaria/react";
22

33
export const ContentWrapper = styled.main`
4-
flex: 1;
54
padding: 0 24px 24px 24px;
65
min-width: 0;
7-
overflow-y: auto;
86
97
@media (max-width: 768px) {
108
grid-column: 1;

src/components/layout/NavBar.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ const NavBarContentCell = styled.div`
199199
padding: 10px 14px 10px 24px;
200200
min-width: 0;
201201
flex-shrink: 0;
202+
position: sticky;
203+
top: 0;
204+
z-index: 10;
202205
background-color: var(--background);
203206
204207
@media (max-width: 768px) {

src/components/layout/Sidebar.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,8 @@ export const SidebarWrapper = styled.div`
116116
min-width: 0;
117117
padding: 6px 8px 4px 10px;
118118
background-color: var(--sidebar);
119+
position: sticky;
120+
top: 0;
121+
height: 100dvh;
122+
align-self: start;
119123
`;

src/global.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ html,
5757
body,
5858
#root {
5959
width: 100%;
60-
height: 100%;
6160
margin: 0;
6261
background-color: var(--background);
6362
scrollbar-gutter: stable;

0 commit comments

Comments
 (0)