summaryrefslogtreecommitdiffstats
path: root/src/components/Widgets/ToC/ToC.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-05-24 19:35:12 +0200
committerGitHub <noreply@github.com>2022-05-24 19:35:12 +0200
commitc85ab5ad43ccf52881ee224672c41ec30021cf48 (patch)
tree8058808d9bfca19383f120c46b34d99ff2f89f63 /src/components/Widgets/ToC/ToC.tsx
parent52404177c07a2aab7fc894362fb3060dff2431a0 (diff)
parent11b9de44a4b2f305a6a484187805e429b2767118 (diff)
refactor: use storybook and atomic design (#16)
BREAKING CHANGE: rewrite most of the Typescript types, so the content format (the meta in particular) needs to be updated.
Diffstat (limited to 'src/components/Widgets/ToC/ToC.tsx')
-rw-r--r--src/components/Widgets/ToC/ToC.tsx55
1 files changed, 0 insertions, 55 deletions
diff --git a/src/components/Widgets/ToC/ToC.tsx b/src/components/Widgets/ToC/ToC.tsx
deleted file mode 100644
index 3f759db..0000000
--- a/src/components/Widgets/ToC/ToC.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-import { ExpandableWidget, OrderedList } from '@components/WidgetParts';
-import { Heading } from '@ts/types/app';
-import useHeadingsTree from '@utils/hooks/useHeadingsTree';
-import { FormattedMessage, useIntl } from 'react-intl';
-
-const ToC = () => {
- const intl = useIntl();
- const headingsTree = useHeadingsTree('article');
- const title = intl.formatMessage({
- defaultMessage: 'Table of contents',
- description: 'ToC: widget title',
- id: 'Zg4L7U',
- });
-
- const getItems = (headings: Heading[]) => {
- return headings.map((heading) => {
- return (
- <li key={heading.id}>
- <a href={`#${heading.id}`}>
- <FormattedMessage
- defaultMessage="<a11y>Jump to </a11y>{title}"
- description="ToC: link"
- id="GgIWnN"
- values={{
- title: heading.title,
- a11y: (chunks: string) => (
- <span className="screen-reader-text">{chunks}</span>
- ),
- }}
- />
- </a>
- {heading.children.length > 0 && (
- <OrderedList items={getItems(heading.children)} />
- )}
- </li>
- );
- });
- };
-
- return (
- <ExpandableWidget title={title} kind="toc" expand={true} withBorders={true}>
- <noscript>
- {intl.formatMessage({
- defaultMessage:
- 'Javascript is required to use the table of contents.',
- description: 'ToC: noscript tag',
- id: 'RZzx/4',
- })}
- </noscript>
- <OrderedList items={getItems(headingsTree)} />
- </ExpandableWidget>
- );
-};
-
-export default ToC;