@docusaurus/theme-classic 2.0.0-beta.1ec2c95e3 → 2.0.0-beta.21
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/README.md +2 -2
- package/lib/admonitions.css +39 -0
- package/lib/getSwizzleConfig.d.ts +8 -0
- package/lib/getSwizzleConfig.js +228 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +106 -170
- package/lib/nprogress.css +41 -0
- package/lib/nprogress.d.ts +10 -0
- package/lib/nprogress.js +25 -0
- package/lib/prism-include-languages.d.ts +7 -0
- package/lib/prism-include-languages.js +0 -2
- package/lib/theme/Admonition/index.d.ts +9 -0
- package/lib/theme/Admonition/index.js +101 -0
- package/lib/theme/AnnouncementBar/index.d.ts +8 -0
- package/lib/theme/AnnouncementBar/index.js +38 -63
- package/lib/theme/AnnouncementBar/styles.module.css +23 -32
- package/lib/theme/BackToTopButton/index.d.ts +8 -0
- package/lib/theme/BackToTopButton/index.js +31 -0
- package/lib/theme/BackToTopButton/styles.module.css +44 -0
- package/lib/theme/BlogArchivePage/index.d.ts +10 -0
- package/lib/theme/BlogArchivePage/index.js +80 -0
- package/lib/theme/BlogLayout/index.d.ts +9 -0
- package/lib/theme/BlogLayout/index.js +33 -0
- package/lib/theme/BlogListPage/index.d.ts +10 -0
- package/lib/theme/BlogListPage/index.js +53 -61
- package/lib/theme/BlogListPaginator/index.d.ts +9 -0
- package/lib/theme/BlogListPaginator/index.js +41 -56
- package/lib/theme/BlogPostAuthor/index.d.ts +9 -0
- package/lib/theme/BlogPostAuthor/index.js +46 -0
- package/lib/theme/BlogPostAuthors/index.d.ts +9 -0
- package/lib/theme/BlogPostAuthors/index.js +42 -0
- package/{src/theme/Toggle → lib/theme/BlogPostAuthors}/styles.module.css +11 -7
- package/lib/theme/BlogPostItem/index.d.ts +9 -0
- package/lib/theme/BlogPostItem/index.js +120 -127
- package/lib/theme/BlogPostItem/styles.module.css +9 -0
- package/lib/theme/BlogPostPage/index.d.ts +10 -0
- package/lib/theme/BlogPostPage/index.js +90 -60
- package/lib/theme/BlogPostPaginator/index.d.ts +9 -0
- package/lib/theme/BlogPostPaginator/index.js +40 -57
- package/lib/theme/BlogSidebar/Desktop/index.d.ts +9 -0
- package/{lib-next/theme/BlogSidebar → lib/theme/BlogSidebar/Desktop}/index.js +19 -23
- package/{lib-next/theme/BlogSidebar → lib/theme/BlogSidebar/Desktop}/styles.module.css +5 -4
- package/lib/theme/BlogSidebar/Mobile/index.d.ts +9 -0
- package/lib/theme/BlogSidebar/Mobile/index.js +34 -0
- package/lib/theme/BlogSidebar/index.d.ts +9 -0
- package/lib/theme/BlogSidebar/index.js +13 -43
- package/lib/theme/BlogTagsListPage/index.d.ts +10 -0
- package/lib/theme/BlogTagsListPage/index.js +27 -69
- package/lib/theme/BlogTagsPostsPage/index.d.ts +10 -0
- package/lib/theme/BlogTagsPostsPage/index.js +72 -89
- package/lib/theme/CodeBlock/Container/index.d.ts +10 -0
- package/lib/theme/CodeBlock/Container/index.js +30 -0
- package/lib/theme/CodeBlock/Container/styles.module.css +14 -0
- package/lib/theme/CodeBlock/Content/Element.d.ts +9 -0
- package/lib/theme/CodeBlock/Content/Element.js +23 -0
- package/lib/theme/CodeBlock/Content/String.d.ts +9 -0
- package/lib/theme/CodeBlock/Content/String.js +104 -0
- package/{lib-next/theme/CodeBlock → lib/theme/CodeBlock/Content}/styles.module.css +45 -27
- package/lib/theme/CodeBlock/CopyButton/index.d.ts +9 -0
- package/lib/theme/CodeBlock/CopyButton/index.js +61 -0
- package/lib/theme/CodeBlock/CopyButton/styles.module.css +47 -0
- package/lib/theme/CodeBlock/Line/index.d.ts +9 -0
- package/lib/theme/CodeBlock/Line/index.js +42 -0
- package/lib/theme/CodeBlock/Line/styles.module.css +51 -0
- package/lib/theme/CodeBlock/WordWrapButton/index.d.ts +9 -0
- package/lib/theme/CodeBlock/WordWrapButton/index.js +40 -0
- package/lib/theme/CodeBlock/WordWrapButton/styles.module.css +15 -0
- package/lib/theme/CodeBlock/index.d.ts +9 -0
- package/lib/theme/CodeBlock/index.js +31 -246
- package/lib/theme/ColorModeToggle/index.d.ts +11 -0
- package/lib/theme/ColorModeToggle/index.js +60 -0
- package/lib/theme/ColorModeToggle/styles.module.css +35 -0
- package/lib/theme/Details/index.d.ts +9 -0
- package/lib/theme/Details/index.js +21 -0
- package/lib/theme/Details/styles.module.css +13 -0
- package/lib/theme/DocBreadcrumbs/index.d.ts +8 -0
- package/lib/theme/DocBreadcrumbs/index.js +115 -0
- package/lib/theme/{Heading/styles.css → DocBreadcrumbs/styles.module.css} +9 -13
- package/lib/theme/DocCard/index.d.ts +9 -0
- package/lib/theme/DocCard/index.js +83 -0
- package/lib/theme/DocCard/styles.module.css +34 -0
- package/lib/theme/DocCardList/index.d.ts +9 -0
- package/lib/theme/DocCardList/index.js +30 -0
- package/lib/theme/DocCategoryGeneratedIndexPage/index.d.ts +10 -0
- package/lib/theme/DocCategoryGeneratedIndexPage/index.js +74 -0
- package/lib/theme/DocCategoryGeneratedIndexPage/styles.module.css +26 -0
- package/lib/theme/DocItem/index.d.ts +10 -0
- package/lib/theme/DocItem/index.js +102 -113
- package/lib/theme/DocItem/styles.module.css +12 -10
- package/lib/theme/DocItemFooter/index.d.ts +10 -0
- package/lib/theme/DocItemFooter/index.js +74 -0
- package/{lib-next/theme/DocItem → lib/theme/DocItemFooter}/styles.module.css +1 -9
- package/lib/theme/DocPage/Layout/Main/index.d.ts +9 -0
- package/lib/theme/DocPage/Layout/Main/index.js +29 -0
- package/lib/theme/DocPage/Layout/Main/styles.module.css +28 -0
- package/lib/theme/DocPage/Layout/Sidebar/ExpandButton/index.d.ts +9 -0
- package/lib/theme/DocPage/Layout/Sidebar/ExpandButton/index.js +34 -0
- package/lib/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +33 -0
- package/lib/theme/DocPage/Layout/Sidebar/index.d.ts +9 -0
- package/lib/theme/DocPage/Layout/Sidebar/index.js +65 -0
- package/lib/theme/DocPage/Layout/Sidebar/styles.module.css +32 -0
- package/lib/theme/DocPage/Layout/index.d.ts +9 -0
- package/lib/theme/DocPage/Layout/index.js +34 -0
- package/{lib-next/theme/IconExternalLink → lib/theme/DocPage/Layout}/styles.module.css +7 -4
- package/lib/theme/DocPage/index.d.ts +10 -0
- package/lib/theme/DocPage/index.js +43 -165
- package/lib/theme/DocPaginator/index.d.ts +9 -0
- package/lib/theme/DocPaginator/index.js +40 -56
- package/lib/theme/DocSidebar/Desktop/CollapseButton/index.d.ts +9 -0
- package/lib/theme/DocSidebar/Desktop/CollapseButton/index.js +34 -0
- package/lib/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +46 -0
- package/lib/theme/DocSidebar/Desktop/Content/index.d.ts +9 -0
- package/lib/theme/DocSidebar/Desktop/Content/index.js +44 -0
- package/lib/theme/DocSidebar/Desktop/Content/styles.module.css +23 -0
- package/lib/theme/DocSidebar/Desktop/index.d.ts +11 -0
- package/lib/theme/DocSidebar/Desktop/index.js +34 -0
- package/lib/theme/DocSidebar/Desktop/styles.module.css +50 -0
- package/lib/theme/DocSidebar/Mobile/index.d.ts +11 -0
- package/lib/theme/DocSidebar/Mobile/index.js +45 -0
- package/lib/theme/DocSidebar/index.d.ts +9 -0
- package/lib/theme/DocSidebar/index.js +17 -302
- package/lib/theme/DocSidebarItem/Category/index.d.ts +9 -0
- package/lib/theme/DocSidebarItem/Category/index.js +183 -0
- package/lib/theme/DocSidebarItem/Html/index.d.ts +9 -0
- package/lib/theme/DocSidebarItem/Html/index.js +26 -0
- package/lib/theme/DocSidebarItem/Html/styles.module.css +13 -0
- package/lib/theme/DocSidebarItem/Link/index.d.ts +9 -0
- package/lib/theme/DocSidebarItem/Link/index.js +53 -0
- package/{lib-next/theme/MDXPage → lib/theme/DocSidebarItem/Link}/styles.module.css +2 -2
- package/lib/theme/DocSidebarItem/index.d.ts +9 -0
- package/lib/theme/DocSidebarItem/index.js +21 -0
- package/lib/theme/DocSidebarItems/index.d.ts +11 -0
- package/lib/theme/DocSidebarItems/index.js +22 -0
- package/lib/theme/DocTagDocListPage/index.d.ts +10 -0
- package/lib/theme/DocTagDocListPage/index.js +89 -0
- package/lib/theme/DocTagsListPage/index.d.ts +10 -0
- package/lib/theme/DocTagsListPage/index.js +40 -0
- package/lib/theme/DocVersionBadge/index.d.ts +9 -0
- package/lib/theme/DocVersionBadge/index.js +30 -0
- package/lib/theme/DocVersionBanner/index.d.ts +9 -0
- package/lib/theme/DocVersionBanner/index.js +105 -102
- package/lib/theme/EditThisPage/index.d.ts +9 -0
- package/lib/theme/EditThisPage/index.js +19 -24
- package/{src/theme/hooks/useLockBodyScroll.ts → lib/theme/ErrorPageContent.d.ts} +4 -14
- package/lib/theme/ErrorPageContent.js +35 -0
- package/lib/theme/Footer/Copyright/index.d.ts +9 -0
- package/lib/theme/Footer/Copyright/index.js +17 -0
- package/lib/theme/Footer/Layout/index.d.ts +9 -0
- package/lib/theme/Footer/Layout/index.js +26 -0
- package/lib/theme/Footer/LinkItem/index.d.ts +9 -0
- package/lib/theme/Footer/LinkItem/index.js +31 -0
- package/lib/theme/Footer/Links/MultiColumn/index.d.ts +9 -0
- package/lib/theme/Footer/Links/MultiColumn/index.js +43 -0
- package/lib/theme/Footer/Links/Simple/index.d.ts +9 -0
- package/lib/theme/Footer/Links/Simple/index.js +37 -0
- package/lib/theme/Footer/Links/index.d.ts +9 -0
- package/lib/theme/Footer/Links/index.js +17 -0
- package/lib/theme/Footer/Logo/index.d.ts +9 -0
- package/lib/theme/Footer/Logo/index.js +36 -0
- package/lib/theme/Footer/{styles.module.css → Logo/styles.module.css} +2 -1
- package/{lib-next/theme/Footer/styles.module.css → lib/theme/Footer/index.d.ts} +4 -9
- package/lib/theme/Footer/index.js +17 -104
- package/lib/theme/Heading/index.d.ts +9 -0
- package/lib/theme/Heading/index.js +35 -68
- package/lib/theme/Heading/styles.module.css +25 -5
- package/lib/theme/IconArrow/index.d.ts +9 -0
- package/lib/theme/IconArrow/index.js +7 -18
- package/lib/theme/IconClose/index.d.ts +9 -0
- package/lib/theme/IconClose/index.js +23 -0
- package/lib/theme/IconDarkMode/index.d.ts +9 -0
- package/lib/theme/IconDarkMode/index.js +17 -0
- package/lib/theme/IconEdit/index.d.ts +9 -0
- package/lib/theme/IconEdit/index.js +16 -25
- package/lib/theme/IconExternalLink/index.d.ts +9 -0
- package/lib/theme/IconExternalLink/index.js +17 -24
- package/lib/theme/IconExternalLink/styles.module.css +0 -2
- package/lib/theme/IconHome/index.d.ts +9 -0
- package/lib/theme/IconHome/index.js +17 -0
- package/lib/theme/IconLanguage/index.d.ts +9 -0
- package/lib/theme/IconLanguage/index.js +16 -23
- package/lib/theme/IconLightMode/index.d.ts +9 -0
- package/lib/theme/IconLightMode/index.js +17 -0
- package/lib/theme/IconMenu/index.d.ts +9 -0
- package/lib/theme/IconMenu/index.js +21 -20
- package/lib/theme/LastUpdated/index.d.ts +9 -0
- package/lib/theme/LastUpdated/index.js +57 -42
- package/lib/theme/Layout/index.d.ts +10 -0
- package/lib/theme/Layout/index.js +33 -46
- package/lib/theme/LayoutProviders/index.d.ts +9 -0
- package/lib/theme/LayoutProviders/index.js +27 -30
- package/{lib-next/theme/BlogPostItem/styles.module.css → lib/theme/Logo/index.d.ts} +3 -12
- package/lib/theme/Logo/index.js +37 -49
- package/lib/theme/MDXComponents/A.d.ts +9 -0
- package/{lib-next/theme/ThemeContext.js → lib/theme/MDXComponents/A.js} +4 -2
- package/lib/theme/MDXComponents/Code.d.ts +9 -0
- package/lib/theme/MDXComponents/Code.js +28 -0
- package/lib/theme/MDXComponents/Details.d.ts +9 -0
- package/lib/theme/MDXComponents/Details.js +22 -0
- package/lib/theme/MDXComponents/Head.d.ts +9 -0
- package/lib/theme/MDXComponents/Head.js +23 -0
- package/lib/theme/MDXComponents/Heading.d.ts +9 -0
- package/{lib-next/theme/NavbarItem/SearchNavbarItem.js → lib/theme/MDXComponents/Heading.js} +3 -7
- package/lib/theme/MDXComponents/Img/index.d.ts +9 -0
- package/lib/theme/MDXComponents/Img/index.js +22 -0
- package/{lib-next/theme/IconEdit → lib/theme/MDXComponents/Img}/styles.module.css +2 -3
- package/lib/theme/MDXComponents/Pre.d.ts +9 -0
- package/lib/theme/MDXComponents/Pre.js +19 -0
- package/lib/theme/MDXComponents/Ul/index.d.ts +9 -0
- package/lib/theme/MDXComponents/Ul/index.js +21 -0
- package/lib/theme/MDXComponents/Ul/styles.module.css +14 -0
- package/lib/theme/MDXComponents/index.d.ts +9 -0
- package/lib/theme/MDXComponents/index.js +23 -57
- package/lib/theme/MDXContent/index.d.ts +9 -0
- package/lib/theme/MDXContent/index.js +12 -0
- package/lib/theme/MDXPage/index.d.ts +10 -0
- package/lib/theme/MDXPage/index.js +44 -56
- package/{lib-next/theme/Heading/styles.module.css → lib/theme/Navbar/ColorModeToggle/index.d.ts} +3 -9
- package/lib/theme/Navbar/ColorModeToggle/index.js +23 -0
- package/lib/theme/Navbar/Content/index.d.ts +8 -0
- package/lib/theme/Navbar/Content/index.js +71 -0
- package/lib/theme/Navbar/Content/styles.module.css +15 -0
- package/lib/theme/Navbar/Layout/index.d.ts +9 -0
- package/lib/theme/Navbar/Layout/index.js +52 -0
- package/{lib-next/theme/Navbar → lib/theme/Navbar/Layout}/styles.module.css +0 -6
- package/lib/theme/Navbar/Logo/index.d.ts +8 -0
- package/{lib-next/theme/TabItem → lib/theme/Navbar/Logo}/index.js +7 -12
- package/lib/theme/Navbar/MobileSidebar/Header/index.d.ts +8 -0
- package/lib/theme/Navbar/MobileSidebar/Header/index.js +31 -0
- package/lib/theme/Navbar/MobileSidebar/Layout/index.d.ts +9 -0
- package/lib/theme/Navbar/MobileSidebar/Layout/index.js +28 -0
- package/{lib-next/theme/TOCInline/styles.module.css → lib/theme/Navbar/MobileSidebar/PrimaryMenu/index.d.ts} +2 -6
- package/lib/theme/Navbar/MobileSidebar/PrimaryMenu/index.js +32 -0
- package/lib/theme/Navbar/MobileSidebar/SecondaryMenu/index.d.ts +8 -0
- package/lib/theme/Navbar/MobileSidebar/SecondaryMenu/index.js +35 -0
- package/lib/theme/Navbar/MobileSidebar/Toggle/index.d.ts +8 -0
- package/lib/theme/Navbar/MobileSidebar/Toggle/index.js +23 -0
- package/lib/theme/Navbar/MobileSidebar/index.d.ts +8 -0
- package/lib/theme/Navbar/MobileSidebar/index.js +29 -0
- package/lib/theme/Navbar/Search/index.d.ts +9 -0
- package/lib/theme/Navbar/Search/index.js +12 -0
- package/lib/theme/Navbar/Search/styles.module.css +20 -0
- package/lib/theme/Navbar/index.d.ts +8 -0
- package/lib/theme/Navbar/index.js +9 -140
- package/lib/theme/NavbarItem/ComponentTypes.d.ts +9 -0
- package/lib/theme/NavbarItem/ComponentTypes.js +27 -0
- package/lib/theme/NavbarItem/DefaultNavbarItem.d.ts +10 -0
- package/lib/theme/NavbarItem/DefaultNavbarItem.js +36 -193
- package/lib/theme/NavbarItem/DocNavbarItem.d.ts +9 -0
- package/lib/theme/NavbarItem/DocNavbarItem.js +24 -52
- package/lib/theme/NavbarItem/DocSidebarNavbarItem.d.ts +9 -0
- package/lib/theme/NavbarItem/DocSidebarNavbarItem.js +33 -0
- package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.d.ts +9 -0
- package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +75 -62
- package/lib/theme/NavbarItem/DocsVersionNavbarItem.d.ts +9 -0
- package/lib/theme/NavbarItem/DocsVersionNavbarItem.js +11 -32
- package/lib/theme/NavbarItem/DropdownNavbarItem.d.ts +9 -0
- package/lib/theme/NavbarItem/DropdownNavbarItem.js +162 -0
- package/lib/theme/NavbarItem/HtmlNavbarItem.d.ts +9 -0
- package/lib/theme/NavbarItem/HtmlNavbarItem.js +28 -0
- package/lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.d.ts +9 -0
- package/{src/theme/NavbarItem/LocaleDropdownNavbarItem.tsx → lib/theme/NavbarItem/LocaleDropdownNavbarItem/index.js} +28 -27
- package/{lib-next/theme/hooks/styles.css → lib/theme/NavbarItem/LocaleDropdownNavbarItem/styles.module.css} +3 -2
- package/lib/theme/NavbarItem/NavbarNavLink.d.ts +9 -0
- package/lib/theme/NavbarItem/NavbarNavLink.js +68 -0
- package/lib/theme/NavbarItem/SearchNavbarItem.d.ts +9 -0
- package/lib/theme/NavbarItem/SearchNavbarItem.js +10 -19
- package/lib/theme/NavbarItem/index.d.ts +9 -0
- package/lib/theme/NavbarItem/index.js +15 -45
- package/lib/theme/NotFound.d.ts +8 -0
- package/lib/theme/NotFound.js +44 -49
- package/lib/theme/PaginatorNavLink/index.d.ts +9 -0
- package/lib/theme/PaginatorNavLink/index.js +23 -0
- package/lib/theme/SearchBar.d.ts +7 -0
- package/lib/theme/SearchBar.js +11 -15
- package/lib/theme/SearchMetadata/index.d.ts +9 -0
- package/lib/theme/SearchMetadata/index.js +34 -0
- package/lib/theme/SiteMetadata/index.d.ts +8 -0
- package/lib/theme/SiteMetadata/index.js +117 -0
- package/lib/theme/SkipToContent/index.d.ts +8 -0
- package/lib/theme/SkipToContent/index.js +16 -62
- package/lib/theme/SkipToContent/styles.module.css +7 -0
- package/lib/theme/TOC/index.d.ts +9 -0
- package/lib/theme/TOC/index.js +18 -52
- package/lib/theme/TOC/styles.module.css +1 -1
- package/lib/theme/TOCCollapsible/CollapseButton/index.d.ts +9 -0
- package/lib/theme/TOCCollapsible/CollapseButton/index.js +29 -0
- package/lib/theme/TOCCollapsible/CollapseButton/styles.module.css +29 -0
- package/lib/theme/TOCCollapsible/index.d.ts +9 -0
- package/lib/theme/TOCCollapsible/index.js +42 -0
- package/lib/theme/TOCCollapsible/styles.module.css +31 -0
- package/lib/theme/TOCInline/index.d.ts +9 -0
- package/lib/theme/TOCInline/index.js +15 -46
- package/lib/theme/TOCItems/Tree.d.ts +11 -0
- package/lib/theme/TOCItems/Tree.js +37 -0
- package/lib/theme/TOCItems/index.d.ts +9 -0
- package/lib/theme/TOCItems/index.js +53 -0
- package/lib/theme/TabItem/index.d.ts +9 -0
- package/lib/theme/TabItem/index.js +11 -24
- package/lib/theme/{hooks/styles.css → TabItem/styles.module.css} +2 -2
- package/lib/theme/Tabs/index.d.ts +9 -0
- package/lib/theme/Tabs/index.js +159 -123
- package/lib/theme/Tabs/styles.module.css +4 -13
- package/lib/theme/Tag/index.d.ts +9 -0
- package/lib/theme/Tag/index.js +23 -0
- package/lib/theme/Tag/styles.module.css +70 -0
- package/lib/theme/TagsListByLetter/index.d.ts +9 -0
- package/lib/theme/TagsListByLetter/index.js +38 -0
- package/lib/theme/TagsListByLetter/styles.module.css +11 -0
- package/lib/theme/TagsListInline/index.d.ts +9 -0
- package/lib/theme/TagsListInline/index.js +31 -0
- package/lib/theme/TagsListInline/styles.module.css +15 -0
- package/lib/theme/ThemedImage/index.d.ts +9 -0
- package/lib/theme/ThemedImage/index.js +33 -43
- package/lib/theme/ThemedImage/styles.module.css +2 -2
- package/lib/theme/prism-include-languages.d.ts +8 -0
- package/lib/theme/prism-include-languages.js +19 -33
- package/lib/translations.d.ts +15 -0
- package/lib/translations.js +122 -122
- package/lib/validateThemeConfig.d.ts +12 -0
- package/lib/validateThemeConfig.js +367 -284
- package/package.json +36 -35
- package/src/admonitions.css +39 -0
- package/src/deps.d.ts +13 -0
- package/src/getSwizzleConfig.ts +245 -0
- package/src/index.ts +55 -76
- package/src/nprogress.css +41 -0
- package/src/nprogress.ts +31 -0
- package/{lib-next/prism-include-languages.js → src/prism-include-languages.ts} +0 -0
- package/src/theme/Admonition/index.tsx +106 -0
- package/src/theme/AnnouncementBar/index.tsx +9 -15
- package/src/theme/AnnouncementBar/styles.module.css +23 -32
- package/src/theme/BackToTopButton/index.tsx +34 -0
- package/src/theme/BackToTopButton/styles.module.css +44 -0
- package/src/theme/BlogArchivePage/index.tsx +92 -0
- package/src/theme/BlogLayout/index.tsx +38 -0
- package/src/theme/BlogListPage/index.tsx +45 -35
- package/src/theme/BlogListPaginator/index.tsx +27 -32
- package/src/theme/BlogPostAuthor/index.tsx +50 -0
- package/src/theme/BlogPostAuthors/index.tsx +49 -0
- package/{lib/theme/Toggle → src/theme/BlogPostAuthors}/styles.module.css +11 -7
- package/src/theme/BlogPostItem/index.tsx +86 -92
- package/src/theme/BlogPostItem/styles.module.css +9 -0
- package/src/theme/BlogPostPage/index.tsx +85 -39
- package/src/theme/BlogPostPaginator/index.tsx +27 -36
- package/src/theme/BlogSidebar/Desktop/index.tsx +45 -0
- package/src/theme/BlogSidebar/{styles.module.css → Desktop/styles.module.css} +5 -4
- package/src/theme/BlogSidebar/Mobile/index.tsx +38 -0
- package/src/theme/BlogSidebar/index.tsx +10 -33
- package/src/theme/BlogTagsListPage/index.tsx +24 -67
- package/src/theme/BlogTagsPostsPage/index.tsx +50 -49
- package/src/theme/CodeBlock/Container/index.tsx +35 -0
- package/src/theme/CodeBlock/Container/styles.module.css +14 -0
- package/src/theme/CodeBlock/Content/Element.tsx +30 -0
- package/src/theme/CodeBlock/Content/String.tsx +111 -0
- package/src/theme/CodeBlock/{styles.module.css → Content/styles.module.css} +45 -27
- package/src/theme/CodeBlock/CopyButton/index.tsx +67 -0
- package/src/theme/CodeBlock/CopyButton/styles.module.css +47 -0
- package/src/theme/CodeBlock/Line/index.tsx +49 -0
- package/src/theme/CodeBlock/Line/styles.module.css +51 -0
- package/src/theme/CodeBlock/WordWrapButton/index.tsx +49 -0
- package/src/theme/CodeBlock/WordWrapButton/styles.module.css +15 -0
- package/src/theme/CodeBlock/index.tsx +29 -253
- package/src/theme/ColorModeToggle/index.tsx +67 -0
- package/src/theme/ColorModeToggle/styles.module.css +35 -0
- package/src/theme/Details/index.tsx +26 -0
- package/src/theme/Details/styles.module.css +13 -0
- package/src/theme/DocBreadcrumbs/index.tsx +141 -0
- package/{lib-next/theme/Heading/styles.css → src/theme/DocBreadcrumbs/styles.module.css} +9 -13
- package/src/theme/DocCard/index.tsx +117 -0
- package/src/theme/DocCard/styles.module.css +34 -0
- package/src/theme/DocCardList/index.tsx +35 -0
- package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +86 -0
- package/src/theme/DocCategoryGeneratedIndexPage/styles.module.css +26 -0
- package/src/theme/DocItem/index.tsx +92 -77
- package/src/theme/DocItem/styles.module.css +12 -10
- package/src/theme/DocItemFooter/index.tsx +90 -0
- package/{lib-next/theme/Toggle → src/theme/DocItemFooter}/styles.module.css +9 -8
- package/src/theme/DocPage/Layout/Main/index.tsx +36 -0
- package/src/theme/DocPage/Layout/Main/styles.module.css +28 -0
- package/src/theme/DocPage/Layout/Sidebar/ExpandButton/index.tsx +40 -0
- package/src/theme/DocPage/Layout/Sidebar/ExpandButton/styles.module.css +33 -0
- package/src/theme/DocPage/Layout/Sidebar/index.tsx +73 -0
- package/src/theme/DocPage/Layout/Sidebar/styles.module.css +32 -0
- package/src/theme/DocPage/Layout/index.tsx +38 -0
- package/src/theme/DocPage/Layout/styles.module.css +15 -0
- package/src/theme/DocPage/index.tsx +39 -167
- package/src/theme/DocPaginator/index.tsx +28 -39
- package/src/theme/DocSidebar/Desktop/CollapseButton/index.tsx +38 -0
- package/src/theme/DocSidebar/Desktop/CollapseButton/styles.module.css +46 -0
- package/src/theme/DocSidebar/Desktop/Content/index.tsx +55 -0
- package/src/theme/DocSidebar/Desktop/Content/styles.module.css +23 -0
- package/src/theme/DocSidebar/Desktop/index.tsx +40 -0
- package/src/theme/DocSidebar/Desktop/styles.module.css +50 -0
- package/src/theme/DocSidebar/Mobile/index.tsx +54 -0
- package/src/theme/DocSidebar/index.tsx +14 -351
- package/src/theme/DocSidebarItem/Category/index.tsx +209 -0
- package/src/theme/DocSidebarItem/Html/index.tsx +34 -0
- package/src/theme/DocSidebarItem/Html/styles.module.css +13 -0
- package/src/theme/DocSidebarItem/Link/index.tsx +57 -0
- package/src/theme/DocSidebarItem/Link/styles.module.css +10 -0
- package/src/theme/DocSidebarItem/index.tsx +27 -0
- package/src/theme/DocSidebarItems/index.tsx +27 -0
- package/src/theme/DocTagDocListPage/index.tsx +95 -0
- package/src/theme/DocTagsListPage/index.tsx +43 -0
- package/src/theme/DocVersionBadge/index.tsx +35 -0
- package/src/theme/DocVersionBanner/index.tsx +53 -27
- package/src/theme/EditThisPage/index.tsx +7 -3
- package/src/theme/ErrorPageContent.tsx +41 -0
- package/src/theme/Footer/Copyright/index.tsx +20 -0
- package/src/theme/Footer/Layout/index.tsx +34 -0
- package/src/theme/Footer/LinkItem/index.tsx +36 -0
- package/src/theme/Footer/Links/MultiColumn/index.tsx +51 -0
- package/src/theme/Footer/Links/Simple/index.tsx +42 -0
- package/src/theme/Footer/Links/index.tsx +21 -0
- package/src/theme/Footer/Logo/index.tsx +41 -0
- package/src/theme/Footer/{styles.module.css → Logo/styles.module.css} +2 -1
- package/src/theme/Footer/index.tsx +13 -122
- package/src/theme/Heading/index.tsx +31 -58
- package/src/theme/Heading/styles.module.css +25 -5
- package/src/theme/IconArrow/index.tsx +2 -4
- package/src/theme/IconClose/index.tsx +26 -0
- package/src/theme/IconDarkMode/index.tsx +20 -0
- package/src/theme/IconEdit/index.tsx +5 -5
- package/src/theme/IconExternalLink/index.tsx +3 -5
- package/src/theme/IconExternalLink/styles.module.css +0 -2
- package/src/theme/IconHome/index.tsx +20 -0
- package/src/theme/IconLanguage/index.tsx +6 -8
- package/src/theme/IconLightMode/index.tsx +20 -0
- package/src/theme/IconMenu/index.tsx +3 -5
- package/src/theme/LastUpdated/index.tsx +4 -2
- package/src/theme/Layout/index.tsx +22 -16
- package/src/theme/LayoutProviders/index.tsx +16 -9
- package/src/theme/Logo/index.tsx +23 -22
- package/src/theme/{ThemeContext.ts → MDXComponents/A.tsx} +5 -6
- package/src/theme/MDXComponents/Code.tsx +37 -0
- package/src/theme/MDXComponents/Details.tsx +27 -0
- package/src/theme/MDXComponents/Head.tsx +31 -0
- package/src/theme/MDXComponents/Heading.tsx +14 -0
- package/src/theme/MDXComponents/Img/index.tsx +27 -0
- package/src/theme/MDXComponents/Img/styles.module.css +10 -0
- package/src/theme/MDXComponents/Pre.tsx +22 -0
- package/src/theme/MDXComponents/Ul/index.tsx +26 -0
- package/src/theme/MDXComponents/Ul/styles.module.css +14 -0
- package/src/theme/MDXComponents/index.tsx +23 -42
- package/src/theme/MDXContent/index.tsx +15 -0
- package/src/theme/MDXPage/index.tsx +38 -35
- package/src/theme/Navbar/ColorModeToggle/index.tsx +30 -0
- package/src/theme/Navbar/Content/index.tsx +86 -0
- package/src/theme/Navbar/Content/styles.module.css +15 -0
- package/src/theme/Navbar/Layout/index.tsx +57 -0
- package/{lib/theme/Navbar → src/theme/Navbar/Layout}/styles.module.css +0 -6
- package/src/theme/Navbar/Logo/index.tsx +19 -0
- package/src/theme/Navbar/MobileSidebar/Header/index.tsx +34 -0
- package/src/theme/Navbar/MobileSidebar/Layout/index.tsx +31 -0
- package/src/theme/Navbar/MobileSidebar/PrimaryMenu/index.tsx +37 -0
- package/src/theme/Navbar/MobileSidebar/SecondaryMenu/index.tsx +38 -0
- package/src/theme/Navbar/MobileSidebar/Toggle/index.tsx +25 -0
- package/src/theme/Navbar/MobileSidebar/index.tsx +33 -0
- package/src/theme/Navbar/Search/index.tsx +19 -0
- package/src/theme/Navbar/Search/styles.module.css +20 -0
- package/src/theme/Navbar/index.tsx +7 -147
- package/src/theme/NavbarItem/ComponentTypes.tsx +32 -0
- package/src/theme/NavbarItem/DefaultNavbarItem.tsx +36 -208
- package/src/theme/NavbarItem/DocNavbarItem.tsx +13 -41
- package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +36 -0
- package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +59 -52
- package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +5 -8
- package/src/theme/NavbarItem/DropdownNavbarItem.tsx +191 -0
- package/src/theme/NavbarItem/HtmlNavbarItem.tsx +32 -0
- package/src/theme/NavbarItem/LocaleDropdownNavbarItem/index.tsx +77 -0
- package/src/theme/NavbarItem/LocaleDropdownNavbarItem/styles.module.css +11 -0
- package/src/theme/NavbarItem/NavbarNavLink.tsx +74 -0
- package/src/theme/NavbarItem/SearchNavbarItem.tsx +11 -3
- package/src/theme/NavbarItem/index.tsx +15 -32
- package/src/theme/NotFound.tsx +40 -37
- package/src/theme/PaginatorNavLink/index.tsx +26 -0
- package/src/theme/SearchBar.tsx +2 -1
- package/src/theme/SearchMetadata/index.tsx +43 -0
- package/src/theme/{LayoutHead → SiteMetadata}/index.tsx +31 -44
- package/src/theme/SkipToContent/index.tsx +5 -33
- package/src/theme/SkipToContent/styles.module.css +7 -0
- package/src/theme/TOC/index.tsx +14 -44
- package/src/theme/TOC/styles.module.css +1 -1
- package/src/theme/TOCCollapsible/CollapseButton/index.tsx +36 -0
- package/src/theme/TOCCollapsible/CollapseButton/styles.module.css +29 -0
- package/src/theme/TOCCollapsible/index.tsx +46 -0
- package/src/theme/TOCCollapsible/styles.module.css +31 -0
- package/src/theme/TOCInline/index.tsx +15 -35
- package/src/theme/TOCItems/Tree.tsx +46 -0
- package/src/theme/TOCItems/index.tsx +61 -0
- package/src/theme/TabItem/index.tsx +12 -4
- package/src/theme/TabItem/styles.module.css +10 -0
- package/src/theme/Tabs/index.tsx +121 -62
- package/src/theme/Tabs/styles.module.css +4 -13
- package/src/theme/Tag/index.tsx +27 -0
- package/src/theme/Tag/styles.module.css +70 -0
- package/src/theme/TagsListByLetter/index.tsx +43 -0
- package/src/theme/TagsListByLetter/styles.module.css +11 -0
- package/src/theme/TagsListInline/index.tsx +35 -0
- package/src/theme/TagsListInline/styles.module.css +15 -0
- package/src/theme/ThemedImage/index.tsx +10 -12
- package/src/theme/ThemedImage/styles.module.css +2 -2
- package/src/theme/prism-include-languages.ts +20 -15
- package/src/theme-classic.d.ts +1272 -0
- package/src/translations.ts +85 -60
- package/src/validateThemeConfig.ts +448 -0
- package/babel.config.js +0 -35
- package/codeTranslations/README.md +0 -20
- package/codeTranslations/ar.json +0 -57
- package/codeTranslations/base.json +0 -112
- package/codeTranslations/bn.json +0 -56
- package/codeTranslations/da.json +0 -57
- package/codeTranslations/de.json +0 -57
- package/codeTranslations/es.json +0 -57
- package/codeTranslations/fa.json +0 -57
- package/codeTranslations/fil.json +0 -57
- package/codeTranslations/fr.json +0 -57
- package/codeTranslations/he.json +0 -57
- package/codeTranslations/hi.json +0 -57
- package/codeTranslations/ja.json +0 -57
- package/codeTranslations/ko.json +0 -57
- package/codeTranslations/pl.json +0 -57
- package/codeTranslations/pt-BR.json +0 -57
- package/codeTranslations/pt-PT.json +0 -57
- package/codeTranslations/ru.json +0 -57
- package/codeTranslations/tr.json +0 -57
- package/codeTranslations/vi.json +0 -57
- package/codeTranslations/zh-Hans.json +0 -57
- package/codeTranslations/zh-Hant.json +0 -57
- package/lib/__tests__/__snapshots__/translations.test.ts.snap +0 -116
- package/lib/__tests__/translations.test.js +0 -112
- package/lib/__tests__/validateThemeConfig.test.js +0 -333
- package/lib/theme/BlogSidebar/styles.module.css +0 -44
- package/lib/theme/CodeBlock/styles.module.css +0 -68
- package/lib/theme/DocPage/styles.module.css +0 -80
- package/lib/theme/DocSidebar/styles.module.css +0 -124
- package/lib/theme/LayoutHead/index.js +0 -144
- package/lib/theme/NavbarItem/LocaleDropdownNavbarItem.js +0 -72
- package/lib/theme/SearchMetadatas/index.js +0 -33
- package/lib/theme/Seo/index.js +0 -49
- package/lib/theme/ThemeContext.js +0 -21
- package/lib/theme/ThemeProvider/index.js +0 -38
- package/lib/theme/Toggle/index.js +0 -94
- package/lib/theme/Toggle/styles.css +0 -103
- package/lib/theme/UserPreferencesContext.js +0 -18
- package/lib/theme/UserPreferencesProvider/index.js +0 -36
- package/lib/theme/hooks/useContextualSearchFilters.js +0 -47
- package/lib/theme/hooks/useDocs.js +0 -18
- package/lib/theme/hooks/useHideableNavbar.js +0 -92
- package/lib/theme/hooks/useKeyboardNavigation.js +0 -45
- package/lib/theme/hooks/useLocationHash.js +0 -28
- package/lib/theme/hooks/useLockBodyScroll.js +0 -26
- package/lib/theme/hooks/usePrismTheme.js +0 -36
- package/lib/theme/hooks/useScrollPosition.js +0 -49
- package/lib/theme/hooks/useTOCHighlight.js +0 -87
- package/lib/theme/hooks/useTabGroupChoice.js +0 -51
- package/lib/theme/hooks/useTheme.js +0 -99
- package/lib/theme/hooks/useThemeContext.js +0 -31
- package/lib/theme/hooks/useUserPreferencesContext.js +0 -31
- package/lib/theme/hooks/useWindowSize.js +0 -55
- package/lib/types.d.ts +0 -598
- package/lib-next/__tests__/__snapshots__/translations.test.ts.snap +0 -116
- package/lib-next/__tests__/translations.test.js +0 -128
- package/lib-next/__tests__/validateThemeConfig.test.js +0 -333
- package/lib-next/index.js +0 -221
- package/lib-next/theme/AnnouncementBar/index.js +0 -61
- package/lib-next/theme/AnnouncementBar/styles.module.css +0 -72
- package/lib-next/theme/BlogListPage/index.js +0 -56
- package/lib-next/theme/BlogListPaginator/index.js +0 -54
- package/lib-next/theme/BlogPostItem/index.js +0 -168
- package/lib-next/theme/BlogPostPage/index.js +0 -55
- package/lib-next/theme/BlogPostPaginator/index.js +0 -57
- package/lib-next/theme/BlogTagsListPage/index.js +0 -75
- package/lib-next/theme/BlogTagsPostsPage/index.js +0 -92
- package/lib-next/theme/CodeBlock/index.js +0 -268
- package/lib-next/theme/DocItem/index.js +0 -117
- package/lib-next/theme/DocPage/index.js +0 -173
- package/lib-next/theme/DocPage/styles.module.css +0 -80
- package/lib-next/theme/DocPaginator/index.js +0 -59
- package/lib-next/theme/DocSidebar/index.js +0 -352
- package/lib-next/theme/DocSidebar/styles.module.css +0 -124
- package/lib-next/theme/DocVersionBanner/index.js +0 -127
- package/lib-next/theme/EditThisPage/index.js +0 -21
- package/lib-next/theme/Footer/index.js +0 -129
- package/lib-next/theme/Heading/index.js +0 -67
- package/lib-next/theme/IconArrow/index.js +0 -20
- package/lib-next/theme/IconEdit/index.js +0 -28
- package/lib-next/theme/IconExternalLink/index.js +0 -26
- package/lib-next/theme/IconLanguage/index.js +0 -25
- package/lib-next/theme/IconMenu/index.js +0 -29
- package/lib-next/theme/LastUpdated/index.js +0 -77
- package/lib-next/theme/Layout/index.js +0 -46
- package/lib-next/theme/Layout/styles.css +0 -27
- package/lib-next/theme/LayoutHead/index.js +0 -137
- package/lib-next/theme/LayoutProviders/index.js +0 -26
- package/lib-next/theme/Logo/index.js +0 -54
- package/lib-next/theme/MDXComponents/index.js +0 -51
- package/lib-next/theme/MDXPage/index.js +0 -51
- package/lib-next/theme/Navbar/index.js +0 -146
- package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +0 -227
- package/lib-next/theme/NavbarItem/DocNavbarItem.js +0 -57
- package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +0 -83
- package/lib-next/theme/NavbarItem/DocsVersionNavbarItem.js +0 -28
- package/lib-next/theme/NavbarItem/LocaleDropdownNavbarItem.js +0 -66
- package/lib-next/theme/NavbarItem/index.js +0 -41
- package/lib-next/theme/NotFound.js +0 -50
- package/lib-next/theme/SearchBar.js +0 -11
- package/lib-next/theme/SearchMetadatas/index.js +0 -20
- package/lib-next/theme/Seo/index.js +0 -36
- package/lib-next/theme/SkipToContent/index.js +0 -53
- package/lib-next/theme/SkipToContent/styles.module.css +0 -14
- package/lib-next/theme/TOC/index.js +0 -52
- package/lib-next/theme/TOC/styles.module.css +0 -23
- package/lib-next/theme/TOCInline/index.js +0 -43
- package/lib-next/theme/Tabs/index.js +0 -144
- package/lib-next/theme/Tabs/styles.module.css +0 -23
- package/lib-next/theme/ThemeProvider/index.js +0 -25
- package/lib-next/theme/ThemedImage/index.js +0 -41
- package/lib-next/theme/ThemedImage/styles.module.css +0 -18
- package/lib-next/theme/Toggle/index.js +0 -80
- package/lib-next/theme/Toggle/styles.css +0 -103
- package/lib-next/theme/UserPreferencesContext.js +0 -9
- package/lib-next/theme/UserPreferencesProvider/index.js +0 -24
- package/lib-next/theme/hooks/useContextualSearchFilters.js +0 -41
- package/lib-next/theme/hooks/useDocs.js +0 -10
- package/lib-next/theme/hooks/useHideableNavbar.js +0 -79
- package/lib-next/theme/hooks/useKeyboardNavigation.js +0 -35
- package/lib-next/theme/hooks/useLocationHash.js +0 -20
- package/lib-next/theme/hooks/useLockBodyScroll.js +0 -18
- package/lib-next/theme/hooks/usePrismTheme.js +0 -20
- package/lib-next/theme/hooks/useScrollPosition.js +0 -38
- package/lib-next/theme/hooks/useTOCHighlight.js +0 -84
- package/lib-next/theme/hooks/useTabGroupChoice.js +0 -39
- package/lib-next/theme/hooks/useTheme.js +0 -82
- package/lib-next/theme/hooks/useThemeContext.js +0 -22
- package/lib-next/theme/hooks/useUserPreferencesContext.js +0 -22
- package/lib-next/theme/hooks/useWindowSize.js +0 -45
- package/lib-next/theme/prism-include-languages.js +0 -23
- package/lib-next/translations.js +0 -145
- package/lib-next/types.d.ts +0 -598
- package/lib-next/validateThemeConfig.js +0 -317
- package/src/__tests__/__snapshots__/translations.test.ts.snap +0 -116
- package/src/__tests__/translations.test.ts +0 -116
- package/src/__tests__/validateThemeConfig.test.js +0 -333
- package/src/prism-include-languages.js +0 -11
- package/src/theme/DocPage/styles.module.css +0 -80
- package/src/theme/DocSidebar/styles.module.css +0 -124
- package/src/theme/Heading/styles.css +0 -23
- package/src/theme/Navbar/styles.module.css +0 -20
- package/src/theme/SearchMetadatas/index.tsx +0 -28
- package/src/theme/Seo/index.tsx +0 -46
- package/src/theme/ThemeProvider/index.tsx +0 -24
- package/src/theme/Toggle/index.tsx +0 -100
- package/src/theme/Toggle/styles.css +0 -103
- package/src/theme/UserPreferencesContext.ts +0 -12
- package/src/theme/UserPreferencesProvider/index.tsx +0 -27
- package/src/theme/hooks/styles.css +0 -10
- package/src/theme/hooks/useContextualSearchFilters.ts +0 -52
- package/src/theme/hooks/useDocs.ts +0 -11
- package/src/theme/hooks/useHideableNavbar.ts +0 -85
- package/src/theme/hooks/useKeyboardNavigation.ts +0 -39
- package/src/theme/hooks/useLocationHash.ts +0 -25
- package/src/theme/hooks/usePrismTheme.ts +0 -22
- package/src/theme/hooks/useScrollPosition.ts +0 -45
- package/src/theme/hooks/useTOCHighlight.ts +0 -98
- package/src/theme/hooks/useTabGroupChoice.ts +0 -46
- package/src/theme/hooks/useTheme.ts +0 -92
- package/src/theme/hooks/useThemeContext.ts +0 -23
- package/src/theme/hooks/useUserPreferencesContext.ts +0 -25
- package/src/theme/hooks/useWindowSize.ts +0 -51
- package/src/types.d.ts +0 -598
- package/src/validateThemeConfig.js +0 -317
- package/tsconfig.json +0 -12
- package/update-code-translations.js +0 -240
- package/update-code-translations.test.js +0 -33
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import React, {useState, useRef, memo, CSSProperties} from 'react';
|
|
9
|
-
import type {Props} from '@theme/Toggle';
|
|
10
|
-
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
11
|
-
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
12
|
-
|
|
13
|
-
import clsx from 'clsx';
|
|
14
|
-
import './styles.css';
|
|
15
|
-
import styles from './styles.module.css';
|
|
16
|
-
|
|
17
|
-
interface IconProps {
|
|
18
|
-
icon: string;
|
|
19
|
-
style: CSSProperties;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const Dark = ({icon, style}: IconProps): JSX.Element => (
|
|
23
|
-
<span className={clsx(styles.toggle, styles.dark)} style={style}>
|
|
24
|
-
{icon}
|
|
25
|
-
</span>
|
|
26
|
-
);
|
|
27
|
-
const Light = ({icon, style}: IconProps): JSX.Element => (
|
|
28
|
-
<span className={clsx(styles.toggle, styles.light)} style={style}>
|
|
29
|
-
{icon}
|
|
30
|
-
</span>
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
// Based on react-toggle (https://github.com/aaronshaf/react-toggle/).
|
|
34
|
-
const Toggle = memo(
|
|
35
|
-
({
|
|
36
|
-
className,
|
|
37
|
-
icons,
|
|
38
|
-
checked: defaultChecked,
|
|
39
|
-
disabled,
|
|
40
|
-
onChange,
|
|
41
|
-
}: Props & {
|
|
42
|
-
icons: {checked: JSX.Element; unchecked: JSX.Element};
|
|
43
|
-
disabled: boolean;
|
|
44
|
-
}): JSX.Element => {
|
|
45
|
-
const [checked, setChecked] = useState(defaultChecked);
|
|
46
|
-
const [focused, setFocused] = useState(false);
|
|
47
|
-
const inputRef = useRef<HTMLInputElement>(null);
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<div
|
|
51
|
-
className={clsx('react-toggle', className, {
|
|
52
|
-
'react-toggle--checked': checked,
|
|
53
|
-
'react-toggle--focus': focused,
|
|
54
|
-
'react-toggle--disabled': disabled,
|
|
55
|
-
})}>
|
|
56
|
-
<div
|
|
57
|
-
className="react-toggle-track"
|
|
58
|
-
role="button"
|
|
59
|
-
tabIndex={-1}
|
|
60
|
-
onClick={() => inputRef.current?.click()}>
|
|
61
|
-
<div className="react-toggle-track-check">{icons.checked}</div>
|
|
62
|
-
<div className="react-toggle-track-x">{icons.unchecked}</div>
|
|
63
|
-
<div className="react-toggle-thumb" />
|
|
64
|
-
</div>
|
|
65
|
-
|
|
66
|
-
<input
|
|
67
|
-
ref={inputRef}
|
|
68
|
-
checked={checked}
|
|
69
|
-
type="checkbox"
|
|
70
|
-
className="react-toggle-screenreader-only"
|
|
71
|
-
aria-label="Switch between dark and light mode"
|
|
72
|
-
onChange={onChange}
|
|
73
|
-
onClick={() => setChecked(!checked)}
|
|
74
|
-
onFocus={() => setFocused(true)}
|
|
75
|
-
onBlur={() => setFocused(false)}
|
|
76
|
-
/>
|
|
77
|
-
</div>
|
|
78
|
-
);
|
|
79
|
-
},
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
export default function (props: Props): JSX.Element {
|
|
83
|
-
const {
|
|
84
|
-
colorMode: {
|
|
85
|
-
switchConfig: {darkIcon, darkIconStyle, lightIcon, lightIconStyle},
|
|
86
|
-
},
|
|
87
|
-
} = useThemeConfig();
|
|
88
|
-
const {isClient} = useDocusaurusContext();
|
|
89
|
-
|
|
90
|
-
return (
|
|
91
|
-
<Toggle
|
|
92
|
-
disabled={!isClient}
|
|
93
|
-
icons={{
|
|
94
|
-
checked: <Dark icon={darkIcon} style={darkIconStyle} />,
|
|
95
|
-
unchecked: <Light icon={lightIcon} style={lightIconStyle} />,
|
|
96
|
-
}}
|
|
97
|
-
{...props}
|
|
98
|
-
/>
|
|
99
|
-
);
|
|
100
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Styles for React Toggle
|
|
10
|
-
* copied over because we want to allow user to swizzle it and modify the css
|
|
11
|
-
* and also to make sure its compatible with our dark mode
|
|
12
|
-
* https://github.com/aaronshaf/react-toggle/blob/master/style.css
|
|
13
|
-
*/
|
|
14
|
-
.react-toggle {
|
|
15
|
-
touch-action: pan-x;
|
|
16
|
-
position: relative;
|
|
17
|
-
cursor: pointer;
|
|
18
|
-
user-select: none;
|
|
19
|
-
-webkit-tap-highlight-color: transparent;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.react-toggle-screenreader-only {
|
|
23
|
-
border: 0;
|
|
24
|
-
clip: rect(0 0 0 0);
|
|
25
|
-
height: 1px;
|
|
26
|
-
margin: -1px;
|
|
27
|
-
overflow: hidden;
|
|
28
|
-
position: absolute;
|
|
29
|
-
width: 1px;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.react-toggle--disabled {
|
|
33
|
-
cursor: not-allowed;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.react-toggle-track {
|
|
37
|
-
width: 50px;
|
|
38
|
-
height: 24px;
|
|
39
|
-
border-radius: 30px;
|
|
40
|
-
background-color: #4d4d4d;
|
|
41
|
-
transition: all 0.2s ease;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.react-toggle-track-check {
|
|
45
|
-
position: absolute;
|
|
46
|
-
width: 14px;
|
|
47
|
-
height: 10px;
|
|
48
|
-
top: 0px;
|
|
49
|
-
bottom: 0px;
|
|
50
|
-
margin: auto 0;
|
|
51
|
-
left: 8px;
|
|
52
|
-
opacity: 0;
|
|
53
|
-
transition: opacity 0.25s ease;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
[data-theme='dark'] .react-toggle .react-toggle-track-check,
|
|
57
|
-
.react-toggle--checked .react-toggle-track-check {
|
|
58
|
-
opacity: 1;
|
|
59
|
-
transition: opacity 0.25s ease;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.react-toggle-track-x {
|
|
63
|
-
position: absolute;
|
|
64
|
-
width: 10px;
|
|
65
|
-
height: 10px;
|
|
66
|
-
top: 0px;
|
|
67
|
-
bottom: 0px;
|
|
68
|
-
margin: auto 0;
|
|
69
|
-
right: 10px;
|
|
70
|
-
opacity: 1;
|
|
71
|
-
transition: opacity 0.25s ease;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
[data-theme='dark'] .react-toggle .react-toggle-track-x,
|
|
75
|
-
.react-toggle--checked .react-toggle-track-x {
|
|
76
|
-
opacity: 0;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.react-toggle-thumb {
|
|
80
|
-
position: absolute;
|
|
81
|
-
top: 1px;
|
|
82
|
-
left: 1px;
|
|
83
|
-
width: 22px;
|
|
84
|
-
height: 22px;
|
|
85
|
-
border: 1px solid #4d4d4d;
|
|
86
|
-
border-radius: 50%;
|
|
87
|
-
background-color: #fafafa;
|
|
88
|
-
transition: all 0.25s ease;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
[data-theme='dark'] .react-toggle .react-toggle-thumb,
|
|
92
|
-
.react-toggle--checked .react-toggle-thumb {
|
|
93
|
-
left: 27px;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.react-toggle--focus .react-toggle-thumb,
|
|
97
|
-
.react-toggle:hover .react-toggle-thumb {
|
|
98
|
-
box-shadow: 0px 0px 2px 3px var(--ifm-color-primary);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.react-toggle:active:not(.react-toggle--disabled) .react-toggle-thumb {
|
|
102
|
-
box-shadow: 0px 0px 5px 5px var(--ifm-color-primary);
|
|
103
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import {createContext} from 'react';
|
|
9
|
-
|
|
10
|
-
const UserPreferencesContext = createContext(undefined);
|
|
11
|
-
|
|
12
|
-
export default UserPreferencesContext;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import React from 'react';
|
|
9
|
-
|
|
10
|
-
import useTabGroupChoice from '@theme/hooks/useTabGroupChoice';
|
|
11
|
-
import UserPreferencesContext from '@theme/UserPreferencesContext';
|
|
12
|
-
import type {Props} from '@theme/UserPreferencesProvider';
|
|
13
|
-
|
|
14
|
-
function UserPreferencesProvider(props: Props): JSX.Element {
|
|
15
|
-
const {tabGroupChoices, setTabGroupChoices} = useTabGroupChoice();
|
|
16
|
-
return (
|
|
17
|
-
<UserPreferencesContext.Provider
|
|
18
|
-
value={{
|
|
19
|
-
tabGroupChoices,
|
|
20
|
-
setTabGroupChoices,
|
|
21
|
-
}}>
|
|
22
|
-
{props.children}
|
|
23
|
-
</UserPreferencesContext.Provider>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default UserPreferencesProvider;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
body:not(.navigation-with-keyboard) *:not(input):focus {
|
|
9
|
-
outline: none;
|
|
10
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
import {useAllDocsData, useActivePluginAndVersion} from '@theme/hooks/useDocs';
|
|
8
|
-
import {
|
|
9
|
-
useDocsPreferredVersionByPluginId,
|
|
10
|
-
DEFAULT_SEARCH_TAG,
|
|
11
|
-
docVersionSearchTag,
|
|
12
|
-
} from '@docusaurus/theme-common';
|
|
13
|
-
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
14
|
-
|
|
15
|
-
type ContextualSearchFilters = {
|
|
16
|
-
locale: string;
|
|
17
|
-
tags: string[];
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// We may want to support multiple search engines, don't couple that to Algolia/DocSearch
|
|
21
|
-
// Maybe users will want to use its own search engine solution
|
|
22
|
-
export default function useContextualSearchFilters(): ContextualSearchFilters {
|
|
23
|
-
const {i18n} = useDocusaurusContext();
|
|
24
|
-
const allDocsData = useAllDocsData();
|
|
25
|
-
const activePluginAndVersion = useActivePluginAndVersion();
|
|
26
|
-
const docsPreferredVersionByPluginId = useDocsPreferredVersionByPluginId();
|
|
27
|
-
|
|
28
|
-
function getDocPluginTags(pluginId: string) {
|
|
29
|
-
const activeVersion =
|
|
30
|
-
activePluginAndVersion?.activePlugin?.pluginId === pluginId
|
|
31
|
-
? activePluginAndVersion.activeVersion
|
|
32
|
-
: undefined;
|
|
33
|
-
|
|
34
|
-
const preferredVersion = docsPreferredVersionByPluginId[pluginId];
|
|
35
|
-
|
|
36
|
-
const latestVersion = allDocsData[pluginId].versions.find((v) => v.isLast);
|
|
37
|
-
|
|
38
|
-
const version = activeVersion ?? preferredVersion ?? latestVersion;
|
|
39
|
-
|
|
40
|
-
return docVersionSearchTag(pluginId, version.name);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const tags = [
|
|
44
|
-
DEFAULT_SEARCH_TAG,
|
|
45
|
-
...Object.keys(allDocsData).map(getDocPluginTags),
|
|
46
|
-
];
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
locale: i18n.currentLocale,
|
|
50
|
-
tags,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// Re-expose useDocs
|
|
9
|
-
// Ensure it's always statically available even if user is not using the docs plugin
|
|
10
|
-
// Problem reported for the blog-only mode: https://github.com/facebook/docusaurus/issues/3360
|
|
11
|
-
export * from '@docusaurus/plugin-content-docs/lib/theme/hooks/useDocs';
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import {useState, useCallback, useEffect, useRef} from 'react';
|
|
9
|
-
import {useLocation} from '@docusaurus/router';
|
|
10
|
-
import useScrollPosition from '@theme/hooks/useScrollPosition';
|
|
11
|
-
import {useLocationChange} from '@docusaurus/theme-common';
|
|
12
|
-
import type {useHideableNavbarReturns} from '@theme/hooks/useHideableNavbar';
|
|
13
|
-
|
|
14
|
-
const useHideableNavbar = (hideOnScroll: boolean): useHideableNavbarReturns => {
|
|
15
|
-
const location = useLocation();
|
|
16
|
-
const [isNavbarVisible, setIsNavbarVisible] = useState(hideOnScroll);
|
|
17
|
-
const isFocusedAnchor = useRef(false);
|
|
18
|
-
const [navbarHeight, setNavbarHeight] = useState(0);
|
|
19
|
-
const navbarRef = useCallback((node: HTMLElement | null) => {
|
|
20
|
-
if (node !== null) {
|
|
21
|
-
setNavbarHeight(node.getBoundingClientRect().height);
|
|
22
|
-
}
|
|
23
|
-
}, []);
|
|
24
|
-
|
|
25
|
-
useScrollPosition(
|
|
26
|
-
({scrollY: scrollTop}, {scrollY: lastScrollTop}) => {
|
|
27
|
-
if (!hideOnScroll) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (scrollTop < navbarHeight) {
|
|
32
|
-
setIsNavbarVisible(true);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (isFocusedAnchor.current) {
|
|
37
|
-
isFocusedAnchor.current = false;
|
|
38
|
-
setIsNavbarVisible(false);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (lastScrollTop && scrollTop === 0) {
|
|
43
|
-
setIsNavbarVisible(true);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const documentHeight =
|
|
47
|
-
document.documentElement.scrollHeight - navbarHeight;
|
|
48
|
-
const windowHeight = window.innerHeight;
|
|
49
|
-
|
|
50
|
-
if (lastScrollTop && scrollTop >= lastScrollTop) {
|
|
51
|
-
setIsNavbarVisible(false);
|
|
52
|
-
} else if (scrollTop + windowHeight < documentHeight) {
|
|
53
|
-
setIsNavbarVisible(true);
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
[navbarHeight, isFocusedAnchor],
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
useLocationChange((locationChangeEvent) => {
|
|
60
|
-
if (!hideOnScroll || locationChangeEvent.location.hash) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
setIsNavbarVisible(true);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
if (!hideOnScroll) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (!location.hash) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
isFocusedAnchor.current = true;
|
|
77
|
-
}, [location.hash]);
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
navbarRef,
|
|
81
|
-
isNavbarVisible,
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export default useHideableNavbar;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import {useEffect} from 'react';
|
|
9
|
-
|
|
10
|
-
import './styles.css';
|
|
11
|
-
|
|
12
|
-
// This hook detect keyboard focus indicator to not show outline for mouse users
|
|
13
|
-
// Inspired by https://hackernoon.com/removing-that-ugly-focus-ring-and-keeping-it-too-6c8727fefcd2
|
|
14
|
-
function useKeyboardNavigation(): void {
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
const keyboardFocusedClassName = 'navigation-with-keyboard';
|
|
17
|
-
|
|
18
|
-
function handleOutlineStyles(e: MouseEvent | KeyboardEvent) {
|
|
19
|
-
if (e.type === 'keydown' && (e as KeyboardEvent).key === 'Tab') {
|
|
20
|
-
document.body.classList.add(keyboardFocusedClassName);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (e.type === 'mousedown') {
|
|
24
|
-
document.body.classList.remove(keyboardFocusedClassName);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
document.addEventListener('keydown', handleOutlineStyles);
|
|
29
|
-
document.addEventListener('mousedown', handleOutlineStyles);
|
|
30
|
-
|
|
31
|
-
return () => {
|
|
32
|
-
document.body.classList.remove(keyboardFocusedClassName);
|
|
33
|
-
document.removeEventListener('keydown', handleOutlineStyles);
|
|
34
|
-
document.removeEventListener('mousedown', handleOutlineStyles);
|
|
35
|
-
};
|
|
36
|
-
}, []);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default useKeyboardNavigation;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import {useState, useEffect} from 'react';
|
|
9
|
-
import type {useLocationHashReturns} from '@theme/hooks/useLocationHash';
|
|
10
|
-
|
|
11
|
-
function useLocationHash(initialHash: string): useLocationHashReturns {
|
|
12
|
-
const [hash, setHash] = useState(initialHash);
|
|
13
|
-
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
const handleHashChange = () => setHash(window.location.hash);
|
|
16
|
-
|
|
17
|
-
window.addEventListener('hashchange', handleHashChange);
|
|
18
|
-
|
|
19
|
-
return () => window.removeEventListener('hashchange', handleHashChange);
|
|
20
|
-
}, []);
|
|
21
|
-
|
|
22
|
-
return [hash, setHash];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default useLocationHash;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import defaultTheme from 'prism-react-renderer/themes/palenight';
|
|
9
|
-
import useThemeContext from '@theme/hooks/useThemeContext';
|
|
10
|
-
import {useThemeConfig} from '@docusaurus/theme-common';
|
|
11
|
-
|
|
12
|
-
const usePrismTheme = (): typeof defaultTheme => {
|
|
13
|
-
const {prism} = useThemeConfig();
|
|
14
|
-
const {isDarkTheme} = useThemeContext();
|
|
15
|
-
const lightModeTheme = prism.theme || defaultTheme;
|
|
16
|
-
const darkModeTheme = prism.darkTheme || lightModeTheme;
|
|
17
|
-
const prismTheme = isDarkTheme ? darkModeTheme : lightModeTheme;
|
|
18
|
-
|
|
19
|
-
return prismTheme;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default usePrismTheme;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import {useEffect, useRef} from 'react';
|
|
9
|
-
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
|
|
10
|
-
import type {ScrollPosition} from '@theme/hooks/useScrollPosition';
|
|
11
|
-
|
|
12
|
-
const getScrollPosition = (): ScrollPosition => ({
|
|
13
|
-
scrollX: ExecutionEnvironment.canUseDOM ? window.pageXOffset : 0,
|
|
14
|
-
scrollY: ExecutionEnvironment.canUseDOM ? window.pageYOffset : 0,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
const useScrollPosition = (
|
|
18
|
-
effect?: (position: ScrollPosition, lastPosition: ScrollPosition) => void,
|
|
19
|
-
deps = [],
|
|
20
|
-
): void => {
|
|
21
|
-
const scrollPosition = useRef(getScrollPosition());
|
|
22
|
-
|
|
23
|
-
const handleScroll = () => {
|
|
24
|
-
const currentScrollPosition = getScrollPosition();
|
|
25
|
-
|
|
26
|
-
if (effect) {
|
|
27
|
-
effect(currentScrollPosition, scrollPosition.current);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
scrollPosition.current = currentScrollPosition;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
const opts: AddEventListenerOptions & EventListenerOptions = {
|
|
35
|
-
passive: true,
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
handleScroll();
|
|
39
|
-
window.addEventListener('scroll', handleScroll, opts);
|
|
40
|
-
|
|
41
|
-
return () => window.removeEventListener('scroll', handleScroll, opts);
|
|
42
|
-
}, deps);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export default useScrollPosition;
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import {useEffect, useState} from 'react';
|
|
9
|
-
|
|
10
|
-
function useTOCHighlight(
|
|
11
|
-
linkClassName: string,
|
|
12
|
-
linkActiveClassName: string,
|
|
13
|
-
topOffset: number,
|
|
14
|
-
): void {
|
|
15
|
-
const [lastActiveLink, setLastActiveLink] = useState<
|
|
16
|
-
HTMLAnchorElement | undefined
|
|
17
|
-
>(undefined);
|
|
18
|
-
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
function setActiveLink() {
|
|
21
|
-
function getActiveHeaderAnchor(): Element | null {
|
|
22
|
-
const headersAnchors: Element[] = Array.from(
|
|
23
|
-
document.getElementsByClassName('anchor'),
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
const firstAnchorUnderViewportTop = headersAnchors.find((anchor) => {
|
|
27
|
-
const {top} = anchor.getBoundingClientRect();
|
|
28
|
-
return top >= topOffset;
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
if (firstAnchorUnderViewportTop) {
|
|
32
|
-
// If first anchor in viewport is under a certain threshold, we consider it's not the active anchor.
|
|
33
|
-
// In such case, the active anchor is the previous one (if it exists), that may be above the viewport
|
|
34
|
-
if (
|
|
35
|
-
firstAnchorUnderViewportTop.getBoundingClientRect().top >= topOffset
|
|
36
|
-
) {
|
|
37
|
-
const previousAnchor =
|
|
38
|
-
headersAnchors[
|
|
39
|
-
headersAnchors.indexOf(firstAnchorUnderViewportTop) - 1
|
|
40
|
-
];
|
|
41
|
-
return previousAnchor ?? firstAnchorUnderViewportTop;
|
|
42
|
-
}
|
|
43
|
-
// If the anchor is at the top of the viewport, we consider it's the first anchor
|
|
44
|
-
else {
|
|
45
|
-
return firstAnchorUnderViewportTop;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
// no anchor under viewport top? (ie we are at the bottom of the page)
|
|
49
|
-
else {
|
|
50
|
-
// highlight the last anchor found
|
|
51
|
-
return headersAnchors[headersAnchors.length - 1];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const activeHeaderAnchor = getActiveHeaderAnchor();
|
|
56
|
-
|
|
57
|
-
if (activeHeaderAnchor) {
|
|
58
|
-
let index = 0;
|
|
59
|
-
let itemHighlighted = false;
|
|
60
|
-
|
|
61
|
-
// @ts-expect-error: Must be <a> tags.
|
|
62
|
-
const links: HTMLCollectionOf<HTMLAnchorElement> = document.getElementsByClassName(
|
|
63
|
-
linkClassName,
|
|
64
|
-
);
|
|
65
|
-
while (index < links.length && !itemHighlighted) {
|
|
66
|
-
const link = links[index];
|
|
67
|
-
const {href} = link;
|
|
68
|
-
const anchorValue = decodeURIComponent(
|
|
69
|
-
href.substring(href.indexOf('#') + 1),
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
if (activeHeaderAnchor.id === anchorValue) {
|
|
73
|
-
if (lastActiveLink) {
|
|
74
|
-
lastActiveLink.classList.remove(linkActiveClassName);
|
|
75
|
-
}
|
|
76
|
-
link.classList.add(linkActiveClassName);
|
|
77
|
-
setLastActiveLink(link);
|
|
78
|
-
itemHighlighted = true;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
index += 1;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
document.addEventListener('scroll', setActiveLink);
|
|
87
|
-
document.addEventListener('resize', setActiveLink);
|
|
88
|
-
|
|
89
|
-
setActiveLink();
|
|
90
|
-
|
|
91
|
-
return () => {
|
|
92
|
-
document.removeEventListener('scroll', setActiveLink);
|
|
93
|
-
document.removeEventListener('resize', setActiveLink);
|
|
94
|
-
};
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export default useTOCHighlight;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import {useState, useCallback, useEffect} from 'react';
|
|
9
|
-
import type {useTabGroupChoiceReturns} from '@theme/hooks/useTabGroupChoice';
|
|
10
|
-
import {createStorageSlot, listStorageKeys} from '@docusaurus/theme-common';
|
|
11
|
-
|
|
12
|
-
const TAB_CHOICE_PREFIX = 'docusaurus.tab.';
|
|
13
|
-
|
|
14
|
-
const useTabGroupChoice = (): useTabGroupChoiceReturns => {
|
|
15
|
-
const [tabGroupChoices, setChoices] = useState<{
|
|
16
|
-
readonly [groupId: string]: string;
|
|
17
|
-
}>({});
|
|
18
|
-
const setChoiceSyncWithLocalStorage = useCallback((groupId, newChoice) => {
|
|
19
|
-
createStorageSlot(`${TAB_CHOICE_PREFIX}${groupId}`).set(newChoice);
|
|
20
|
-
}, []);
|
|
21
|
-
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
try {
|
|
24
|
-
const localStorageChoices = {};
|
|
25
|
-
listStorageKeys().forEach((storageKey) => {
|
|
26
|
-
if (storageKey.startsWith(TAB_CHOICE_PREFIX)) {
|
|
27
|
-
const groupId = storageKey.substring(TAB_CHOICE_PREFIX.length);
|
|
28
|
-
localStorageChoices[groupId] = createStorageSlot(storageKey).get();
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
setChoices(localStorageChoices);
|
|
32
|
-
} catch (err) {
|
|
33
|
-
console.error(err);
|
|
34
|
-
}
|
|
35
|
-
}, []);
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
tabGroupChoices,
|
|
39
|
-
setTabGroupChoices: (groupId: string, newChoice: string) => {
|
|
40
|
-
setChoices((oldChoices) => ({...oldChoices, [groupId]: newChoice}));
|
|
41
|
-
setChoiceSyncWithLocalStorage(groupId, newChoice);
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export default useTabGroupChoice;
|