@redocly/theme 0.1.8 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Button/index.d.ts +1 -1
- package/Button/index.js +1 -1
- package/CodeBlock/index.d.ts +1 -1
- package/CodeBlock/index.js +1 -1
- package/CopyButton/index.d.ts +2 -2
- package/CopyButton/index.js +2 -2
- package/Footer/Footer.d.ts +2 -2
- package/Footer/Footer.js +6 -5
- package/Footer/FooterColumn.d.ts +1 -1
- package/Footer/FooterColumn.js +8 -7
- package/Footer/FooterColumns.d.ts +3 -3
- package/Footer/FooterColumns.js +4 -4
- package/Footer/FooterCopyright.d.ts +3 -3
- package/Footer/FooterCopyright.js +3 -2
- package/Footer/index.d.ts +4 -4
- package/Footer/index.js +17 -11
- package/Headings/index.d.ts +1 -1
- package/Headings/index.js +1 -1
- package/JsonViewer/index.d.ts +2 -2
- package/JsonViewer/index.js +2 -2
- package/Layout/PageLayout.d.ts +1 -1
- package/Layout/PageLayout.js +2 -1
- package/Layout/RootLayout.d.ts +1 -1
- package/Layout/RootLayout.js +2 -1
- package/Layout/index.d.ts +2 -2
- package/Layout/index.js +15 -7
- package/Markdown/{Admonition/Admonition.d.ts → Admonition.d.ts} +0 -0
- package/Markdown/{Admonition/Admonition.js → Admonition.js} +5 -5
- package/Markdown/CodeSample/index.d.ts +3 -0
- package/Markdown/CodeSample/index.js +19 -0
- package/Markdown/{Heading/Heading.d.ts → Heading.d.ts} +0 -0
- package/Markdown/{Heading/Heading.js → Heading.js} +1 -1
- package/Markdown/MarkdownLayout.d.ts +2 -2
- package/Markdown/{Mermaid/Mermaid.d.ts → Mermaid.d.ts} +0 -0
- package/Markdown/{Mermaid/Mermaid.js → Mermaid.js} +0 -0
- package/Markdown/StyledMarkdown.js +2 -2
- package/Markdown/Tabs/index.d.ts +2 -0
- package/Markdown/Tabs/index.js +18 -0
- package/Markdown/index.d.ts +9 -0
- package/Markdown/index.js +25 -0
- package/Navbar/Navbar.d.ts +1 -2
- package/Navbar/Navbar.js +3 -3
- package/Navbar/NavbarItem.d.ts +1 -1
- package/Navbar/NavbarItem.js +3 -3
- package/Navbar/NavbarMenu.d.ts +1 -1
- package/Navbar/NavbarMenu.js +5 -4
- package/Navbar/index.d.ts +3 -0
- package/Navbar/index.js +19 -0
- package/NavbarLogo/NavbarLogo.d.ts +6 -0
- package/{Logo/Logo.js → NavbarLogo/NavbarLogo.js} +8 -5
- package/NavbarLogo/index.d.ts +1 -0
- package/NavbarLogo/index.js +17 -0
- package/OperationBadge/index.d.ts +1 -1
- package/OperationBadge/index.js +1 -1
- package/PageNavigation/index.d.ts +3 -0
- package/PageNavigation/index.js +19 -0
- package/Panel/index.d.ts +8 -8
- package/Panel/index.js +8 -8
- package/REAMDE.md +1 -0
- package/SamplesPanelControls/index.d.ts +1 -1
- package/SamplesPanelControls/index.js +1 -1
- package/Search/Autocomplete.js +1 -1
- package/Search/ClearIcon.js +1 -1
- package/Search/Parameters.js +2 -2
- package/Search/SearchIcon.js +1 -1
- package/Search/SearchItem.js +2 -2
- package/Search/index.d.ts +9 -0
- package/Search/index.js +25 -0
- package/Search/utils.js +1 -1
- package/Sidebar/ApiCallItem.d.ts +2 -2
- package/Sidebar/ApiCallItem.js +6 -6
- package/Sidebar/ArrowBack.d.ts +1 -2
- package/Sidebar/ArrowBack.js +2 -1
- package/Sidebar/BackButton.d.ts +1 -1
- package/Sidebar/BackButton.js +5 -4
- package/Sidebar/Drilldown.d.ts +2 -2
- package/Sidebar/Drilldown.js +8 -7
- package/Sidebar/DrilldownMenu.d.ts +2 -2
- package/Sidebar/DrilldownMenu.js +5 -7
- package/Sidebar/DrilldownMenuItem.d.ts +2 -2
- package/Sidebar/DrilldownMenuItem.js +5 -4
- package/Sidebar/ExternalIcon.d.ts +1 -2
- package/Sidebar/ExternalIcon.js +2 -1
- package/Sidebar/Menu.d.ts +1 -2
- package/Sidebar/Menu.js +3 -2
- package/Sidebar/MenuContainer.d.ts +1 -2
- package/Sidebar/MenuContainer.js +2 -1
- package/Sidebar/MenuGroup.d.ts +1 -1
- package/Sidebar/MenuGroup.js +6 -6
- package/Sidebar/MenuItem.d.ts +2 -2
- package/Sidebar/MenuItem.js +7 -6
- package/Sidebar/MenuItemLabel.d.ts +1 -2
- package/Sidebar/MenuItemLabel.js +4 -3
- package/Sidebar/MenuLink.d.ts +1 -2
- package/Sidebar/MenuLink.js +3 -2
- package/Sidebar/MenuLinkItem.d.ts +2 -2
- package/Sidebar/MenuLinkItem.js +4 -3
- package/Sidebar/MobileSidebarButton.d.ts +1 -2
- package/Sidebar/MobileSidebarButton.js +3 -2
- package/Sidebar/Separator.d.ts +2 -2
- package/Sidebar/Separator.js +5 -4
- package/Sidebar/SeparatorItem.d.ts +1 -2
- package/Sidebar/SeparatorItem.js +3 -2
- package/Sidebar/SeparatorLine.d.ts +1 -2
- package/Sidebar/SeparatorLine.js +2 -1
- package/Sidebar/Sidebar.d.ts +2 -2
- package/Sidebar/Sidebar.js +3 -2
- package/Sidebar/SidebarLayout.d.ts +1 -1
- package/Sidebar/SidebarLayout.js +6 -5
- package/Sidebar/index.d.ts +19 -0
- package/Sidebar/index.js +35 -0
- package/Sidebar/types/DrilldownMenuProps.d.ts +2 -2
- package/Sidebar/types/ItemState.d.ts +2 -3
- package/Sidebar/types/MenuItemProps.d.ts +2 -2
- package/Sidebar/types/NavItem.d.ts +1 -1
- package/Sidebar/types/index.d.ts +5 -0
- package/Sidebar/types/index.js +21 -0
- package/SidebarLogo/index.d.ts +1 -1
- package/SidebarLogo/index.js +1 -1
- package/SourceCode/index.d.ts +1 -1
- package/SourceCode/index.js +1 -1
- package/TableOfContent/TableOfContent.d.ts +1 -1
- package/TableOfContent/TableOfContent.js +9 -9
- package/TableOfContent/index.d.ts +1 -0
- package/TableOfContent/index.js +17 -0
- package/Tooltip/index.d.ts +1 -1
- package/Tooltip/index.js +1 -1
- package/globalStyle.d.ts +1 -0
- package/globalStyle.js +7 -3
- package/hooks/index.d.ts +7 -7
- package/hooks/index.js +7 -7
- package/hooks/useActiveSectionId.d.ts +2 -2
- package/hooks/useActiveSectionId.js +1 -0
- package/icons/ShelfIcon/index.d.ts +2 -2
- package/icons/ShelfIcon/index.js +1 -1
- package/icons/index.d.ts +1 -1
- package/icons/index.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/mocks/Link.js +4 -1
- package/mocks/hooks/usePageData.js +4 -1
- package/package.json +1 -1
- package/src/Button/Button.stories.tsx +1 -1
- package/src/Button/index.ts +1 -1
- package/src/CodeBlock/index.ts +1 -1
- package/src/CopyButton/CopyButton.stories.tsx +1 -1
- package/src/CopyButton/index.ts +2 -2
- package/src/DesignTokens/borders.stories.mdx +20 -0
- package/src/DesignTokens/colors.stories.mdx +24 -0
- package/src/DesignTokens/page-layout.stories.mdx +12 -0
- package/src/DesignTokens/tokens-generated.scss +610 -0
- package/src/DesignTokens/typography.stories.mdx +36 -0
- package/src/Footer/Footer.stories.tsx +57 -0
- package/src/Footer/Footer.tsx +7 -10
- package/src/Footer/FooterColumn.tsx +8 -8
- package/src/Footer/FooterColumns.tsx +5 -3
- package/src/Footer/FooterCopyright.tsx +6 -4
- package/src/Footer/__tests__/Footer.test.tsx +55 -0
- package/src/Footer/__tests__/__snapshots__/Footer.test.tsx.snap +253 -0
- package/src/Footer/index.ts +4 -0
- package/src/Headings/index.ts +1 -1
- package/src/JsonViewer/JsonViewer.stories.tsx +1 -1
- package/src/JsonViewer/index.ts +2 -2
- package/src/Layout/PageLayout.tsx +1 -1
- package/src/Layout/RootLayout.tsx +1 -1
- package/src/Layout/__tests__/PageLayout.test.tsx +17 -0
- package/src/Layout/__tests__/RootLayout.test.tsx +17 -0
- package/src/Layout/__tests__/__snapshots__/PageLayout.test.tsx.snap +38 -0
- package/src/Layout/__tests__/__snapshots__/RootLayout.test.tsx.snap +18 -0
- package/src/Layout/index.ts +2 -0
- package/src/Markdown/{Admonition/Admonition.tsx → Admonition.tsx} +15 -15
- package/src/Markdown/CodeSample/index.ts +3 -0
- package/src/Markdown/{Heading/Heading.tsx → Heading.tsx} +4 -1
- package/src/Markdown/MarkdownLayout.tsx +2 -2
- package/src/Markdown/{Mermaid/Mermaid.tsx → Mermaid.tsx} +0 -0
- package/src/Markdown/StyledMarkdown.tsx +27 -27
- package/src/Markdown/Tabs/index.ts +2 -0
- package/src/Markdown/index.ts +9 -0
- package/src/Navbar/Navbar.stories.tsx +10 -6
- package/src/Navbar/Navbar.tsx +3 -4
- package/src/Navbar/NavbarItem.tsx +2 -2
- package/src/Navbar/NavbarMenu.tsx +3 -3
- package/src/Navbar/__tests__/Navbar.test.tsx +55 -0
- package/src/Navbar/__tests__/__snapshots__/Navbar.test.tsx.snap +256 -0
- package/src/Navbar/index.ts +3 -0
- package/src/NavbarLogo/NavbarLogo.stories.tsx +20 -0
- package/src/NavbarLogo/NavbarLogo.tsx +24 -0
- package/src/NavbarLogo/__tests__/NavbarLogo.test.tsx +47 -0
- package/src/NavbarLogo/__tests__/__snapshots__/NavbarLogo.test.tsx.snap +38 -0
- package/src/NavbarLogo/index.ts +1 -0
- package/src/OperationBadge/OperationBadge.stories.tsx +1 -1
- package/src/OperationBadge/index.ts +1 -1
- package/src/PageNavigation/PageNavigation.stories.tsx +21 -0
- package/src/PageNavigation/__tests__/NextPageLink.test.tsx +29 -0
- package/src/PageNavigation/__tests__/PageNavigation.test.tsx +54 -0
- package/src/PageNavigation/__tests__/PreviousPageLink.test.tsx +29 -0
- package/src/PageNavigation/__tests__/__snapshots__/NextPageLink.test.tsx.snap +67 -0
- package/src/PageNavigation/__tests__/__snapshots__/PageNavigation.test.tsx.snap +275 -0
- package/src/PageNavigation/__tests__/__snapshots__/PreviousPageLink.test.tsx.snap +67 -0
- package/src/PageNavigation/index.ts +3 -0
- package/src/Panel/index.ts +8 -8
- package/src/SamplesPanelControls/SamplesControlButton.stories.tsx +1 -1
- package/src/SamplesPanelControls/index.ts +1 -1
- package/src/Search/Autocomplete.tsx +1 -1
- package/src/Search/ClearIcon.tsx +11 -12
- package/src/Search/Parameters.tsx +2 -2
- package/src/Search/SearchIcon.tsx +11 -12
- package/src/Search/SearchItem.tsx +2 -2
- package/src/Search/__tests__/Input.test.tsx +13 -0
- package/src/Search/__tests__/__snapshots__/Input.test.tsx.snap +36 -0
- package/src/Search/index.ts +9 -0
- package/src/Search/utils.tsx +1 -1
- package/src/Sidebar/ApiCallItem.tsx +5 -5
- package/src/Sidebar/ArrowBack.tsx +1 -1
- package/src/Sidebar/BackButton.tsx +4 -4
- package/src/Sidebar/Drilldown.tsx +6 -6
- package/src/Sidebar/DrilldownMenu.tsx +4 -4
- package/src/Sidebar/DrilldownMenuItem.tsx +6 -6
- package/src/Sidebar/ExternalIcon.tsx +1 -1
- package/src/Sidebar/Menu.tsx +2 -2
- package/src/Sidebar/MenuContainer.tsx +1 -1
- package/src/Sidebar/MenuGroup.tsx +5 -5
- package/src/Sidebar/MenuItem.tsx +6 -6
- package/src/Sidebar/MenuItemLabel.tsx +5 -5
- package/src/Sidebar/MenuLink.tsx +2 -2
- package/src/Sidebar/MenuLinkItem.tsx +3 -3
- package/src/Sidebar/MobileSidebarButton.tsx +3 -3
- package/src/Sidebar/Separator.tsx +4 -4
- package/src/Sidebar/SeparatorItem.tsx +2 -2
- package/src/Sidebar/SeparatorLine.tsx +1 -1
- package/src/Sidebar/Sidebar.tsx +2 -2
- package/src/Sidebar/SidebarLayout.tsx +4 -4
- package/src/Sidebar/index.ts +19 -0
- package/src/Sidebar/types/DrilldownMenuProps.ts +2 -2
- package/src/Sidebar/types/ItemState.ts +2 -4
- package/src/Sidebar/types/MenuItemProps.ts +2 -2
- package/src/Sidebar/types/NavItem.ts +1 -1
- package/src/Sidebar/types/index.ts +5 -0
- package/src/SidebarLogo/SidebarLogo.stories.tsx +1 -1
- package/src/SidebarLogo/index.ts +1 -1
- package/src/SourceCode/SourceCode.stories.tsx +1 -1
- package/src/SourceCode/index.ts +1 -1
- package/src/TableOfContent/TableOfContent.stories.tsx +37 -0
- package/src/TableOfContent/TableOfContent.tsx +13 -11
- package/src/TableOfContent/__tests__/TableOfContent.test.tsx +61 -0
- package/src/TableOfContent/__tests__/__snapshots__/TableOfContent.test.tsx.snap +153 -0
- package/src/TableOfContent/index.ts +1 -0
- package/src/Tooltip/Tooltip.stories.tsx +1 -1
- package/src/Tooltip/index.ts +1 -1
- package/src/Welcome.stories.mdx +7 -0
- package/src/globalStyle.ts +333 -144
- package/src/hooks/index.ts +7 -7
- package/src/hooks/useActiveSectionId.ts +3 -3
- package/src/icons/ShelfIcon/index.ts +2 -2
- package/src/icons/index.ts +1 -1
- package/src/index.ts +1 -0
- package/src/mocks/Link.tsx +5 -2
- package/src/mocks/hooks/usePageData.ts +4 -1
- package/src/types/portal/index.d.ts +0 -1
- package/src/types/portal/src/client/app/Sidebar/types.d.ts +32 -41
- package/src/types/portal/src/client/app/media-css.d.ts +4 -4
- package/src/types/portal/src/client/styling/default.d.ts +585 -391
- package/src/types/portal/src/client/styling/index.d.ts +2 -6
- package/src/types/portal/src/server/constants.d.ts +5 -9
- package/src/types/portal/src/server/plugins/markdown/types.d.ts +14 -19
- package/src/types/portal/src/server/plugins/portal-config/types.d.ts +12 -12
- package/src/types/portal/src/server/plugins/types.d.ts +55 -0
- package/src/types/portal/src/server/store.d.ts +49 -97
- package/src/types/portal/src/server/utils/async.d.ts +1 -5
- package/src/types/portal/src/server/utils/content-provider.d.ts +51 -0
- package/src/types/portal/src/server/utils/index.d.ts +1 -1
- package/src/types/portal/src/server/utils/paths.d.ts +10 -13
- package/src/types/portal/src/server/utils/reporter/formatter.d.ts +8 -8
- package/src/types/portal/src/server/utils/reporter/reporter.d.ts +15 -15
- package/src/types/portal/src/server/version-store.d.ts +35 -0
- package/src/types/portal/src/shared/constants.d.ts +6 -6
- package/src/types/portal/src/shared/types.d.ts +97 -58
- package/src/types/portal/src/shared/urls.d.ts +2 -1
- package/src/ui/AlertIcon.tsx +8 -7
- package/src/ui/{Arrow/Arrow.tsx → Arrow.tsx} +0 -0
- package/src/ui/Background.tsx +3 -3
- package/src/ui/Dropdown.tsx +5 -5
- package/src/ui/Jumbotron.tsx +3 -3
- package/src/ui/Tiles/TileHeader.ts +1 -1
- package/src/ui/Tiles/TileText.tsx +2 -2
- package/src/ui/Tiles/index.ts +4 -0
- package/src/ui/Typography.tsx +22 -22
- package/src/ui/UniversalLink.tsx +2 -2
- package/src/ui/index.tsx +8 -3
- package/src/utils/isUrl.ts +1 -1
- package/src/utils/replaceHashInColor.ts +1 -1
- package/ui/AlertIcon.d.ts +3 -2
- package/ui/AlertIcon.js +2 -2
- package/ui/{Arrow/Arrow.d.ts → Arrow.d.ts} +0 -0
- package/ui/{Arrow/Arrow.js → Arrow.js} +0 -0
- package/ui/Background.js +1 -1
- package/ui/Dropdown.d.ts +1 -1
- package/ui/Dropdown.js +5 -4
- package/ui/Jumbotron.js +3 -3
- package/ui/Tiles/TileHeader.js +1 -1
- package/ui/Tiles/TileText.js +1 -1
- package/ui/Tiles/index.d.ts +4 -0
- package/ui/Tiles/index.js +20 -0
- package/ui/Typography.js +20 -20
- package/ui/UniversalLink.js +4 -4
- package/ui/index.d.ts +7 -3
- package/ui/index.js +7 -3
- package/utils/isUrl.d.ts +1 -1
- package/utils/isUrl.js +2 -1
- package/utils/replaceHashInColor.d.ts +1 -1
- package/utils/replaceHashInColor.js +2 -1
- package/Logo/Logo.d.ts +0 -5
- package/src/Footer/index.tsx +0 -4
- package/src/Introduction.stories.mdx +0 -7
- package/src/Layout/index.tsx +0 -2
- package/src/Logo/Logo.tsx +0 -17
- package/src/types/portal/src/server/plugins/nav-utils.d.ts +0 -19
- package/src/types/portal/src/server/plugins/sidebars/index.d.ts +0 -16
- package/src/types/portal/src/server/plugins/versions/index.d.ts +0 -15
- package/src/types/portal/src/server/plugins/versions/types.d.ts +0 -23
- package/src/types/portal/src/server/plugins/versions/utils.d.ts +0 -10
- package/src/types/portal/src/server/utils/watcher.d.ts +0 -16
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
3
|
+
import { ThemeProvider } from 'styled-components';
|
|
4
|
+
|
|
5
|
+
import { TableOfContent } from '@theme/TableOfContent';
|
|
6
|
+
import { generateMediaQueries } from '@theme/utils/media-css';
|
|
7
|
+
|
|
8
|
+
const breakpoints = { small: '1rem', medium: '1rem', large: '1rem' };
|
|
9
|
+
|
|
10
|
+
const theme = {
|
|
11
|
+
mediaQueries: generateMediaQueries(breakpoints),
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
title: 'Portal/TableOfContent',
|
|
16
|
+
component: TableOfContent,
|
|
17
|
+
decorators: [
|
|
18
|
+
(Story) => (
|
|
19
|
+
<ThemeProvider theme={theme}>
|
|
20
|
+
<Story />
|
|
21
|
+
</ThemeProvider>
|
|
22
|
+
),
|
|
23
|
+
],
|
|
24
|
+
} as ComponentMeta<typeof TableOfContent>;
|
|
25
|
+
|
|
26
|
+
const Template: ComponentStory<typeof TableOfContent> = (args) => <TableOfContent {...args} />;
|
|
27
|
+
|
|
28
|
+
export const Default = Template.bind({});
|
|
29
|
+
Default.args = {
|
|
30
|
+
headings: [
|
|
31
|
+
{ id: '1', value: 'test 1', depth: 1 },
|
|
32
|
+
{ id: '2', value: 'test 2', depth: 2 },
|
|
33
|
+
{ id: '3', value: 'test 3', depth: 3 },
|
|
34
|
+
{ id: '4', value: 'test 4', depth: 3 },
|
|
35
|
+
{ id: '5', value: 'test 5', depth: 2 },
|
|
36
|
+
],
|
|
37
|
+
};
|
|
@@ -11,14 +11,14 @@ interface TableOfContentProps {
|
|
|
11
11
|
tocMaxDepth: number;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export
|
|
15
|
-
const { headings, tocMaxDepth } = props;
|
|
14
|
+
export function TableOfContent(props: TableOfContentProps): JSX.Element | null {
|
|
15
|
+
const { headings, tocMaxDepth, contentWrapper } = props;
|
|
16
16
|
|
|
17
17
|
const sidebar = useRef<HTMLDivElement | null>(null);
|
|
18
18
|
useFullHeight(sidebar);
|
|
19
|
-
const activeHeadingId = useActiveHeading(
|
|
19
|
+
const activeHeadingId = useActiveHeading(contentWrapper);
|
|
20
20
|
|
|
21
|
-
if (headings && headings.length === 1 && headings[0]
|
|
21
|
+
if (headings && headings.length === 1 && (!headings[0] || headings[0].depth === 1)) {
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
24
|
if (!headings?.length) {
|
|
@@ -46,8 +46,8 @@ export default function TableOfContent(props: TableOfContentProps): JSX.Element
|
|
|
46
46
|
return (
|
|
47
47
|
<MenuItem
|
|
48
48
|
key={href}
|
|
49
|
-
depth={heading.depth || 0}
|
|
50
49
|
href={href}
|
|
50
|
+
depth={heading.depth || 0}
|
|
51
51
|
className={activeHeadingId === heading.id ? 'active' : ''}
|
|
52
52
|
dangerouslySetInnerHTML={{ __html: heading.value || '' }}
|
|
53
53
|
data-cy={`toc-${heading.value}`}
|
|
@@ -70,7 +70,7 @@ const TocHeader = styled.div`
|
|
|
70
70
|
|
|
71
71
|
const MenuItem = styled.a<{ depth: number }>`
|
|
72
72
|
display: block;
|
|
73
|
-
color: var(--color-
|
|
73
|
+
color: var(--color-content);
|
|
74
74
|
cursor: pointer;
|
|
75
75
|
font-size: 0.8em;
|
|
76
76
|
padding: 10px 15px;
|
|
@@ -78,12 +78,14 @@ const MenuItem = styled.a<{ depth: number }>`
|
|
|
78
78
|
transition: background-color 0.3s, color 0.3s;
|
|
79
79
|
text-decoration: none;
|
|
80
80
|
word-break: break-word;
|
|
81
|
-
font-family: var(--font-family
|
|
81
|
+
font-family: var(--h-font-family);
|
|
82
|
+
|
|
82
83
|
:hover,
|
|
83
84
|
&.active {
|
|
84
|
-
color: var(--sidebar-
|
|
85
|
-
background-color: var(--sidebar-
|
|
85
|
+
color: var(--sidebar-item-active-color);
|
|
86
|
+
background-color: var(--sidebar-item-active-background-color);
|
|
86
87
|
}
|
|
88
|
+
|
|
87
89
|
:empty {
|
|
88
90
|
padding: 0;
|
|
89
91
|
}
|
|
@@ -94,7 +96,7 @@ const TableOfContentMenu = styled.aside`
|
|
|
94
96
|
background-color: transparent;
|
|
95
97
|
flex-shrink: 0;
|
|
96
98
|
display: none !important;
|
|
97
|
-
font-family: var(--font-family-
|
|
99
|
+
font-family: var(--font-family-base);
|
|
98
100
|
|
|
99
101
|
${({ theme }) => theme.mediaQueries.medium} {
|
|
100
102
|
width: var(--toc-width);
|
|
@@ -106,7 +108,7 @@ const TableOfContentItems = styled.div`
|
|
|
106
108
|
position: sticky;
|
|
107
109
|
top: calc(var(--navbar-height) + 20px);
|
|
108
110
|
max-height: calc(100vh - var(--navbar-height) - 20px);
|
|
109
|
-
border-left: 1px solid var(--
|
|
111
|
+
border-left: 1px solid var(--global-border-color);
|
|
110
112
|
overflow-y: auto;
|
|
111
113
|
width: var(--toc-width); ;
|
|
112
114
|
`;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { TableOfContent } from '@theme';
|
|
4
|
+
import { renderWithTheme } from '../../../tests/utils';
|
|
5
|
+
|
|
6
|
+
describe('TableOfContent', () => {
|
|
7
|
+
it('renders', () => {
|
|
8
|
+
const { container } = renderWithTheme(
|
|
9
|
+
<TableOfContent
|
|
10
|
+
headings={[
|
|
11
|
+
{ id: '1', value: 'test 1', depth: 1 },
|
|
12
|
+
{ id: '2', value: 'test 2', depth: 1 },
|
|
13
|
+
null,
|
|
14
|
+
{ id: '3', value: '', depth: 2 },
|
|
15
|
+
{ id: '4', value: 'test 4', depth: 0 },
|
|
16
|
+
{ id: '4', value: 'test 4', depth: 5 },
|
|
17
|
+
{ id: '5', value: 'test 5', depth: 1 },
|
|
18
|
+
]}
|
|
19
|
+
tocMaxDepth={3}
|
|
20
|
+
contentWrapper={null}
|
|
21
|
+
/>,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
expect(container.firstChild).toMatchSnapshot();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('renders nothing with no headings', () => {
|
|
28
|
+
const { container } = renderWithTheme(
|
|
29
|
+
<TableOfContent headings={null} tocMaxDepth={3} contentWrapper={null} />,
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
expect(container.firstChild).toBeNull();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('renders nothing with empty headings array', () => {
|
|
36
|
+
const { container } = renderWithTheme(
|
|
37
|
+
<TableOfContent headings={[]} tocMaxDepth={3} contentWrapper={null} />,
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
expect(container.firstChild).toBeNull();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('renders nothing for single heading with depth 1', () => {
|
|
44
|
+
const { container } = renderWithTheme(
|
|
45
|
+
<TableOfContent
|
|
46
|
+
headings={[{ id: '3', value: 'test 3', depth: 1 }]}
|
|
47
|
+
tocMaxDepth={3}
|
|
48
|
+
contentWrapper={null}
|
|
49
|
+
/>,
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
expect(container.firstChild).toBeNull();
|
|
53
|
+
});
|
|
54
|
+
it('renders nothing for single empty heading', () => {
|
|
55
|
+
const { container } = renderWithTheme(
|
|
56
|
+
<TableOfContent headings={[null]} tocMaxDepth={3} contentWrapper={null} />,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
expect(container.firstChild).toBeNull();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`TableOfContent renders 1`] = `
|
|
4
|
+
.c2 {
|
|
5
|
+
font-size: 0.8em;
|
|
6
|
+
padding: 10px 15px;
|
|
7
|
+
font-weight: bold;
|
|
8
|
+
text-transform: uppercase;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.c3 {
|
|
12
|
+
display: block;
|
|
13
|
+
color: var(--color-content);
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
font-size: 0.8em;
|
|
16
|
+
padding: 10px 15px;
|
|
17
|
+
padding-left: 0px;
|
|
18
|
+
-webkit-transition: background-color 0.3s,color 0.3s;
|
|
19
|
+
transition: background-color 0.3s,color 0.3s;
|
|
20
|
+
-webkit-text-decoration: none;
|
|
21
|
+
text-decoration: none;
|
|
22
|
+
word-break: break-word;
|
|
23
|
+
font-family: var(--h-font-family);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.c3:hover,
|
|
27
|
+
.c3.active {
|
|
28
|
+
color: var(--sidebar-item-active-color);
|
|
29
|
+
background-color: var(--sidebar-item-active-background-color);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.c3:empty {
|
|
33
|
+
padding: 0;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.c4 {
|
|
37
|
+
display: block;
|
|
38
|
+
color: var(--color-content);
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
font-size: 0.8em;
|
|
41
|
+
padding: 10px 15px;
|
|
42
|
+
padding-left: 15px;
|
|
43
|
+
-webkit-transition: background-color 0.3s,color 0.3s;
|
|
44
|
+
transition: background-color 0.3s,color 0.3s;
|
|
45
|
+
-webkit-text-decoration: none;
|
|
46
|
+
text-decoration: none;
|
|
47
|
+
word-break: break-word;
|
|
48
|
+
font-family: var(--h-font-family);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.c4:hover,
|
|
52
|
+
.c4.active {
|
|
53
|
+
color: var(--sidebar-item-active-color);
|
|
54
|
+
background-color: var(--sidebar-item-active-background-color);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.c4:empty {
|
|
58
|
+
padding: 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.c5 {
|
|
62
|
+
display: block;
|
|
63
|
+
color: var(--color-content);
|
|
64
|
+
cursor: pointer;
|
|
65
|
+
font-size: 0.8em;
|
|
66
|
+
padding: 10px 15px;
|
|
67
|
+
padding-left: -15px;
|
|
68
|
+
-webkit-transition: background-color 0.3s,color 0.3s;
|
|
69
|
+
transition: background-color 0.3s,color 0.3s;
|
|
70
|
+
-webkit-text-decoration: none;
|
|
71
|
+
text-decoration: none;
|
|
72
|
+
word-break: break-word;
|
|
73
|
+
font-family: var(--h-font-family);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.c5:hover,
|
|
77
|
+
.c5.active {
|
|
78
|
+
color: var(--sidebar-item-active-color);
|
|
79
|
+
background-color: var(--sidebar-item-active-background-color);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.c5:empty {
|
|
83
|
+
padding: 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.c0 {
|
|
87
|
+
font-size: 1rem;
|
|
88
|
+
background-color: transparent;
|
|
89
|
+
-webkit-flex-shrink: 0;
|
|
90
|
+
-ms-flex-negative: 0;
|
|
91
|
+
flex-shrink: 0;
|
|
92
|
+
display: none !important;
|
|
93
|
+
font-family: var(--font-family-base);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.c1 {
|
|
97
|
+
position: -webkit-sticky;
|
|
98
|
+
position: sticky;
|
|
99
|
+
top: calc(var(--navbar-height) + 20px);
|
|
100
|
+
max-height: calc(100vh - var(--navbar-height) - 20px);
|
|
101
|
+
border-left: 1px solid var(--global-border-color);
|
|
102
|
+
overflow-y: auto;
|
|
103
|
+
width: var(--toc-width);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@media screen and (min-width:85rem) {
|
|
107
|
+
.c0 {
|
|
108
|
+
width: var(--toc-width);
|
|
109
|
+
display: block !important;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
<aside
|
|
114
|
+
class="c0"
|
|
115
|
+
data-component-name="TableOfContent/TableOfContent"
|
|
116
|
+
>
|
|
117
|
+
<div
|
|
118
|
+
class="c1"
|
|
119
|
+
>
|
|
120
|
+
<div
|
|
121
|
+
class="c2"
|
|
122
|
+
>
|
|
123
|
+
On this page
|
|
124
|
+
</div>
|
|
125
|
+
<a
|
|
126
|
+
class="c3"
|
|
127
|
+
data-cy="toc-test 2"
|
|
128
|
+
href="#2"
|
|
129
|
+
>
|
|
130
|
+
test 2
|
|
131
|
+
</a>
|
|
132
|
+
<a
|
|
133
|
+
class="c4"
|
|
134
|
+
data-cy="toc-"
|
|
135
|
+
href="#3"
|
|
136
|
+
/>
|
|
137
|
+
<a
|
|
138
|
+
class="c5"
|
|
139
|
+
data-cy="toc-test 4"
|
|
140
|
+
href="#4"
|
|
141
|
+
>
|
|
142
|
+
test 4
|
|
143
|
+
</a>
|
|
144
|
+
<a
|
|
145
|
+
class="c3"
|
|
146
|
+
data-cy="toc-test 5"
|
|
147
|
+
href="#5"
|
|
148
|
+
>
|
|
149
|
+
test 5
|
|
150
|
+
</a>
|
|
151
|
+
</div>
|
|
152
|
+
</aside>
|
|
153
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@theme/TableOfContent/TableOfContent';
|
package/src/Tooltip/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from '
|
|
1
|
+
export * from '@theme/Tooltip/Tooltip';
|