-
-
Notifications
You must be signed in to change notification settings - Fork 982
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Table of Contents from @swmansion/t-rex-ui
- Loading branch information
1 parent
6fb2104
commit e77c3ca
Showing
4 changed files
with
9 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { TOCCollapsible } from '@swmansion/t-rex-ui'; | ||
|
||
export default TOCCollapsible; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { TOCItems } from '@swmansion/t-rex-ui'; | ||
|
||
export default TOCItems; |
This file was deleted.
Oops, something went wrong.