diff --git a/.changeset/calm-socks-learn.md b/.changeset/calm-socks-learn.md new file mode 100644 index 000000000..27996e37e --- /dev/null +++ b/.changeset/calm-socks-learn.md @@ -0,0 +1,5 @@ +--- +'@myst-theme/site': patch +--- + +Change height intersect calculation for `useOutlineHeight` to include container offset. diff --git a/.changeset/eleven-pugs-cover.md b/.changeset/eleven-pugs-cover.md new file mode 100644 index 000000000..7cf2de278 --- /dev/null +++ b/.changeset/eleven-pugs-cover.md @@ -0,0 +1,6 @@ +--- +'@myst-theme/article': patch +'@myst-theme/site': patch +--- + +Add supporting documents export from MyST Site diff --git a/.changeset/flat-spoons-cheat.md b/.changeset/flat-spoons-cheat.md new file mode 100644 index 000000000..2149de17b --- /dev/null +++ b/.changeset/flat-spoons-cheat.md @@ -0,0 +1,5 @@ +--- +'@myst-theme/site': patch +--- + +Allow document outline to have children diff --git a/.changeset/friendly-flowers-push.md b/.changeset/friendly-flowers-push.md new file mode 100644 index 000000000..5264d824b --- /dev/null +++ b/.changeset/friendly-flowers-push.md @@ -0,0 +1,6 @@ +--- +'@myst-theme/article': patch +'@myst-theme/site': patch +--- + +Remove the minimum height from the banner diff --git a/packages/site/src/components/DocumentOutline.tsx b/packages/site/src/components/DocumentOutline.tsx index 5a4a2e9c7..bc8baf492 100644 --- a/packages/site/src/components/DocumentOutline.tsx +++ b/packages/site/src/components/DocumentOutline.tsx @@ -1,7 +1,14 @@ +import { + useBaseurl, + useNavLinkProvider, + useSiteManifest, + withBaseurl, +} from '@myst-theme/providers'; import { useNavigation } from '@remix-run/react'; import classNames from 'classnames'; import throttle from 'lodash.throttle'; -import { useCallback, useEffect, useRef, useState } from 'react'; +import React, { useCallback, useEffect, useRef, useState } from 'react'; +import DocumentChartBarIcon from '@heroicons/react/24/outline/DocumentChartBarIcon'; const SELECTOR = [1, 2, 3, 4].map((n) => `main h${n}`).join(', '); const HIGHLIGHT_CLASS = 'highlight'; @@ -180,13 +187,15 @@ const useIntersectionObserver = (highlight: () => void, onScreen: Set() { +export function useOutlineHeight( + existingContainer?: React.RefObject, +) { const container = useRef(null); const outline = useRef(null); const transitionState = useNavigation().state; const setHeight = () => { if (!container.current || !outline.current) return; - const height = container.current.offsetHeight - window.scrollY; + const height = container.current.offsetHeight - window.scrollY + container.current.offsetTop; outline.current.style.display = height < 50 ? 'none' : ''; outline.current.style.height = height > window.innerHeight ? '' : `${height}px`; outline.current.style.opacity = height && height > 300 ? '' : '0'; @@ -201,6 +210,11 @@ export function useOutlineHeight() { window.removeEventListener('scroll', handleScroll); }; }, [container.current, outline.current, transitionState]); + + useEffect(() => { + if (!existingContainer || !existingContainer.current) return; + (container as any).current = existingContainer.current; + }, [existingContainer?.current]); return { container, outline }; } @@ -209,16 +223,18 @@ export const DocumentOutline = ({ top, className, selector = SELECTOR, + children, }: { outlineRef?: React.RefObject; top?: number; height?: number; className?: string; selector?: string; + children?: React.ReactNode; }) => { const { activeId, headings, highlight } = useHeaders(selector); if (headings.length <= 1 || !onClient) { - return