Skip to content

Commit

Permalink
Use Table of Contents from @swmansion/t-rex-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
patrycjakalinska committed May 13, 2024
1 parent 6fb2104 commit e77c3ca
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 50 deletions.
3 changes: 3 additions & 0 deletions docs/src/theme/TOCCollapsible/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { TOCCollapsible } from '@swmansion/t-rex-ui';

export default TOCCollapsible;
38 changes: 3 additions & 35 deletions docs/src/theme/TOCItems/Tree.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,3 @@
import React from 'react';
import styles from './styles.module.css';
import clsx from 'clsx';
// Recursive component rendering the toc tree
function TOCItemTree({ toc, className, linkClassName, isChild }) {
if (!toc.length) {
return null;
}
return (
<ul className={clsx(styles.tocItems, isChild ? undefined : className)}>
{toc.map((heading) => (
<li key={heading.id}>
{/* eslint-disable-next-line jsx-a11y/control-has-associated-label */}
<a
href={`#${heading.id}`}
className={linkClassName ?? undefined}
// Developer provided the HTML, so assume it's safe.
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{
__html: `<span>${heading.value}</span>`,
}}
/>
<TOCItemTree
isChild
toc={heading.children}
className={className}
linkClassName={linkClassName}
/>
</li>
))}
</ul>
);
}
// Memo only the tree root is enough
export default React.memo(TOCItemTree);
import { TOCItemTree } from '@swmansion/t-rex-ui';

export default TOCItemTree;
3 changes: 3 additions & 0 deletions docs/src/theme/TOCItems/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { TOCItems } from '@swmansion/t-rex-ui';

export default TOCItems;
15 changes: 0 additions & 15 deletions docs/src/theme/TOCItems/styles.module.css

This file was deleted.

0 comments on commit e77c3ca

Please sign in to comment.