Correctly resize full width images when table of contents is opened/closed (#5826)
* stash * restore * Self review
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user