Skip to content

Commit

Permalink
wip(curriculum): show 'in this module' above toc
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoMcA committed Feb 2, 2024
1 parent d8388dd commit 0afaab0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion client/src/curriculum/module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ export function CurriculumModule(props: HydrationData<any, CurriculumDoc>) {
<div className="toc-container">
<aside className="toc">
<nav>
{doc.toc && !!doc.toc.length && <TOC toc={doc.toc} />}
{doc.toc && !!doc.toc.length && (
<TOC toc={doc.toc} title="In this module" />
)}
</nav>
</aside>
{PLACEMENT_ENABLED && <SidePlacement />}
Expand Down
6 changes: 4 additions & 2 deletions client/src/document/organisms/toc/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useFirstVisibleElement } from "../../hooks";
import { useGleanClick } from "../../../telemetry/glean-context";
import { TOC_CLICK } from "../../../telemetry/constants";

export function TOC({ toc }: { toc: Toc[] }) {
export function TOC({ toc, title }: { toc: Toc[]; title?: string }) {
const [currentViewedTocItem, setCurrentViewedTocItem] = useState("");

const observedElements = React.useCallback(() => {
Expand Down Expand Up @@ -44,7 +44,9 @@ export function TOC({ toc }: { toc: Toc[] }) {
<div className="document-toc-container">
<section className="document-toc">
<header>
<h2 className="document-toc-heading">In this article</h2>
<h2 className="document-toc-heading">
{title || "In this article"}
</h2>
</header>
<ul className="document-toc-list">
{toc.map((item) => {
Expand Down

0 comments on commit 0afaab0

Please sign in to comment.