Correctly resize full width images when table of contents is opened/closed (#5826)

* stash

* restore

* Self review
This commit is contained in:
Tom Moor
2023-09-12 21:33:25 -04:00
committed by GitHub
parent d81db7e4f6
commit b80ee89588
6 changed files with 86 additions and 69 deletions

View File

@@ -10,7 +10,9 @@ import useWindowScrollPosition from "~/hooks/useWindowScrollPosition";
const HEADING_OFFSET = 20;
type Props = {
/** Whether the document is rendering full width or not. */
isFullWidth: boolean;
/** The headings to render in the contents. */
headings: {
title: string;
level: number;
@@ -45,7 +47,7 @@ export default function Contents({ headings, isFullWidth }: Props) {
// calculate the minimum heading level and adjust all the headings to make
// that the top-most. This prevents the contents from being weirdly indented
// if all of the headings in the document are level 3, for example.
// if all of the headings in the document start at level 3, for example.
const minHeading = headings.reduce(
(memo, heading) => (heading.level < memo ? heading.level : memo),
Infinity