diff --git a/.changeset/heavy-bees-ring.md b/.changeset/heavy-bees-ring.md new file mode 100644 index 00000000..52132c7a --- /dev/null +++ b/.changeset/heavy-bees-ring.md @@ -0,0 +1,7 @@ +--- +"@myst-theme/site": patch +"@myst-theme/article": patch +"@myst-theme/book": patch +--- + +🔍 Make document outline collapsible diff --git a/packages/search-minisearch/package.json b/packages/search-minisearch/package.json index 02fb299f..1d8da2e5 100644 --- a/packages/search-minisearch/package.json +++ b/packages/search-minisearch/package.json @@ -13,8 +13,6 @@ "clean": "rimraf dist", "lint": "eslint \"src/**/*.ts*\" -c ./.eslintrc.cjs", "lint:format": "prettier --check \"src/**/*.{ts,tsx,md}\"", - "test": "vitest run", - "test:watch": "vitest watch", "build:esm": "tsc --project ./tsconfig.json --module Node16 --outDir dist --declaration", "build": "npm-run-all -l clean -p build:esm" }, diff --git a/packages/search/package.json b/packages/search/package.json index 20f7ccf4..ea3d9a4a 100644 --- a/packages/search/package.json +++ b/packages/search/package.json @@ -13,8 +13,6 @@ "clean": "rimraf dist", "lint": "eslint \"src/**/*.ts*\" -c ./.eslintrc.cjs", "lint:format": "prettier --check \"src/**/*.{ts,tsx,md}\"", - "test": "vitest run", - "test:watch": "vitest watch", "build:esm": "tsc --project ./tsconfig.json --module Node16 --outDir dist --declaration", "build": "npm-run-all -l clean -p build:esm" }, diff --git a/packages/site/src/components/DocumentOutline.tsx b/packages/site/src/components/DocumentOutline.tsx index 494bca3a..d3cd63a3 100644 --- a/packages/site/src/components/DocumentOutline.tsx +++ b/packages/site/src/components/DocumentOutline.tsx @@ -8,10 +8,12 @@ import { useNavigation } from '@remix-run/react'; import classNames from 'classnames'; import throttle from 'lodash.throttle'; import React, { useCallback, useEffect, useRef, useState } from 'react'; +import type { RefObject } from 'react'; import { DocumentChartBarIcon } from '@heroicons/react/24/outline'; +import { ChevronRightIcon } from '@heroicons/react/24/solid'; +import * as Collapsible from '@radix-ui/react-collapsible'; const SELECTOR = [1, 2, 3, 4].map((n) => `main h${n}`).join(', '); -const HIGHLIGHT_CLASS = 'highlight'; const onClient = typeof document !== 'undefined'; @@ -25,15 +27,13 @@ export type Heading = { type Props = { headings: Heading[]; - selector: string; activeId?: string; - highlight?: () => void; }; /** * This renders an item in the table of contents list. * scrollIntoView is used to ensure that when a user clicks on an item, it will smoothly scroll. */ -const Headings = ({ headings, activeId, highlight, selector }: Props) => ( +const Headings = ({ headings, activeId }: Props) => (