@elastic/eui-docusaurus-theme 2.0.0
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/LICENSE.txt +6 -0
- package/README.md +292 -0
- package/lib/.tsbuildinfo-client +1 -0
- package/lib/components/badge/index.d.ts +1 -0
- package/lib/components/badge/index.js +9 -0
- package/lib/components/codesandbox_icon/codesandbox_icon.d.ts +4 -0
- package/lib/components/codesandbox_icon/codesandbox_icon.js +2 -0
- package/lib/components/codesandbox_icon/index.d.ts +1 -0
- package/lib/components/codesandbox_icon/index.js +8 -0
- package/lib/components/demo/actions_bar/actions_bar.d.ts +10 -0
- package/lib/components/demo/actions_bar/actions_bar.js +34 -0
- package/lib/components/demo/actions_bar/index.d.ts +1 -0
- package/lib/components/demo/actions_bar/index.js +8 -0
- package/lib/components/demo/code_transformer.d.ts +18 -0
- package/lib/components/demo/code_transformer.js +39 -0
- package/lib/components/demo/codesandbox/find_external_dependencies.d.ts +5 -0
- package/lib/components/demo/codesandbox/find_external_dependencies.js +30 -0
- package/lib/components/demo/codesandbox/index.d.ts +1 -0
- package/lib/components/demo/codesandbox/index.js +8 -0
- package/lib/components/demo/codesandbox/open_action.d.ts +16 -0
- package/lib/components/demo/codesandbox/open_action.js +91 -0
- package/lib/components/demo/context.d.ts +14 -0
- package/lib/components/demo/context.js +13 -0
- package/lib/components/demo/create_demo.d.ts +5 -0
- package/lib/components/demo/create_demo.js +13 -0
- package/lib/components/demo/demo.d.ts +23 -0
- package/lib/components/demo/demo.js +61 -0
- package/lib/components/demo/editor/editor.d.ts +1 -0
- package/lib/components/demo/editor/editor.js +39 -0
- package/lib/components/demo/editor/index.d.ts +1 -0
- package/lib/components/demo/editor/index.js +8 -0
- package/lib/components/demo/index.d.ts +3 -0
- package/lib/components/demo/index.js +10 -0
- package/lib/components/demo/preview/index.d.ts +1 -0
- package/lib/components/demo/preview/index.js +8 -0
- package/lib/components/demo/preview/preview.d.ts +7 -0
- package/lib/components/demo/preview/preview.js +36 -0
- package/lib/components/demo/scope.d.ts +1 -0
- package/lib/components/demo/scope.js +12 -0
- package/lib/components/demo/source/get_source_from_children.d.ts +11 -0
- package/lib/components/demo/source/get_source_from_children.js +42 -0
- package/lib/components/demo/source/index.d.ts +1 -0
- package/lib/components/demo/source/index.js +8 -0
- package/lib/components/demo/source/source.d.ts +6 -0
- package/lib/components/demo/source/source.js +25 -0
- package/lib/components/figma_embed/index.d.ts +5 -0
- package/lib/components/figma_embed/index.js +36 -0
- package/lib/components/guideline/guideline.d.ts +10 -0
- package/lib/components/guideline/guideline.js +68 -0
- package/lib/components/guideline/guideline_text.d.ts +6 -0
- package/lib/components/guideline/guideline_text.js +28 -0
- package/lib/components/guideline/index.d.ts +2 -0
- package/lib/components/guideline/index.js +9 -0
- package/lib/components/guideline/types.d.ts +1 -0
- package/lib/components/guideline/types.js +8 -0
- package/lib/components/high_contrast_mode_toggle/index.d.ts +1 -0
- package/lib/components/high_contrast_mode_toggle/index.js +15 -0
- package/lib/components/icon/index.d.ts +1 -0
- package/lib/components/icon/index.js +9 -0
- package/lib/components/index.d.ts +7 -0
- package/lib/components/index.js +14 -0
- package/lib/components/navbar_item/index.d.ts +19 -0
- package/lib/components/navbar_item/index.js +84 -0
- package/lib/components/prop_table/definition_types.d.ts +43 -0
- package/lib/components/prop_table/definition_types.js +8 -0
- package/lib/components/prop_table/extended_types.d.ts +5 -0
- package/lib/components/prop_table/extended_types.js +27 -0
- package/lib/components/prop_table/extended_types_info.d.ts +26 -0
- package/lib/components/prop_table/extended_types_info.js +34 -0
- package/lib/components/prop_table/index.d.ts +1 -0
- package/lib/components/prop_table/index.js +8 -0
- package/lib/components/prop_table/prop_table.d.ts +8 -0
- package/lib/components/prop_table/prop_table.js +115 -0
- package/lib/components/theme_context/index.d.ts +16 -0
- package/lib/components/theme_context/index.js +103 -0
- package/lib/components/theme_context/theme_overrides.d.ts +2 -0
- package/lib/components/theme_context/theme_overrides.js +12 -0
- package/lib/components/version_switcher/index.d.ts +23 -0
- package/lib/components/version_switcher/index.js +51 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +19 -0
- package/lib/index.js.map +1 -0
- package/lib/theme/Admonition/Types.d.ts +3 -0
- package/lib/theme/Admonition/Types.js +51 -0
- package/lib/theme/CodeBlock/index.d.ts +3 -0
- package/lib/theme/CodeBlock/index.js +35 -0
- package/lib/theme/ColorModeToggle/index.d.ts +10 -0
- package/lib/theme/ColorModeToggle/index.js +51 -0
- package/lib/theme/Demo/actions.d.ts +8 -0
- package/lib/theme/Demo/actions.js +8 -0
- package/lib/theme/Demo/default_scope.d.ts +3 -0
- package/lib/theme/Demo/default_scope.js +17 -0
- package/lib/theme/DocBreadcrumbs/Items/Home/index.d.ts +2 -0
- package/lib/theme/DocBreadcrumbs/Items/Home/index.js +15 -0
- package/lib/theme/DocBreadcrumbs/Items/item.styles.d.ts +5 -0
- package/lib/theme/DocBreadcrumbs/Items/item.styles.js +40 -0
- package/lib/theme/DocBreadcrumbs/index.d.ts +2 -0
- package/lib/theme/DocBreadcrumbs/index.js +63 -0
- package/lib/theme/DocItem/Content/index.d.ts +3 -0
- package/lib/theme/DocItem/Content/index.js +44 -0
- package/lib/theme/DocItem/Footer/index.d.ts +2 -0
- package/lib/theme/DocItem/Footer/index.js +17 -0
- package/lib/theme/DocItem/Layout/index.d.ts +3 -0
- package/lib/theme/DocItem/Layout/index.js +71 -0
- package/lib/theme/DocItem/Metadata/index.d.ts +2 -0
- package/lib/theme/DocItem/Metadata/index.js +7 -0
- package/lib/theme/DocItem/Paginator/index.d.ts +6 -0
- package/lib/theme/DocItem/Paginator/index.js +11 -0
- package/lib/theme/DocItem/TOC/Desktop/index.d.ts +2 -0
- package/lib/theme/DocItem/TOC/Desktop/index.js +8 -0
- package/lib/theme/DocItem/TOC/Mobile/index.d.ts +2 -0
- package/lib/theme/DocItem/TOC/Mobile/index.js +17 -0
- package/lib/theme/DocItem/index.d.ts +3 -0
- package/lib/theme/DocItem/index.js +10 -0
- package/lib/theme/DocPaginator/index.d.ts +3 -0
- package/lib/theme/DocPaginator/index.js +19 -0
- package/lib/theme/DocRoot/Layout/Main/index.d.ts +3 -0
- package/lib/theme/DocRoot/Layout/Main/index.js +35 -0
- package/lib/theme/DocRoot/Layout/Sidebar/index.d.ts +3 -0
- package/lib/theme/DocRoot/Layout/Sidebar/index.js +81 -0
- package/lib/theme/DocRoot/Layout/index.d.ts +3 -0
- package/lib/theme/DocRoot/Layout/index.js +47 -0
- package/lib/theme/DocSidebarItem/Category/index.d.ts +3 -0
- package/lib/theme/DocSidebarItem/Category/index.js +146 -0
- package/lib/theme/DocSidebarItem/Link/index.d.ts +3 -0
- package/lib/theme/DocSidebarItem/Link/index.js +39 -0
- package/lib/theme/DocSidebarItem/index.d.ts +3 -0
- package/lib/theme/DocSidebarItem/index.js +15 -0
- package/lib/theme/DocSidebarItems/index.d.ts +5 -0
- package/lib/theme/DocSidebarItems/index.js +17 -0
- package/lib/theme/EditThisPage/index.d.ts +3 -0
- package/lib/theme/EditThisPage/index.js +17 -0
- package/lib/theme/Footer/index.d.ts +2 -0
- package/lib/theme/Footer/index.js +43 -0
- package/lib/theme/Heading/index.d.ts +3 -0
- package/lib/theme/Heading/index.js +49 -0
- package/lib/theme/Logo/index.d.ts +3 -0
- package/lib/theme/Logo/index.js +80 -0
- package/lib/theme/MDXComponents/A.d.ts +6 -0
- package/lib/theme/MDXComponents/A.js +17 -0
- package/lib/theme/MDXComponents/Blockquote.d.ts +2 -0
- package/lib/theme/MDXComponents/Blockquote.js +18 -0
- package/lib/theme/MDXComponents/Code.d.ts +6 -0
- package/lib/theme/MDXComponents/Code.js +35 -0
- package/lib/theme/MDXComponents/Heading.d.ts +4 -0
- package/lib/theme/MDXComponents/Heading.js +4 -0
- package/lib/theme/MDXComponents/ListItem.d.ts +2 -0
- package/lib/theme/MDXComponents/ListItem.js +5 -0
- package/lib/theme/MDXComponents/OrderedList.d.ts +2 -0
- package/lib/theme/MDXComponents/OrderedList.js +11 -0
- package/lib/theme/MDXComponents/Paragraph.d.ts +2 -0
- package/lib/theme/MDXComponents/Paragraph.js +18 -0
- package/lib/theme/MDXComponents/Table.d.ts +2 -0
- package/lib/theme/MDXComponents/Table.js +3 -0
- package/lib/theme/MDXComponents/TableBody.d.ts +2 -0
- package/lib/theme/MDXComponents/TableBody.js +3 -0
- package/lib/theme/MDXComponents/TableDataCell.d.ts +2 -0
- package/lib/theme/MDXComponents/TableDataCell.js +3 -0
- package/lib/theme/MDXComponents/TableHeader.d.ts +2 -0
- package/lib/theme/MDXComponents/TableHeader.js +3 -0
- package/lib/theme/MDXComponents/TableHeaderCell.d.ts +2 -0
- package/lib/theme/MDXComponents/TableHeaderCell.js +3 -0
- package/lib/theme/MDXComponents/TableRow.d.ts +2 -0
- package/lib/theme/MDXComponents/TableRow.js +3 -0
- package/lib/theme/MDXComponents/UnorderedList.d.ts +2 -0
- package/lib/theme/MDXComponents/UnorderedList.js +11 -0
- package/lib/theme/MDXComponents/index.d.ts +2 -0
- package/lib/theme/MDXComponents/index.js +46 -0
- package/lib/theme/MDXContent/index.d.ts +6 -0
- package/lib/theme/MDXContent/index.js +4 -0
- package/lib/theme/Navbar/Content/index.d.ts +7 -0
- package/lib/theme/Navbar/Content/index.js +149 -0
- package/lib/theme/Navbar/Layout/index.d.ts +6 -0
- package/lib/theme/Navbar/Layout/index.js +59 -0
- package/lib/theme/Navbar/MobileSidebar/Header/index.d.ts +7 -0
- package/lib/theme/Navbar/MobileSidebar/Header/index.js +46 -0
- package/lib/theme/Navbar/MobileSidebar/Layout/index.d.ts +6 -0
- package/lib/theme/Navbar/MobileSidebar/Layout/index.js +26 -0
- package/lib/theme/Navbar/MobileSidebar/index.d.ts +7 -0
- package/lib/theme/Navbar/MobileSidebar/index.js +14 -0
- package/lib/theme/NavbarItem/DropdownNavbarItem/index.d.ts +3 -0
- package/lib/theme/NavbarItem/DropdownNavbarItem/index.js +94 -0
- package/lib/theme/NavbarItem/NavbarNavLink.d.ts +7 -0
- package/lib/theme/NavbarItem/NavbarNavLink.js +48 -0
- package/lib/theme/PaginatorNavLink/index.d.ts +3 -0
- package/lib/theme/PaginatorNavLink/index.js +43 -0
- package/lib/theme/Root.d.ts +3 -0
- package/lib/theme/Root.js +66 -0
- package/lib/theme/Root.styles.d.ts +2 -0
- package/lib/theme/Root.styles.js +111 -0
- package/lib/theme/TOCCollapsible/CollapseButton/index.d.ts +3 -0
- package/lib/theme/TOCCollapsible/CollapseButton/index.js +23 -0
- package/lib/theme/TOCItems/Tree.d.ts +5 -0
- package/lib/theme/TOCItems/Tree.js +80 -0
- package/lib/theme/infima.styles.d.ts +1 -0
- package/lib/theme/infima.styles.js +1456 -0
- package/lib/theme/reset.styles.d.ts +2 -0
- package/lib/theme/reset.styles.js +79 -0
- package/package.json +61 -0
- package/src/components/badge/index.ts +11 -0
- package/src/components/codesandbox_icon/codesandbox_icon.tsx +24 -0
- package/src/components/codesandbox_icon/index.ts +9 -0
- package/src/components/demo/actions_bar/actions_bar.tsx +95 -0
- package/src/components/demo/actions_bar/index.ts +9 -0
- package/src/components/demo/code_transformer.ts +44 -0
- package/src/components/demo/codesandbox/find_external_dependencies.ts +34 -0
- package/src/components/demo/codesandbox/index.ts +9 -0
- package/src/components/demo/codesandbox/open_action.tsx +132 -0
- package/src/components/demo/context.ts +30 -0
- package/src/components/demo/create_demo.tsx +17 -0
- package/src/components/demo/demo.tsx +143 -0
- package/src/components/demo/editor/editor.tsx +51 -0
- package/src/components/demo/editor/index.ts +9 -0
- package/src/components/demo/index.ts +11 -0
- package/src/components/demo/preview/index.ts +9 -0
- package/src/components/demo/preview/preview.tsx +77 -0
- package/src/components/demo/scope.ts +14 -0
- package/src/components/demo/source/get_source_from_children.ts +59 -0
- package/src/components/demo/source/index.ts +9 -0
- package/src/components/demo/source/source.tsx +36 -0
- package/src/components/figma_embed/index.tsx +57 -0
- package/src/components/guideline/guideline.tsx +121 -0
- package/src/components/guideline/guideline_text.tsx +51 -0
- package/src/components/guideline/index.ts +10 -0
- package/src/components/guideline/types.ts +9 -0
- package/src/components/high_contrast_mode_toggle/index.tsx +28 -0
- package/src/components/icon/index.ts +11 -0
- package/src/components/index.ts +15 -0
- package/src/components/navbar_item/index.tsx +164 -0
- package/src/components/prop_table/definition_types.ts +53 -0
- package/src/components/prop_table/extended_types.tsx +66 -0
- package/src/components/prop_table/extended_types_info.ts +35 -0
- package/src/components/prop_table/index.ts +9 -0
- package/src/components/prop_table/prop_table.tsx +235 -0
- package/src/components/theme_context/index.tsx +156 -0
- package/src/components/theme_context/theme_overrides.ts +15 -0
- package/src/components/version_switcher/index.tsx +144 -0
- package/src/index.ts +21 -0
- package/src/theme/Admonition/Types.tsx +85 -0
- package/src/theme/CodeBlock/index.tsx +57 -0
- package/src/theme/ColorModeToggle/index.tsx +93 -0
- package/src/theme/Demo/actions.tsx +20 -0
- package/src/theme/Demo/default_scope.ts +19 -0
- package/src/theme/DocBreadcrumbs/Items/Home/index.tsx +38 -0
- package/src/theme/DocBreadcrumbs/Items/item.styles.ts +43 -0
- package/src/theme/DocBreadcrumbs/index.tsx +144 -0
- package/src/theme/DocItem/Content/index.tsx +75 -0
- package/src/theme/DocItem/Footer/index.tsx +59 -0
- package/src/theme/DocItem/Layout/index.tsx +112 -0
- package/src/theme/DocItem/Metadata/index.tsx +23 -0
- package/src/theme/DocItem/Paginator/index.tsx +20 -0
- package/src/theme/DocItem/TOC/Desktop/index.tsx +24 -0
- package/src/theme/DocItem/TOC/Mobile/index.tsx +35 -0
- package/src/theme/DocItem/index.tsx +30 -0
- package/src/theme/DocPaginator/index.tsx +64 -0
- package/src/theme/DocRoot/Layout/Main/index.tsx +61 -0
- package/src/theme/DocRoot/Layout/Sidebar/index.tsx +124 -0
- package/src/theme/DocRoot/Layout/index.tsx +72 -0
- package/src/theme/DocSidebarItem/Category/index.tsx +266 -0
- package/src/theme/DocSidebarItem/Link/index.tsx +86 -0
- package/src/theme/DocSidebarItem/index.tsx +29 -0
- package/src/theme/DocSidebarItems/index.tsx +30 -0
- package/src/theme/EditThisPage/index.tsx +50 -0
- package/src/theme/Footer/index.tsx +67 -0
- package/src/theme/Heading/index.tsx +94 -0
- package/src/theme/Logo/index.tsx +146 -0
- package/src/theme/MDXComponents/A.tsx +33 -0
- package/src/theme/MDXComponents/Blockquote.tsx +35 -0
- package/src/theme/MDXComponents/Code.tsx +60 -0
- package/src/theme/MDXComponents/Heading.tsx +16 -0
- package/src/theme/MDXComponents/ListItem.tsx +20 -0
- package/src/theme/MDXComponents/OrderedList.tsx +26 -0
- package/src/theme/MDXComponents/Paragraph.tsx +33 -0
- package/src/theme/MDXComponents/Table.tsx +16 -0
- package/src/theme/MDXComponents/TableBody.tsx +16 -0
- package/src/theme/MDXComponents/TableDataCell.tsx +20 -0
- package/src/theme/MDXComponents/TableHeader.tsx +16 -0
- package/src/theme/MDXComponents/TableHeaderCell.tsx +20 -0
- package/src/theme/MDXComponents/TableRow.tsx +16 -0
- package/src/theme/MDXComponents/UnorderedList.tsx +26 -0
- package/src/theme/MDXComponents/index.ts +61 -0
- package/src/theme/MDXContent/index.tsx +22 -0
- package/src/theme/Navbar/Content/index.tsx +262 -0
- package/src/theme/Navbar/Layout/index.tsx +100 -0
- package/src/theme/Navbar/MobileSidebar/Header/index.tsx +89 -0
- package/src/theme/Navbar/MobileSidebar/Layout/index.tsx +44 -0
- package/src/theme/Navbar/MobileSidebar/index.tsx +46 -0
- package/src/theme/NavbarItem/DropdownNavbarItem/index.tsx +200 -0
- package/src/theme/NavbarItem/NavbarNavLink.tsx +141 -0
- package/src/theme/PaginatorNavLink/index.tsx +72 -0
- package/src/theme/Root.styles.ts +122 -0
- package/src/theme/Root.tsx +106 -0
- package/src/theme/TOCCollapsible/CollapseButton/index.tsx +53 -0
- package/src/theme/TOCItems/Tree.tsx +114 -0
- package/src/theme/infima.styles.ts +1458 -0
- package/src/theme/reset.styles.ts +82 -0
- package/src/theme/theme.d.ts +598 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { css } from '@emotion/react';
|
|
4
|
+
import { ThemeClassNames } from '@docusaurus/theme-common';
|
|
5
|
+
import { useSidebarBreadcrumbs } from '@docusaurus/plugin-content-docs/client';
|
|
6
|
+
import { useHomePageRoute } from '@docusaurus/theme-common/internal';
|
|
7
|
+
import Link from '@docusaurus/Link';
|
|
8
|
+
import { translate } from '@docusaurus/Translate';
|
|
9
|
+
import { EuiIcon, useEuiMemoizedStyles } from '@elastic/eui';
|
|
10
|
+
import HomeBreadcrumbItem from './Items/Home';
|
|
11
|
+
import { getItemStyles } from './Items/item.styles';
|
|
12
|
+
// converted from css modules to Emotion
|
|
13
|
+
const getStyles = ({ euiTheme }) => ({
|
|
14
|
+
breadcrumbsContainer: css `
|
|
15
|
+
--ifm-breadcrumb-size-multiplier: 0.8;
|
|
16
|
+
|
|
17
|
+
// align breadcrumb items with content
|
|
18
|
+
margin-inline-start: -${euiTheme.size.m};
|
|
19
|
+
`,
|
|
20
|
+
});
|
|
21
|
+
// TODO move to design system folder
|
|
22
|
+
function BreadcrumbsItemLink({ children, href, isLast, }) {
|
|
23
|
+
const className = 'breadcrumbs__link';
|
|
24
|
+
if (isLast) {
|
|
25
|
+
return (_jsx("span", { className: className, itemProp: "name", children: children }));
|
|
26
|
+
}
|
|
27
|
+
return href ? (_jsx(Link, { className: className, href: href, itemProp: "item", children: _jsx("span", { itemProp: "name", children: children }) })) : (
|
|
28
|
+
// TODO Google search console doesn't like breadcrumb items without href.
|
|
29
|
+
// The schema doesn't seem to require `id` for each `item`, although Google
|
|
30
|
+
// insist to infer one, even if it's invalid. Removing `itemProp="item
|
|
31
|
+
// name"` for now, since I don't know how to properly fix it.
|
|
32
|
+
// See https://github.com/facebook/docusaurus/issues/7241
|
|
33
|
+
_jsx("span", { className: className, children: children }));
|
|
34
|
+
}
|
|
35
|
+
function BreadcrumbsItem({ children, active, index, addMicrodata, }) {
|
|
36
|
+
const styles = useEuiMemoizedStyles(getItemStyles);
|
|
37
|
+
return (_jsxs("li", { ...(addMicrodata && {
|
|
38
|
+
itemScope: true,
|
|
39
|
+
itemProp: 'itemListElement',
|
|
40
|
+
itemType: 'https://schema.org/ListItem',
|
|
41
|
+
}), className: clsx('breadcrumbs__item', {
|
|
42
|
+
'breadcrumbs__item--active': active,
|
|
43
|
+
}), css: styles.item, children: [children, _jsx("meta", { itemProp: "position", content: String(index + 1) }), !active && _jsx(EuiIcon, { type: "arrowRight", css: styles.icon })] }));
|
|
44
|
+
}
|
|
45
|
+
export default function DocBreadcrumbs() {
|
|
46
|
+
const breadcrumbs = useSidebarBreadcrumbs();
|
|
47
|
+
const homePageRoute = useHomePageRoute();
|
|
48
|
+
const styles = useEuiMemoizedStyles(getStyles);
|
|
49
|
+
if (!breadcrumbs) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return (_jsx("nav", { className: clsx(ThemeClassNames.docs.docBreadcrumbs), "aria-label": translate({
|
|
53
|
+
id: 'theme.docs.breadcrumbs.navAriaLabel',
|
|
54
|
+
message: 'Breadcrumbs',
|
|
55
|
+
description: 'The ARIA label for the breadcrumbs',
|
|
56
|
+
}), css: styles.breadcrumbsContainer, children: _jsxs("ul", { className: "breadcrumbs", itemScope: true, itemType: "https://schema.org/BreadcrumbList", children: [homePageRoute && _jsx(HomeBreadcrumbItem, {}), breadcrumbs.map((item, idx) => {
|
|
57
|
+
const isLast = idx === breadcrumbs.length - 1;
|
|
58
|
+
const href = item.type === 'category' && item.linkUnlisted
|
|
59
|
+
? undefined
|
|
60
|
+
: item.href;
|
|
61
|
+
return (_jsx(BreadcrumbsItem, { active: isLast, index: idx, addMicrodata: !!href, children: _jsx(BreadcrumbsItemLink, { href: href, isLast: isLast, children: item.label }) }, idx));
|
|
62
|
+
})] }) }));
|
|
63
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { css } from '@emotion/react';
|
|
4
|
+
import { ThemeClassNames } from '@docusaurus/theme-common';
|
|
5
|
+
import { useDoc } from '@docusaurus/plugin-content-docs/client';
|
|
6
|
+
import MDXContent from '@theme-original/MDXContent';
|
|
7
|
+
import { EuiHorizontalRule, useEuiMemoizedStyles, } from '@elastic/eui';
|
|
8
|
+
import Heading from '../../MDXComponents/Heading';
|
|
9
|
+
/**
|
|
10
|
+
Title can be declared inside md content or declared through
|
|
11
|
+
front matter and added manually. To make both cases consistent,
|
|
12
|
+
the added title is added under the same div.markdown block
|
|
13
|
+
See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
|
|
14
|
+
|
|
15
|
+
We render a "synthetic title" if:
|
|
16
|
+
- user doesn't ask to hide it with front matter
|
|
17
|
+
- the markdown content does not already contain a top-level h1 heading
|
|
18
|
+
*/
|
|
19
|
+
function useSyntheticTitle() {
|
|
20
|
+
const { metadata, frontMatter, contentTitle } = useDoc();
|
|
21
|
+
const shouldRender = !frontMatter.hide_title && typeof contentTitle === 'undefined';
|
|
22
|
+
if (!shouldRender) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return metadata.title;
|
|
26
|
+
}
|
|
27
|
+
const getContentStyles = ({ euiTheme }) => {
|
|
28
|
+
return {
|
|
29
|
+
header: css `
|
|
30
|
+
// required specificity to override docusaurus styles
|
|
31
|
+
& > h1.euiTitle {
|
|
32
|
+
--ifm-h1-font-size: var(--eui-font-size-xxl);
|
|
33
|
+
--ifm-h1-vertical-rhythm-bottom: 1.2;
|
|
34
|
+
|
|
35
|
+
line-height: 2.8rem;
|
|
36
|
+
}
|
|
37
|
+
`,
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export default function DocItemContent({ children }) {
|
|
41
|
+
const syntheticTitle = useSyntheticTitle();
|
|
42
|
+
const styles = useEuiMemoizedStyles(getContentStyles);
|
|
43
|
+
return (_jsxs("div", { className: clsx(ThemeClassNames.docs.docMarkdown, 'markdown'), children: [syntheticTitle && (_jsxs(_Fragment, { children: [_jsx("header", { css: styles.header, children: _jsx(Heading, { as: "h1", children: syntheticTitle }) }), _jsx(EuiHorizontalRule, {})] })), _jsx(MDXContent, { children: children })] }));
|
|
44
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { ThemeClassNames } from '@docusaurus/theme-common';
|
|
4
|
+
import { useDoc } from '@docusaurus/plugin-content-docs/client';
|
|
5
|
+
import TagsListInline from '@theme-original/TagsListInline';
|
|
6
|
+
import EditMetaRow from '@theme-original/EditMetaRow';
|
|
7
|
+
export default function DocItemFooter() {
|
|
8
|
+
const { metadata } = useDoc();
|
|
9
|
+
const { editUrl, lastUpdatedAt, lastUpdatedBy, tags } = metadata;
|
|
10
|
+
const canDisplayTagsRow = tags.length > 0;
|
|
11
|
+
const canDisplayEditMetaRow = !!(editUrl || lastUpdatedAt || lastUpdatedBy);
|
|
12
|
+
const canDisplayFooter = canDisplayTagsRow || canDisplayEditMetaRow;
|
|
13
|
+
if (!canDisplayFooter) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return (_jsxs("footer", { className: clsx(ThemeClassNames.docs.docFooter, 'docusaurus-mt-lg'), children: [canDisplayTagsRow && (_jsx("div", { className: clsx('row margin-top--sm', ThemeClassNames.docs.docFooterTagsRow), children: _jsx("div", { className: "col", children: _jsx(TagsListInline, { tags: tags }) }) })), canDisplayEditMetaRow && (_jsx(EditMetaRow, { className: clsx('margin-top--sm', ThemeClassNames.docs.docFooterEditMetaRow), editUrl: editUrl, lastUpdatedAt: lastUpdatedAt, lastUpdatedBy: lastUpdatedBy }))] }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { EuiHorizontalRule } from '@elastic/eui';
|
|
3
|
+
import { css } from '@emotion/react';
|
|
4
|
+
import { useWindowSize } from '@docusaurus/theme-common';
|
|
5
|
+
import { useDoc } from '@docusaurus/plugin-content-docs/client';
|
|
6
|
+
import DocItemPaginator from '@theme-original/DocItem/Paginator';
|
|
7
|
+
import ContentVisibility from '@theme-original/ContentVisibility';
|
|
8
|
+
import DocVersionBanner from '@theme-original/DocVersionBanner';
|
|
9
|
+
import DocVersionBadge from '@theme-original/DocVersionBadge';
|
|
10
|
+
import DocBreadcrumbs from '../../DocBreadcrumbs';
|
|
11
|
+
import DocItemTOCMobile from '../TOC/Mobile';
|
|
12
|
+
import DocItemTOCDesktop from '../TOC/Desktop';
|
|
13
|
+
import DocItemContent from '../Content';
|
|
14
|
+
import DocItemFooter from '../Footer';
|
|
15
|
+
// At 1280px there's enough space to show the TOC,
|
|
16
|
+
// until then we show the mobile/collapsible TOC
|
|
17
|
+
const BREAKPOINT_TOC = 1280;
|
|
18
|
+
// converted from css modules to emotion
|
|
19
|
+
const styles = {
|
|
20
|
+
docItemContainer: css `
|
|
21
|
+
& header + *,
|
|
22
|
+
& article > *:first-child {
|
|
23
|
+
margin-top: 0;
|
|
24
|
+
}
|
|
25
|
+
`,
|
|
26
|
+
docItemRow: css `
|
|
27
|
+
justify-content: center;
|
|
28
|
+
`,
|
|
29
|
+
docItemCol: css `
|
|
30
|
+
@media (min-width: 997px) {
|
|
31
|
+
font-size: 100%;
|
|
32
|
+
max-width: 94ch;
|
|
33
|
+
/* Ensure TOC won't wrap */
|
|
34
|
+
overflow-x: auto;
|
|
35
|
+
}
|
|
36
|
+
`,
|
|
37
|
+
docItemTOCDesktopContainter: css `
|
|
38
|
+
display: none;
|
|
39
|
+
|
|
40
|
+
@media (min-width: ${BREAKPOINT_TOC}px) {
|
|
41
|
+
display: block;
|
|
42
|
+
}
|
|
43
|
+
`,
|
|
44
|
+
docItemTOCMobileContainter: css `
|
|
45
|
+
@media (min-width: ${BREAKPOINT_TOC}px) {
|
|
46
|
+
display: none;
|
|
47
|
+
}
|
|
48
|
+
`,
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Decide if the toc should be rendered, on mobile or desktop viewports
|
|
52
|
+
*/
|
|
53
|
+
function useDocTOC() {
|
|
54
|
+
const { frontMatter, toc } = useDoc();
|
|
55
|
+
const windowSize = useWindowSize();
|
|
56
|
+
const hidden = frontMatter.hide_table_of_contents ?? false;
|
|
57
|
+
const canRender = !hidden && toc.length > 0;
|
|
58
|
+
// Hide/show for TOC elements is handled by media queries
|
|
59
|
+
const mobile = canRender ? _jsx(DocItemTOCMobile, {}) : undefined;
|
|
60
|
+
const desktop = canRender ? _jsx(DocItemTOCDesktop, {}) : undefined;
|
|
61
|
+
return {
|
|
62
|
+
hidden,
|
|
63
|
+
mobile,
|
|
64
|
+
desktop,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export default function DocItemLayout({ children }) {
|
|
68
|
+
const docTOC = useDocTOC();
|
|
69
|
+
const { metadata } = useDoc();
|
|
70
|
+
return (_jsxs("div", { className: "row", css: styles.docItemRow, children: [_jsxs("div", { className: "col", css: styles.docItemCol, children: [_jsx(ContentVisibility, { metadata: metadata }), _jsx(DocVersionBanner, {}), _jsxs("div", { css: styles.docItemContainer, children: [_jsxs("article", { children: [_jsx(DocBreadcrumbs, {}), _jsx(DocVersionBadge, {}), _jsx("div", { css: styles.docItemTOCMobileContainter, children: docTOC.mobile }), _jsx(DocItemContent, { children: children }), _jsx(DocItemFooter, {})] }), _jsx(EuiHorizontalRule, { margin: "xl" }), _jsx(DocItemPaginator, {})] })] }), docTOC.desktop && (_jsx("div", { className: "col col--3", css: styles.docItemTOCDesktopContainter, children: docTOC.desktop }))] }));
|
|
71
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { PageMetadata } from '@docusaurus/theme-common';
|
|
3
|
+
import { useDoc } from '@docusaurus/plugin-content-docs/client';
|
|
4
|
+
export default function DocItemMetadata() {
|
|
5
|
+
const { metadata, frontMatter, assets } = useDoc();
|
|
6
|
+
return (_jsx(PageMetadata, { title: metadata.title, description: metadata.description, keywords: frontMatter.keywords, image: assets.image ?? frontMatter.image }));
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useDoc } from '@docusaurus/plugin-content-docs/client';
|
|
3
|
+
import DocPaginator from '@theme-original/DocPaginator';
|
|
4
|
+
/**
|
|
5
|
+
* This extra component is needed, because <DocPaginator> should remain generic.
|
|
6
|
+
* DocPaginator is used in non-docs contexts too: generated-index pages...
|
|
7
|
+
*/
|
|
8
|
+
export default function DocItemPaginator() {
|
|
9
|
+
const { metadata } = useDoc();
|
|
10
|
+
return _jsx(DocPaginator, { previous: metadata.previous, next: metadata.next });
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { ThemeClassNames } from '@docusaurus/theme-common';
|
|
3
|
+
import { useDoc } from '@docusaurus/plugin-content-docs/client';
|
|
4
|
+
import TOC from '@theme-original/TOC';
|
|
5
|
+
export default function DocItemTOCDesktop() {
|
|
6
|
+
const { toc, frontMatter } = useDoc();
|
|
7
|
+
return (_jsx(TOC, { toc: toc, minHeadingLevel: frontMatter.toc_min_heading_level, maxHeadingLevel: frontMatter.toc_max_heading_level, className: ThemeClassNames.docs.docTocDesktop }));
|
|
8
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
|
+
import { ThemeClassNames } from '@docusaurus/theme-common';
|
|
4
|
+
import { useDoc } from '@docusaurus/plugin-content-docs/client';
|
|
5
|
+
import TOCCollapsible from '@theme-original/TOCCollapsible';
|
|
6
|
+
// converted from css modules to emotion
|
|
7
|
+
const tocStyles = {
|
|
8
|
+
tocMobile: css `
|
|
9
|
+
@media print {
|
|
10
|
+
display: none;
|
|
11
|
+
}
|
|
12
|
+
`,
|
|
13
|
+
};
|
|
14
|
+
export default function DocItemTOCMobile() {
|
|
15
|
+
const { toc, frontMatter } = useDoc();
|
|
16
|
+
return (_jsx(TOCCollapsible, { toc: toc, minHeadingLevel: frontMatter.toc_min_heading_level, maxHeadingLevel: frontMatter.toc_max_heading_level, className: ThemeClassNames.docs.docTocMobile, css: tocStyles.tocMobile }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { HtmlClassNameProvider } from '@docusaurus/theme-common';
|
|
3
|
+
import { DocProvider } from '@docusaurus/plugin-content-docs/client';
|
|
4
|
+
import DocItemMetadata from './Metadata';
|
|
5
|
+
import DocItemLayout from './Layout';
|
|
6
|
+
export default function DocItem(props) {
|
|
7
|
+
const docHtmlClassName = `docs-doc-id-${props.content.metadata.id}`;
|
|
8
|
+
const MDXComponent = props.content;
|
|
9
|
+
return (_jsx(DocProvider, { content: props.content, children: _jsxs(HtmlClassNameProvider, { className: docHtmlClassName, children: [_jsx(DocItemMetadata, {}), _jsx(DocItemLayout, { children: _jsx(MDXComponent, {}) })] }) }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { css } from '@emotion/react';
|
|
3
|
+
import Translate, { translate } from '@docusaurus/Translate';
|
|
4
|
+
import PaginatorNavLink from '@theme-original/PaginatorNavLink';
|
|
5
|
+
const styles = {
|
|
6
|
+
pagination: css `
|
|
7
|
+
// docusaurus reset, we add spacing via the
|
|
8
|
+
// horizontal rule in Layout instead
|
|
9
|
+
margin-top: 0;
|
|
10
|
+
`,
|
|
11
|
+
};
|
|
12
|
+
export default function DocPaginator(props) {
|
|
13
|
+
const { previous, next } = props;
|
|
14
|
+
return (_jsxs("nav", { className: "pagination-nav docusaurus-mt-lg", css: styles.pagination, "aria-label": translate({
|
|
15
|
+
id: 'theme.docs.paginator.navAriaLabel',
|
|
16
|
+
message: 'Docs pages',
|
|
17
|
+
description: 'The ARIA label for the docs pagination',
|
|
18
|
+
}), children: [previous && (_jsx(PaginatorNavLink, { ...previous, subLabel: _jsx(Translate, { id: "theme.docs.paginator.previous", description: "The label used to navigate to the previous doc", children: "Previous" }) })), next && (_jsx(PaginatorNavLink, { ...next, subLabel: _jsx(Translate, { id: "theme.docs.paginator.next", description: "The label used to navigate to the next doc", children: "Next" }), isNext: true }))] }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { css } from '@emotion/react';
|
|
4
|
+
import { useDocsSidebar } from '@docusaurus/plugin-content-docs/client';
|
|
5
|
+
// converted from css modules to Emotion
|
|
6
|
+
const styles = {
|
|
7
|
+
docMainContainer: css `
|
|
8
|
+
display: flex;
|
|
9
|
+
width: 100%;
|
|
10
|
+
|
|
11
|
+
@media (min-width: 997px) {
|
|
12
|
+
flex-grow: 1;
|
|
13
|
+
max-width: calc(100% - var(--doc-sidebar-width));
|
|
14
|
+
}
|
|
15
|
+
`,
|
|
16
|
+
docMainContainerEnhanced: css `
|
|
17
|
+
@media (min-width: 997px) {
|
|
18
|
+
max-width: calc(100% - var(--doc-sidebar-hidden-width));
|
|
19
|
+
}
|
|
20
|
+
`,
|
|
21
|
+
docItemWrapperEnhanced: css `
|
|
22
|
+
@media (min-width: 997px) {
|
|
23
|
+
max-width: calc(
|
|
24
|
+
var(--ifm-container-width) + var(--doc-sidebar-width)
|
|
25
|
+
) !important;
|
|
26
|
+
}
|
|
27
|
+
`,
|
|
28
|
+
};
|
|
29
|
+
export default function DocRootLayoutMain({ hiddenSidebarContainer, children, }) {
|
|
30
|
+
const sidebar = useDocsSidebar();
|
|
31
|
+
return (_jsx("main", { className: clsx(styles.docMainContainer), css: [
|
|
32
|
+
styles.docMainContainer,
|
|
33
|
+
(hiddenSidebarContainer || !sidebar) && styles.docMainContainerEnhanced,
|
|
34
|
+
], children: _jsx("div", { className: "container padding-top--md padding-bottom--lg", css: [hiddenSidebarContainer && styles.docItemWrapperEnhanced], children: children }) }));
|
|
35
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
4
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
5
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
6
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
7
|
+
* Side Public License, v 1.
|
|
8
|
+
*/
|
|
9
|
+
import React, { useState, useCallback } from 'react';
|
|
10
|
+
import clsx from 'clsx';
|
|
11
|
+
import { css } from '@emotion/react';
|
|
12
|
+
import { prefersReducedMotion, ThemeClassNames, } from '@docusaurus/theme-common';
|
|
13
|
+
import { useDocsSidebar } from '@docusaurus/plugin-content-docs/client';
|
|
14
|
+
import { useLocation } from '@docusaurus/router';
|
|
15
|
+
import DocSidebar from '@theme-original/DocSidebar';
|
|
16
|
+
import ExpandButton from '@theme-original/DocRoot/Layout/Sidebar/ExpandButton';
|
|
17
|
+
// converted from css modules to Emotion
|
|
18
|
+
const styles = {
|
|
19
|
+
docSidebarContainer: css `
|
|
20
|
+
display: none;
|
|
21
|
+
|
|
22
|
+
@media (min-width: 997px) {
|
|
23
|
+
// ensure scrolling still works
|
|
24
|
+
display: flex;
|
|
25
|
+
width: var(--doc-sidebar-width);
|
|
26
|
+
margin-top: calc(-1 * var(--ifm-navbar-height));
|
|
27
|
+
border-right: 1px solid var(--ifm-toc-border-color);
|
|
28
|
+
will-change: width;
|
|
29
|
+
transition: width var(--ifm-transition-fast) ease;
|
|
30
|
+
clip-path: inset(0);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.theme-doc-sidebar-menu.menu__list {
|
|
34
|
+
padding-inline-end: var(--eui-size-s);
|
|
35
|
+
}
|
|
36
|
+
`,
|
|
37
|
+
docSidebarContainerHidden: css `
|
|
38
|
+
width: var(--doc-sidebar-hidden-width);
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
`,
|
|
41
|
+
sidebarViewport: css `
|
|
42
|
+
top: 0;
|
|
43
|
+
position: sticky;
|
|
44
|
+
height: 100%;
|
|
45
|
+
max-height: 100vh;
|
|
46
|
+
`,
|
|
47
|
+
};
|
|
48
|
+
// Reset sidebar state when sidebar changes
|
|
49
|
+
// Use React key to unmount/remount the children
|
|
50
|
+
// See https://github.com/facebook/docusaurus/issues/3414
|
|
51
|
+
function ResetOnSidebarChange({ children }) {
|
|
52
|
+
const sidebar = useDocsSidebar();
|
|
53
|
+
return (_jsx(React.Fragment, { children: children }, sidebar?.name ?? 'noSidebar'));
|
|
54
|
+
}
|
|
55
|
+
export default function DocRootLayoutSidebar({ sidebar, hiddenSidebarContainer, setHiddenSidebarContainer, }) {
|
|
56
|
+
const { pathname } = useLocation();
|
|
57
|
+
const [hiddenSidebar, setHiddenSidebar] = useState(false);
|
|
58
|
+
const toggleSidebar = useCallback(() => {
|
|
59
|
+
if (hiddenSidebar) {
|
|
60
|
+
setHiddenSidebar(false);
|
|
61
|
+
}
|
|
62
|
+
// onTransitionEnd won't fire when sidebar animation is disabled
|
|
63
|
+
// fixes https://github.com/facebook/docusaurus/issues/8918
|
|
64
|
+
if (!hiddenSidebar && prefersReducedMotion()) {
|
|
65
|
+
setHiddenSidebar(true);
|
|
66
|
+
}
|
|
67
|
+
setHiddenSidebarContainer((value) => !value);
|
|
68
|
+
}, [setHiddenSidebarContainer, hiddenSidebar]);
|
|
69
|
+
return (_jsx("aside", { className: clsx(ThemeClassNames.docs.docSidebarContainer, styles.docSidebarContainer.name // adding the name here to preserve the functionality of the class check further down
|
|
70
|
+
), css: [
|
|
71
|
+
styles.docSidebarContainer,
|
|
72
|
+
hiddenSidebarContainer && styles.docSidebarContainerHidden,
|
|
73
|
+
], onTransitionEnd: (e) => {
|
|
74
|
+
if (!e.currentTarget.classList.contains(styles.docSidebarContainer.name)) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (hiddenSidebarContainer) {
|
|
78
|
+
setHiddenSidebar(true);
|
|
79
|
+
}
|
|
80
|
+
}, children: _jsx(ResetOnSidebarChange, { children: _jsxs("div", { className: clsx(hiddenSidebar && 'sidebarViewportHidden'), css: styles.sidebarViewport, children: [_jsx(DocSidebar, { sidebar: sidebar, path: pathname, onCollapse: toggleSidebar, isHidden: hiddenSidebar }), hiddenSidebar && _jsx(ExpandButton, { toggleSidebar: toggleSidebar })] }) }) }));
|
|
81
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
4
|
+
* or more contributor license agreements. Licensed under the Elastic License
|
|
5
|
+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
6
|
+
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
7
|
+
* Side Public License, v 1.
|
|
8
|
+
*/
|
|
9
|
+
import { useEffect, useState } from 'react';
|
|
10
|
+
import { css } from '@emotion/react';
|
|
11
|
+
import { useDocsSidebar } from '@docusaurus/plugin-content-docs/client';
|
|
12
|
+
import useIsBrowser from '@docusaurus/useIsBrowser';
|
|
13
|
+
import BackToTopButton from '@theme-original/BackToTopButton';
|
|
14
|
+
import DocRootLayoutSidebar from '@theme-original/DocRoot/Layout/Sidebar';
|
|
15
|
+
import DocRootLayoutMain from './Main';
|
|
16
|
+
// converted from css modules to Emotion
|
|
17
|
+
const styles = {
|
|
18
|
+
docRoot: css `
|
|
19
|
+
display: flex;
|
|
20
|
+
width: 100%;
|
|
21
|
+
`,
|
|
22
|
+
docsWrapper: css `
|
|
23
|
+
display: flex;
|
|
24
|
+
flex: 1 0 auto;
|
|
25
|
+
`,
|
|
26
|
+
};
|
|
27
|
+
export default function DocRootLayout({ children }) {
|
|
28
|
+
const isBrowser = useIsBrowser();
|
|
29
|
+
const sidebar = useDocsSidebar();
|
|
30
|
+
const [hiddenSidebarContainer, setHiddenSidebarContainer] = useState(false);
|
|
31
|
+
// Replicate browser hash scroll behavior to trigger it after the MDX content
|
|
32
|
+
// is rendered. Timeout = 0 should do the job here just fine as the effect
|
|
33
|
+
// will get executed at next render cycle when all elements are (hopefully)
|
|
34
|
+
// already in the DOM.
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!isBrowser) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (window.location.hash) {
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
const element = document.getElementById(window.location.hash.substring(1));
|
|
42
|
+
element?.scrollIntoView(true);
|
|
43
|
+
}, 100);
|
|
44
|
+
}
|
|
45
|
+
}, [isBrowser]);
|
|
46
|
+
return (_jsxs("div", { css: styles.docsWrapper, children: [_jsx(BackToTopButton, {}), _jsxs("div", { css: styles.docRoot, children: [sidebar && (_jsx(DocRootLayoutSidebar, { sidebar: sidebar.items, hiddenSidebarContainer: hiddenSidebarContainer, setHiddenSidebarContainer: setHiddenSidebarContainer })), _jsx(DocRootLayoutMain, { hiddenSidebarContainer: hiddenSidebarContainer, children: children })] })] }));
|
|
47
|
+
}
|