@docusaurus/theme-classic 2.0.0-beta.15a2b59f9 → 2.0.0-beta.17
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 +35 -0
- package/{lib-next/theme/Toggle/styles.module.css → lib/deps.d.ts} +5 -9
- package/lib/getSwizzleConfig.js +125 -0
- package/lib/index.js +36 -41
- package/lib/prism-include-languages.js +9 -5
- package/lib/theme-classic.d.ts +771 -0
- package/lib/translations.js +40 -34
- package/lib/types.d.ts +0 -587
- package/lib/validateThemeConfig.js +242 -250
- package/lib-next/theme/Admonition/index.js +101 -0
- package/lib-next/theme/AnnouncementBar/index.js +8 -16
- package/lib-next/theme/AnnouncementBar/styles.module.css +23 -32
- package/lib-next/theme/BackToTopButton/index.js +131 -0
- package/lib-next/theme/BackToTopButton/styles.module.css +44 -0
- package/lib-next/theme/BlogArchivePage/index.js +80 -0
- package/lib-next/theme/BlogLayout/index.js +37 -0
- package/lib-next/theme/BlogListPage/index.js +18 -29
- package/lib-next/theme/BlogListPaginator/index.js +13 -16
- package/lib-next/theme/BlogPostAuthor/index.js +52 -0
- package/{lib/theme/IconEdit → lib-next/theme/BlogPostAuthor}/styles.module.css +4 -3
- package/lib-next/theme/BlogPostAuthors/index.js +44 -0
- package/{src/theme/Toggle → lib-next/theme/BlogPostAuthors}/styles.module.css +11 -7
- package/lib-next/theme/BlogPostItem/index.js +94 -96
- package/lib-next/theme/BlogPostPage/index.js +75 -39
- package/lib-next/theme/BlogPostPaginator/index.js +12 -19
- package/lib-next/theme/BlogSidebar/index.js +11 -13
- package/lib-next/theme/BlogSidebar/styles.module.css +4 -2
- package/lib-next/theme/BlogTagsListPage/index.js +15 -59
- package/lib-next/theme/BlogTagsPostsPage/index.js +33 -41
- package/lib-next/theme/CodeBlock/index.js +64 -154
- package/lib-next/theme/CodeBlock/styles.module.css +17 -9
- package/lib-next/theme/ColorModeToggle/index.js +83 -0
- package/lib-next/theme/ColorModeToggle/styles.module.css +51 -0
- package/lib-next/theme/Details/index.js +21 -0
- package/lib-next/theme/Details/styles.module.css +13 -0
- package/lib-next/theme/DocBreadcrumbs/index.js +76 -0
- package/lib-next/theme/DocBreadcrumbs/styles.module.css +26 -0
- package/lib-next/theme/DocCard/index.js +91 -0
- package/lib-next/theme/DocCard/styles.module.css +43 -0
- package/lib-next/theme/DocCardList/index.js +19 -0
- package/lib-next/theme/DocCategoryGeneratedIndexPage/index.js +54 -0
- package/lib-next/theme/DocCategoryGeneratedIndexPage/styles.module.css +18 -0
- package/lib-next/theme/DocItem/index.js +53 -58
- package/lib-next/theme/DocItem/styles.module.css +6 -10
- package/lib-next/theme/DocItemFooter/index.js +79 -0
- package/{lib/theme/DocItem → lib-next/theme/DocItemFooter}/styles.module.css +1 -9
- package/lib-next/theme/DocPage/index.js +54 -55
- package/lib-next/theme/DocPage/styles.module.css +9 -3
- package/lib-next/theme/DocPaginator/index.js +15 -24
- package/lib-next/theme/DocSidebar/index.js +65 -286
- package/lib-next/theme/DocSidebar/styles.module.css +5 -22
- package/lib-next/theme/DocSidebarItem/index.js +264 -0
- package/{lib/theme/BlogPostItem → lib-next/theme/DocSidebarItem}/styles.module.css +5 -10
- package/lib-next/theme/DocSidebarItems/index.js +28 -0
- package/lib-next/theme/DocTagDocListPage/index.js +89 -0
- package/lib-next/theme/DocTagsListPage/index.js +35 -0
- package/lib-next/theme/DocVersionBadge/index.js +34 -0
- package/lib-next/theme/DocVersionBanner/index.js +32 -15
- package/lib-next/theme/EditThisPage/index.js +6 -1
- package/lib-next/theme/ErrorPageContent.js +35 -0
- package/lib-next/theme/Footer/index.js +95 -40
- package/lib-next/theme/Footer/styles.module.css +2 -1
- package/lib-next/theme/Heading/index.js +39 -48
- package/lib-next/theme/Heading/styles.module.css +25 -5
- package/lib-next/theme/IconArrow/index.js +2 -5
- package/lib-next/theme/IconClose/index.js +23 -0
- package/lib-next/theme/IconDarkMode/index.js +17 -0
- package/lib-next/theme/IconEdit/index.js +2 -5
- package/lib-next/theme/IconExternalLink/index.js +2 -5
- package/lib-next/theme/IconLanguage/index.js +5 -8
- package/lib-next/theme/IconLightMode/index.js +17 -0
- package/lib-next/theme/IconMenu/index.js +7 -5
- package/lib-next/theme/LastUpdated/index.js +3 -2
- package/lib-next/theme/Layout/index.js +5 -7
- package/lib-next/theme/LayoutHead/index.js +27 -32
- package/lib-next/theme/LayoutProviders/index.js +15 -9
- package/lib-next/theme/Logo/index.js +25 -24
- package/lib-next/theme/MDXComponents/index.js +59 -30
- package/{src/theme/hooks → lib-next/theme/MDXComponents}/styles.css +7 -2
- package/lib-next/theme/MDXPage/index.js +10 -12
- package/lib-next/theme/Navbar/index.js +199 -64
- package/lib-next/theme/Navbar/styles.module.css +10 -3
- package/lib-next/theme/NavbarItem/DefaultNavbarItem.js +35 -201
- package/lib-next/theme/NavbarItem/DocNavbarItem.js +11 -8
- package/lib-next/theme/NavbarItem/DocSidebarNavbarItem.js +73 -0
- package/lib-next/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +34 -20
- package/lib-next/theme/NavbarItem/DocsVersionNavbarItem.js +4 -1
- package/lib-next/theme/NavbarItem/DropdownNavbarItem.js +156 -0
- package/lib-next/theme/NavbarItem/{LocaleDropdownNavbarItem.js → LocaleDropdownNavbarItem/index.js} +12 -13
- package/{lib/theme/hooks/styles.css → lib-next/theme/NavbarItem/LocaleDropdownNavbarItem/styles.module.css} +3 -2
- package/lib-next/theme/NavbarItem/NavbarNavLink.js +70 -0
- package/lib-next/theme/NavbarItem/index.js +26 -14
- package/lib-next/theme/{UserPreferencesContext.js → NavbarItem/utils.js} +3 -3
- package/lib-next/theme/NotFound.js +1 -4
- package/lib-next/theme/PaginatorNavLink/index.js +17 -0
- package/lib-next/theme/SearchBar.js +1 -1
- package/lib-next/theme/SearchMetadata/index.js +34 -0
- package/lib-next/theme/Seo/index.js +11 -7
- package/lib-next/theme/SkipToContent/index.js +3 -5
- package/lib-next/theme/SkipToContent/styles.module.css +7 -0
- package/lib-next/theme/TOC/index.js +12 -39
- package/lib-next/theme/TOC/styles.module.css +1 -1
- package/lib-next/theme/TOCCollapsible/index.js +54 -0
- package/lib-next/theme/TOCCollapsible/styles.module.css +50 -0
- package/lib-next/theme/TOCInline/index.js +10 -31
- package/lib-next/theme/TOCItems/index.js +85 -0
- package/lib-next/theme/TabItem/index.js +1 -4
- package/lib-next/theme/Tabs/__tests__/index.test.js +146 -0
- package/lib-next/theme/Tabs/index.js +108 -50
- package/lib-next/theme/Tabs/styles.module.css +0 -13
- package/lib-next/theme/Tag/index.js +24 -0
- package/lib-next/theme/Tag/styles.module.css +70 -0
- package/lib-next/theme/TagsListByLetter/index.js +40 -0
- package/lib-next/theme/{hooks/styles.css → TagsListByLetter/styles.module.css} +3 -2
- package/lib-next/theme/TagsListInline/index.js +31 -0
- package/lib-next/theme/TagsListInline/styles.module.css +15 -0
- package/lib-next/theme/ThemedImage/index.js +7 -10
- package/lib-next/theme/ThemedImage/styles.module.css +2 -2
- package/lib-next/theme/prism-include-languages.js +17 -15
- package/package.json +31 -31
- package/src/admonitions.css +35 -0
- package/src/deps.d.ts +13 -0
- package/src/getSwizzleConfig.ts +123 -0
- package/src/index.ts +39 -61
- 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 +143 -0
- package/src/theme/BackToTopButton/styles.module.css +44 -0
- package/src/theme/BlogArchivePage/index.tsx +91 -0
- package/src/theme/BlogLayout/index.tsx +42 -0
- package/src/theme/BlogListPage/index.tsx +19 -28
- package/src/theme/BlogListPaginator/index.tsx +13 -15
- package/src/theme/BlogPostAuthor/index.tsx +54 -0
- package/{lib/theme/MDXPage → src/theme/BlogPostAuthor}/styles.module.css +4 -2
- package/src/theme/BlogPostAuthors/index.tsx +49 -0
- package/src/theme/BlogPostAuthors/styles.module.css +21 -0
- package/src/theme/BlogPostItem/index.tsx +84 -90
- package/src/theme/BlogPostPage/index.tsx +77 -38
- package/src/theme/BlogPostPaginator/index.tsx +12 -18
- package/src/theme/BlogSidebar/index.tsx +11 -13
- package/src/theme/BlogSidebar/styles.module.css +4 -2
- package/src/theme/BlogTagsListPage/index.tsx +15 -60
- package/src/theme/BlogTagsPostsPage/index.tsx +32 -40
- package/src/theme/CodeBlock/index.tsx +68 -156
- package/src/theme/CodeBlock/styles.module.css +17 -9
- package/src/theme/ColorModeToggle/index.tsx +92 -0
- package/src/theme/ColorModeToggle/styles.module.css +51 -0
- package/src/theme/Details/index.tsx +25 -0
- package/src/theme/Details/styles.module.css +13 -0
- package/src/theme/DocBreadcrumbs/index.tsx +91 -0
- package/src/theme/DocBreadcrumbs/styles.module.css +26 -0
- package/src/theme/DocCard/index.tsx +109 -0
- package/src/theme/DocCard/styles.module.css +43 -0
- package/src/theme/DocCardList/index.tsx +27 -0
- package/src/theme/DocCategoryGeneratedIndexPage/index.tsx +59 -0
- package/src/theme/DocCategoryGeneratedIndexPage/styles.module.css +18 -0
- package/src/theme/DocItem/index.tsx +56 -58
- package/src/theme/DocItem/styles.module.css +6 -10
- package/src/theme/DocItemFooter/index.tsx +91 -0
- package/{lib/theme/Toggle → src/theme/DocItemFooter}/styles.module.css +9 -8
- package/src/theme/DocPage/index.tsx +53 -49
- package/src/theme/DocPage/styles.module.css +9 -3
- package/src/theme/DocPaginator/index.tsx +15 -23
- package/src/theme/DocSidebar/index.tsx +76 -298
- package/src/theme/DocSidebar/styles.module.css +5 -22
- package/src/theme/DocSidebarItem/index.tsx +283 -0
- package/src/theme/DocSidebarItem/styles.module.css +13 -0
- package/src/theme/DocSidebarItems/index.tsx +32 -0
- package/src/theme/DocTagDocListPage/index.tsx +89 -0
- package/src/theme/DocTagsListPage/index.tsx +39 -0
- package/src/theme/DocVersionBadge/index.tsx +35 -0
- package/src/theme/DocVersionBanner/index.tsx +49 -22
- package/src/theme/EditThisPage/index.tsx +6 -1
- package/src/theme/ErrorPageContent.tsx +41 -0
- package/src/theme/Footer/index.tsx +109 -44
- package/src/theme/Footer/styles.module.css +2 -1
- package/src/theme/Heading/index.tsx +38 -53
- 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 -4
- package/src/theme/IconExternalLink/index.tsx +3 -5
- 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 +3 -2
- package/src/theme/Layout/index.tsx +5 -6
- package/src/theme/LayoutHead/index.tsx +26 -25
- package/src/theme/LayoutProviders/index.tsx +15 -9
- package/src/theme/Logo/index.tsx +21 -19
- package/src/theme/MDXComponents/index.tsx +70 -32
- package/{lib/theme/IconExternalLink/styles.module.css → src/theme/MDXComponents/styles.css} +7 -4
- package/src/theme/MDXPage/index.tsx +10 -12
- package/src/theme/Navbar/index.tsx +208 -68
- package/src/theme/Navbar/styles.module.css +10 -3
- package/src/theme/NavbarItem/DefaultNavbarItem.tsx +37 -207
- package/src/theme/NavbarItem/DocNavbarItem.tsx +17 -18
- package/src/theme/NavbarItem/DocSidebarNavbarItem.tsx +84 -0
- package/src/theme/NavbarItem/DocsVersionDropdownNavbarItem.tsx +39 -24
- package/src/theme/NavbarItem/DocsVersionNavbarItem.tsx +7 -3
- package/src/theme/NavbarItem/DropdownNavbarItem.tsx +181 -0
- package/src/theme/NavbarItem/{LocaleDropdownNavbarItem.tsx → LocaleDropdownNavbarItem/index.tsx} +16 -10
- package/src/theme/NavbarItem/LocaleDropdownNavbarItem/styles.module.css +11 -0
- package/src/theme/NavbarItem/NavbarNavLink.tsx +68 -0
- package/src/theme/NavbarItem/index.tsx +41 -18
- package/src/theme/NavbarItem/utils.ts +10 -0
- package/src/theme/NotFound.tsx +1 -3
- package/src/theme/PaginatorNavLink/index.tsx +20 -0
- package/src/theme/SearchBar.tsx +2 -1
- package/src/theme/SearchMetadata/index.tsx +43 -0
- package/src/theme/Seo/index.tsx +7 -4
- package/src/theme/SkipToContent/index.tsx +3 -5
- package/src/theme/SkipToContent/styles.module.css +7 -0
- package/src/theme/TOC/index.tsx +13 -44
- package/src/theme/TOC/styles.module.css +1 -1
- package/src/theme/TOCCollapsible/index.tsx +58 -0
- package/src/theme/TOCCollapsible/styles.module.css +50 -0
- package/src/theme/TOCInline/index.tsx +14 -35
- package/src/theme/TOCItems/index.tsx +100 -0
- package/src/theme/TabItem/index.tsx +5 -3
- package/src/theme/Tabs/index.tsx +115 -56
- package/src/theme/Tabs/styles.module.css +0 -13
- package/src/theme/Tag/index.tsx +29 -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 +7 -9
- package/src/theme/ThemedImage/styles.module.css +2 -2
- package/src/theme/prism-include-languages.ts +20 -15
- package/src/theme-classic.d.ts +771 -0
- package/src/translations.ts +74 -54
- package/src/types.d.ts +0 -587
- package/src/validateThemeConfig.ts +381 -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/AnnouncementBar/index.js +0 -72
- package/lib/theme/AnnouncementBar/styles.module.css +0 -72
- package/lib/theme/BlogListPage/index.js +0 -71
- package/lib/theme/BlogListPaginator/index.js +0 -63
- package/lib/theme/BlogPostItem/index.js +0 -161
- package/lib/theme/BlogPostPage/index.js +0 -69
- package/lib/theme/BlogPostPaginator/index.js +0 -64
- package/lib/theme/BlogSidebar/index.js +0 -51
- package/lib/theme/BlogSidebar/styles.module.css +0 -44
- package/lib/theme/BlogTagsListPage/index.js +0 -76
- package/lib/theme/BlogTagsPostsPage/index.js +0 -100
- package/lib/theme/CodeBlock/index.js +0 -253
- package/lib/theme/CodeBlock/styles.module.css +0 -68
- package/lib/theme/DocItem/index.js +0 -129
- package/lib/theme/DocPage/index.js +0 -173
- package/lib/theme/DocPage/styles.module.css +0 -80
- package/lib/theme/DocPaginator/index.js +0 -63
- package/lib/theme/DocSidebar/index.js +0 -309
- package/lib/theme/DocSidebar/styles.module.css +0 -124
- package/lib/theme/DocVersionBanner/index.js +0 -128
- package/lib/theme/EditThisPage/index.js +0 -31
- package/lib/theme/Footer/index.js +0 -115
- package/lib/theme/Footer/styles.module.css +0 -15
- package/lib/theme/Heading/index.js +0 -76
- package/lib/theme/Heading/styles.css +0 -23
- package/lib/theme/Heading/styles.module.css +0 -15
- package/lib/theme/IconArrow/index.js +0 -28
- package/lib/theme/IconEdit/index.js +0 -34
- package/lib/theme/IconExternalLink/index.js +0 -30
- package/lib/theme/IconLanguage/index.js +0 -29
- package/lib/theme/IconMenu/index.js +0 -30
- package/lib/theme/LastUpdated/index.js +0 -61
- package/lib/theme/Layout/index.js +0 -64
- package/lib/theme/Layout/styles.css +0 -27
- package/lib/theme/LayoutHead/index.js +0 -144
- package/lib/theme/LayoutProviders/index.js +0 -36
- package/lib/theme/Logo/index.js +0 -60
- package/lib/theme/MDXComponents/index.js +0 -65
- package/lib/theme/MDXPage/index.js +0 -66
- package/lib/theme/Navbar/index.js +0 -147
- package/lib/theme/Navbar/styles.module.css +0 -20
- package/lib/theme/NavbarItem/DefaultNavbarItem.js +0 -209
- package/lib/theme/NavbarItem/DocNavbarItem.js +0 -63
- package/lib/theme/NavbarItem/DocsVersionDropdownNavbarItem.js +0 -76
- package/lib/theme/NavbarItem/DocsVersionNavbarItem.js +0 -43
- package/lib/theme/NavbarItem/LocaleDropdownNavbarItem.js +0 -72
- package/lib/theme/NavbarItem/SearchNavbarItem.js +0 -28
- package/lib/theme/NavbarItem/index.js +0 -54
- package/lib/theme/NotFound.js +0 -57
- package/lib/theme/SearchBar.js +0 -15
- package/lib/theme/SearchMetadatas/index.js +0 -33
- package/lib/theme/Seo/index.js +0 -49
- package/lib/theme/SkipToContent/index.js +0 -71
- package/lib/theme/SkipToContent/styles.module.css +0 -14
- package/lib/theme/TOC/index.js +0 -59
- package/lib/theme/TOC/styles.module.css +0 -23
- package/lib/theme/TOCInline/index.js +0 -53
- package/lib/theme/TOCInline/styles.module.css +0 -12
- package/lib/theme/TabItem/index.js +0 -32
- package/lib/theme/Tabs/index.js +0 -150
- package/lib/theme/Tabs/styles.module.css +0 -23
- package/lib/theme/ThemeContext.js +0 -21
- package/lib/theme/ThemeProvider/index.js +0 -38
- package/lib/theme/ThemedImage/index.js +0 -49
- package/lib/theme/ThemedImage/styles.module.css +0 -18
- 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/theme/prism-include-languages.js +0 -39
- 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/Heading/styles.css +0 -23
- package/lib-next/theme/SearchMetadatas/index.js +0 -20
- package/lib-next/theme/ThemeContext.js +0 -9
- package/lib-next/theme/ThemeProvider/index.js +0 -25
- package/lib-next/theme/Toggle/index.js +0 -80
- package/lib-next/theme/Toggle/styles.css +0 -103
- 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/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/Heading/styles.css +0 -23
- package/src/theme/SearchMetadatas/index.tsx +0 -28
- package/src/theme/ThemeContext.ts +0 -15
- 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/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/useLockBodyScroll.ts +0 -20
- 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/validateThemeConfig.js +0 -317
- package/tsconfig.json +0 -12
- package/update-code-translations.js +0 -240
- package/update-code-translations.test.js +0 -33
|
@@ -4,224 +4,58 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React
|
|
7
|
+
import React from 'react';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {useLocation} from '@docusaurus/router';
|
|
12
|
-
import {isSamePath} from '@docusaurus/theme-common';
|
|
13
|
-
import IconExternalLink from '@theme/IconExternalLink';
|
|
14
|
-
import isInternalUrl from '@docusaurus/isInternalUrl';
|
|
15
|
-
const dropdownLinkActiveClass = 'dropdown__link--active';
|
|
9
|
+
import NavbarNavLink from '@theme/NavbarItem/NavbarNavLink';
|
|
10
|
+
import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
|
|
16
11
|
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
to,
|
|
21
|
-
href,
|
|
22
|
-
label,
|
|
23
|
-
activeClassName = 'navbar__link--active',
|
|
24
|
-
prependBaseUrlToHref,
|
|
12
|
+
function DefaultNavbarItemDesktop({
|
|
13
|
+
className,
|
|
14
|
+
isDropdownItem = false,
|
|
25
15
|
...props
|
|
26
16
|
}) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
forcePrependBaseUrl: true,
|
|
33
|
-
});
|
|
34
|
-
const isExternalLink = label && href && !isInternalUrl(href);
|
|
35
|
-
const isDropdownLink = activeClassName === dropdownLinkActiveClass;
|
|
36
|
-
return (
|
|
37
|
-
<Link
|
|
38
|
-
{...(href
|
|
39
|
-
? {
|
|
40
|
-
href: prependBaseUrlToHref ? normalizedHref : href,
|
|
41
|
-
}
|
|
42
|
-
: {
|
|
43
|
-
isNavLink: true,
|
|
44
|
-
activeClassName,
|
|
45
|
-
to: toUrl,
|
|
46
|
-
...(activeBasePath || activeBaseRegex
|
|
47
|
-
? {
|
|
48
|
-
isActive: (_match, location) =>
|
|
49
|
-
activeBaseRegex
|
|
50
|
-
? new RegExp(activeBaseRegex).test(location.pathname)
|
|
51
|
-
: location.pathname.startsWith(activeBaseUrl),
|
|
52
|
-
}
|
|
53
|
-
: null),
|
|
54
|
-
})}
|
|
55
|
-
{...props}>
|
|
56
|
-
{isExternalLink ? (
|
|
57
|
-
<span>
|
|
58
|
-
{label}
|
|
59
|
-
<IconExternalLink
|
|
60
|
-
{...(isDropdownLink && {
|
|
61
|
-
width: 12,
|
|
62
|
-
height: 12,
|
|
63
|
-
})}
|
|
64
|
-
/>
|
|
65
|
-
</span>
|
|
66
|
-
) : (
|
|
67
|
-
label
|
|
17
|
+
const element = (
|
|
18
|
+
<NavbarNavLink
|
|
19
|
+
className={clsx(
|
|
20
|
+
isDropdownItem ? 'dropdown__link' : 'navbar__item navbar__link',
|
|
21
|
+
className,
|
|
68
22
|
)}
|
|
69
|
-
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
70
25
|
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function NavItemDesktop({items, position, className, ...props}) {
|
|
74
|
-
const dropdownRef = useRef(null);
|
|
75
|
-
const dropdownMenuRef = useRef(null);
|
|
76
|
-
const [showDropdown, setShowDropdown] = useState(false);
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
const handleClickOutside = (event) => {
|
|
79
|
-
if (!dropdownRef.current || dropdownRef.current.contains(event.target)) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
setShowDropdown(false);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
document.addEventListener('mousedown', handleClickOutside);
|
|
87
|
-
document.addEventListener('touchstart', handleClickOutside);
|
|
88
|
-
return () => {
|
|
89
|
-
document.removeEventListener('mousedown', handleClickOutside);
|
|
90
|
-
document.removeEventListener('touchstart', handleClickOutside);
|
|
91
|
-
};
|
|
92
|
-
}, [dropdownRef]);
|
|
93
26
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
{
|
|
97
|
-
'navbar__item navbar__link': !isDropdownItem,
|
|
98
|
-
dropdown__link: isDropdownItem,
|
|
99
|
-
},
|
|
100
|
-
extraClassName,
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
if (!items) {
|
|
104
|
-
return <NavLink className={navLinkClassNames(className)} {...props} />;
|
|
27
|
+
if (isDropdownItem) {
|
|
28
|
+
return <li>{element}</li>;
|
|
105
29
|
}
|
|
106
30
|
|
|
107
|
-
return
|
|
108
|
-
<div
|
|
109
|
-
ref={dropdownRef}
|
|
110
|
-
className={clsx('navbar__item', 'dropdown', 'dropdown--hoverable', {
|
|
111
|
-
'dropdown--left': position === 'left',
|
|
112
|
-
'dropdown--right': position === 'right',
|
|
113
|
-
'dropdown--show': showDropdown,
|
|
114
|
-
})}>
|
|
115
|
-
<NavLink
|
|
116
|
-
className={navLinkClassNames(className)}
|
|
117
|
-
{...props}
|
|
118
|
-
onClick={props.to ? undefined : (e) => e.preventDefault()}
|
|
119
|
-
onKeyDown={(e) => {
|
|
120
|
-
if (e.key === 'Enter') {
|
|
121
|
-
e.preventDefault();
|
|
122
|
-
setShowDropdown(!showDropdown);
|
|
123
|
-
}
|
|
124
|
-
}}>
|
|
125
|
-
{props.children ?? props.label}
|
|
126
|
-
</NavLink>
|
|
127
|
-
<ul ref={dropdownMenuRef} className="dropdown__menu">
|
|
128
|
-
{items.map(({className: childItemClassName, ...childItemProps}, i) => (
|
|
129
|
-
<li key={i}>
|
|
130
|
-
<NavLink
|
|
131
|
-
onKeyDown={(e) => {
|
|
132
|
-
if (i === items.length - 1 && e.key === 'Tab') {
|
|
133
|
-
e.preventDefault();
|
|
134
|
-
setShowDropdown(false);
|
|
135
|
-
const nextNavbarItem = dropdownRef.current.nextElementSibling;
|
|
136
|
-
|
|
137
|
-
if (nextNavbarItem) {
|
|
138
|
-
nextNavbarItem.focus();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}}
|
|
142
|
-
activeClassName={dropdownLinkActiveClass}
|
|
143
|
-
className={navLinkClassNames(childItemClassName, true)}
|
|
144
|
-
{...childItemProps}
|
|
145
|
-
/>
|
|
146
|
-
</li>
|
|
147
|
-
))}
|
|
148
|
-
</ul>
|
|
149
|
-
</div>
|
|
150
|
-
);
|
|
31
|
+
return element;
|
|
151
32
|
}
|
|
152
33
|
|
|
153
|
-
function
|
|
154
|
-
items,
|
|
34
|
+
function DefaultNavbarItemMobile({
|
|
155
35
|
className,
|
|
156
|
-
|
|
157
|
-
// Need to destructure position from props so that it doesn't get passed on.
|
|
36
|
+
isDropdownItem: _isDropdownItem,
|
|
158
37
|
...props
|
|
159
38
|
}) {
|
|
160
|
-
const menuListRef = useRef(null);
|
|
161
|
-
const {pathname} = useLocation();
|
|
162
|
-
const [collapsed, setCollapsed] = useState(
|
|
163
|
-
() => !items?.some((item) => isSamePath(item.to, pathname)) ?? true,
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
const navLinkClassNames = (extraClassName, isSubList = false) =>
|
|
167
|
-
clsx(
|
|
168
|
-
'menu__link',
|
|
169
|
-
{
|
|
170
|
-
'menu__link--sublist': isSubList,
|
|
171
|
-
},
|
|
172
|
-
extraClassName,
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
if (!items) {
|
|
176
|
-
return (
|
|
177
|
-
<li className="menu__list-item">
|
|
178
|
-
<NavLink className={navLinkClassNames(className)} {...props} />
|
|
179
|
-
</li>
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
const menuListHeight = menuListRef.current?.scrollHeight
|
|
184
|
-
? `${menuListRef.current?.scrollHeight}px`
|
|
185
|
-
: undefined;
|
|
186
39
|
return (
|
|
187
|
-
<li
|
|
188
|
-
className={clsx('
|
|
189
|
-
'menu__list-item--collapsed': collapsed,
|
|
190
|
-
})}>
|
|
191
|
-
<NavLink
|
|
192
|
-
role="button"
|
|
193
|
-
className={navLinkClassNames(className, true)}
|
|
194
|
-
{...props}
|
|
195
|
-
onClick={(e) => {
|
|
196
|
-
e.preventDefault();
|
|
197
|
-
setCollapsed((state) => !state);
|
|
198
|
-
}}>
|
|
199
|
-
{props.children ?? props.label}
|
|
200
|
-
</NavLink>
|
|
201
|
-
<ul
|
|
202
|
-
className="menu__list"
|
|
203
|
-
ref={menuListRef}
|
|
204
|
-
style={{
|
|
205
|
-
height: !collapsed ? menuListHeight : undefined,
|
|
206
|
-
}}>
|
|
207
|
-
{items.map(({className: childItemClassName, ...childItemProps}, i) => (
|
|
208
|
-
<li className="menu__list-item" key={i}>
|
|
209
|
-
<NavLink
|
|
210
|
-
activeClassName="menu__link--active"
|
|
211
|
-
className={navLinkClassNames(childItemClassName)}
|
|
212
|
-
{...childItemProps}
|
|
213
|
-
onClick={props.onClick}
|
|
214
|
-
/>
|
|
215
|
-
</li>
|
|
216
|
-
))}
|
|
217
|
-
</ul>
|
|
40
|
+
<li className="menu__list-item">
|
|
41
|
+
<NavbarNavLink className={clsx('menu__link', className)} {...props} />
|
|
218
42
|
</li>
|
|
219
43
|
);
|
|
220
44
|
}
|
|
221
45
|
|
|
222
|
-
function DefaultNavbarItem({
|
|
223
|
-
|
|
224
|
-
|
|
46
|
+
export default function DefaultNavbarItem({
|
|
47
|
+
mobile = false,
|
|
48
|
+
position: _position,
|
|
49
|
+
// Need to destructure position from props so that it doesn't get passed on.
|
|
50
|
+
...props
|
|
51
|
+
}) {
|
|
52
|
+
const Comp = mobile ? DefaultNavbarItemMobile : DefaultNavbarItemDesktop;
|
|
53
|
+
return (
|
|
54
|
+
<Comp
|
|
55
|
+
{...props}
|
|
56
|
+
activeClassName={
|
|
57
|
+
props.activeClassName ?? getInfimaActiveClassName(mobile)
|
|
58
|
+
}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
225
61
|
}
|
|
226
|
-
|
|
227
|
-
export default DefaultNavbarItem;
|
|
@@ -6,14 +6,16 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
useLatestVersion,
|
|
11
|
+
useActiveDocContext,
|
|
12
|
+
} from '@docusaurus/plugin-content-docs/client';
|
|
10
13
|
import clsx from 'clsx';
|
|
11
|
-
import {
|
|
12
|
-
import {uniq} from '@docusaurus/
|
|
14
|
+
import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
|
|
15
|
+
import {useDocsPreferredVersion, uniq} from '@docusaurus/theme-common';
|
|
13
16
|
|
|
14
17
|
function getDocInVersions(versions, docId) {
|
|
15
|
-
|
|
16
|
-
const allDocs = [].concat(...versions.map((version) => version.docs));
|
|
18
|
+
const allDocs = versions.flatMap((version) => version.docs);
|
|
17
19
|
const doc = allDocs.find((versionDoc) => versionDoc.id === docId);
|
|
18
20
|
|
|
19
21
|
if (!doc) {
|
|
@@ -29,7 +31,6 @@ Available doc ids are:\n- ${docIds}`);
|
|
|
29
31
|
|
|
30
32
|
export default function DocNavbarItem({
|
|
31
33
|
docId,
|
|
32
|
-
activeSidebarClassName,
|
|
33
34
|
label: staticLabel,
|
|
34
35
|
docsPluginId,
|
|
35
36
|
...props
|
|
@@ -42,14 +43,16 @@ export default function DocNavbarItem({
|
|
|
42
43
|
[activeVersion, preferredVersion, latestVersion].filter(Boolean),
|
|
43
44
|
);
|
|
44
45
|
const doc = getDocInVersions(versions, docId);
|
|
46
|
+
const activeDocInfimaClassName = getInfimaActiveClassName(props.mobile);
|
|
45
47
|
return (
|
|
46
48
|
<DefaultNavbarItem
|
|
47
49
|
exact
|
|
48
50
|
{...props}
|
|
49
51
|
className={clsx(props.className, {
|
|
50
|
-
[
|
|
51
|
-
activeDoc && activeDoc.sidebar === doc.sidebar,
|
|
52
|
+
[activeDocInfimaClassName]:
|
|
53
|
+
activeDoc?.sidebar && activeDoc.sidebar === doc.sidebar,
|
|
52
54
|
})}
|
|
55
|
+
activeClassName={activeDocInfimaClassName}
|
|
53
56
|
label={staticLabel ?? doc.id}
|
|
54
57
|
to={doc.path}
|
|
55
58
|
/>
|
|
@@ -0,0 +1,73 @@
|
|
|
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 React from 'react';
|
|
8
|
+
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
9
|
+
import {
|
|
10
|
+
useLatestVersion,
|
|
11
|
+
useActiveDocContext,
|
|
12
|
+
} from '@docusaurus/plugin-content-docs/client';
|
|
13
|
+
import clsx from 'clsx';
|
|
14
|
+
import {getInfimaActiveClassName} from '@theme/NavbarItem/utils';
|
|
15
|
+
import {useDocsPreferredVersion, uniq} from '@docusaurus/theme-common';
|
|
16
|
+
|
|
17
|
+
function getSidebarLink(versions, sidebarId) {
|
|
18
|
+
const allSidebars = versions
|
|
19
|
+
.flatMap((version) => {
|
|
20
|
+
if (version.sidebars) {
|
|
21
|
+
return Object.entries(version.sidebars);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return undefined;
|
|
25
|
+
})
|
|
26
|
+
.filter((sidebarItem) => !!sidebarItem);
|
|
27
|
+
const sidebarEntry = allSidebars.find((sidebar) => sidebar[0] === sidebarId);
|
|
28
|
+
|
|
29
|
+
if (!sidebarEntry) {
|
|
30
|
+
throw new Error(`DocSidebarNavbarItem: couldn't find any sidebar with id "${sidebarId}" in version${
|
|
31
|
+
versions.length ? 's' : ''
|
|
32
|
+
} ${versions.map((version) => version.name).join(', ')}".
|
|
33
|
+
Available sidebar ids are:
|
|
34
|
+
- ${Object.keys(allSidebars).join('\n- ')}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (!sidebarEntry[1].link) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
`DocSidebarNavbarItem: couldn't find any document for sidebar with id "${sidebarId}"`,
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return sidebarEntry[1].link;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default function DocSidebarNavbarItem({
|
|
47
|
+
sidebarId,
|
|
48
|
+
label,
|
|
49
|
+
docsPluginId,
|
|
50
|
+
...props
|
|
51
|
+
}) {
|
|
52
|
+
const {activeVersion, activeDoc} = useActiveDocContext(docsPluginId);
|
|
53
|
+
const {preferredVersion} = useDocsPreferredVersion(docsPluginId);
|
|
54
|
+
const latestVersion = useLatestVersion(docsPluginId); // Versions used to look for the doc to link to, ordered + no duplicate
|
|
55
|
+
|
|
56
|
+
const versions = uniq(
|
|
57
|
+
[activeVersion, preferredVersion, latestVersion].filter(Boolean),
|
|
58
|
+
);
|
|
59
|
+
const sidebarLink = getSidebarLink(versions, sidebarId);
|
|
60
|
+
const activeDocInfimaClassName = getInfimaActiveClassName(props.mobile);
|
|
61
|
+
return (
|
|
62
|
+
<DefaultNavbarItem
|
|
63
|
+
exact
|
|
64
|
+
{...props}
|
|
65
|
+
className={clsx(props.className, {
|
|
66
|
+
[activeDocInfimaClassName]: activeDoc?.sidebar === sidebarId,
|
|
67
|
+
})}
|
|
68
|
+
activeClassName={activeDocInfimaClassName}
|
|
69
|
+
label={label ?? sidebarLink.label}
|
|
70
|
+
to={sidebarLink.path}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -6,12 +6,14 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
9
|
+
import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
|
|
9
10
|
import {
|
|
10
11
|
useVersions,
|
|
11
12
|
useLatestVersion,
|
|
12
13
|
useActiveDocContext,
|
|
13
|
-
} from '@
|
|
14
|
+
} from '@docusaurus/plugin-content-docs/client';
|
|
14
15
|
import {useDocsPreferredVersion} from '@docusaurus/theme-common';
|
|
16
|
+
import {translate} from '@docusaurus/Translate';
|
|
15
17
|
|
|
16
18
|
const getVersionMainDoc = (version) =>
|
|
17
19
|
version.docs.find((doc) => doc.id === version.mainDocId);
|
|
@@ -27,9 +29,8 @@ export default function DocsVersionDropdownNavbarItem({
|
|
|
27
29
|
const activeDocContext = useActiveDocContext(docsPluginId);
|
|
28
30
|
const versions = useVersions(docsPluginId);
|
|
29
31
|
const latestVersion = useLatestVersion(docsPluginId);
|
|
30
|
-
const {preferredVersion, savePreferredVersionName} =
|
|
31
|
-
docsPluginId
|
|
32
|
-
);
|
|
32
|
+
const {preferredVersion, savePreferredVersionName} =
|
|
33
|
+
useDocsPreferredVersion(docsPluginId);
|
|
33
34
|
|
|
34
35
|
function getItems() {
|
|
35
36
|
const versionLinks = versions.map((version) => {
|
|
@@ -48,30 +49,43 @@ export default function DocsVersionDropdownNavbarItem({
|
|
|
48
49
|
},
|
|
49
50
|
};
|
|
50
51
|
});
|
|
51
|
-
|
|
52
|
-
...dropdownItemsBefore,
|
|
53
|
-
...versionLinks,
|
|
54
|
-
...dropdownItemsAfter,
|
|
55
|
-
]; // We don't want to render a version dropdown with 0 or 1 item
|
|
56
|
-
// If we build the site with a single docs version (onlyIncludeVersions: ['1.0.0'])
|
|
57
|
-
// We'd rather render a button instead of a dropdown
|
|
58
|
-
|
|
59
|
-
if (items.length <= 1) {
|
|
60
|
-
return undefined;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return items;
|
|
52
|
+
return [...dropdownItemsBefore, ...versionLinks, ...dropdownItemsAfter];
|
|
64
53
|
}
|
|
65
54
|
|
|
66
55
|
const items = getItems();
|
|
67
56
|
const dropdownVersion =
|
|
68
57
|
activeDocContext.activeVersion ?? preferredVersion ?? latestVersion; // Mobile dropdown is handled a bit differently
|
|
69
58
|
|
|
70
|
-
const dropdownLabel =
|
|
59
|
+
const dropdownLabel =
|
|
60
|
+
mobile && items.length > 1
|
|
61
|
+
? translate({
|
|
62
|
+
id: 'theme.navbar.mobileVersionsDropdown.label',
|
|
63
|
+
message: 'Versions',
|
|
64
|
+
description:
|
|
65
|
+
'The label for the navbar versions dropdown on mobile view',
|
|
66
|
+
})
|
|
67
|
+
: dropdownVersion.label;
|
|
71
68
|
const dropdownTo =
|
|
72
|
-
mobile && items
|
|
69
|
+
mobile && items.length > 1
|
|
70
|
+
? undefined
|
|
71
|
+
: getVersionMainDoc(dropdownVersion).path; // We don't want to render a version dropdown with 0 or 1 item. If we build
|
|
72
|
+
// the site with a single docs version (onlyIncludeVersions: ['1.0.0']),
|
|
73
|
+
// We'd rather render a button instead of a dropdown
|
|
74
|
+
|
|
75
|
+
if (items.length <= 1) {
|
|
76
|
+
return (
|
|
77
|
+
<DefaultNavbarItem
|
|
78
|
+
{...props}
|
|
79
|
+
mobile={mobile}
|
|
80
|
+
label={dropdownLabel}
|
|
81
|
+
to={dropdownTo}
|
|
82
|
+
isActive={dropdownActiveClassDisabled ? () => false : undefined}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
73
87
|
return (
|
|
74
|
-
<
|
|
88
|
+
<DropdownNavbarItem
|
|
75
89
|
{...props}
|
|
76
90
|
mobile={mobile}
|
|
77
91
|
label={dropdownLabel}
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import DefaultNavbarItem from '@theme/NavbarItem/DefaultNavbarItem';
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
useActiveVersion,
|
|
11
|
+
useLatestVersion,
|
|
12
|
+
} from '@docusaurus/plugin-content-docs/client';
|
|
10
13
|
import {useDocsPreferredVersion} from '@docusaurus/theme-common';
|
|
11
14
|
|
|
12
15
|
const getVersionMainDoc = (version) =>
|
|
@@ -0,0 +1,156 @@
|
|
|
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 React, {useState, useRef, useEffect} from 'react';
|
|
8
|
+
import clsx from 'clsx';
|
|
9
|
+
import {
|
|
10
|
+
isSamePath,
|
|
11
|
+
useCollapsible,
|
|
12
|
+
Collapsible,
|
|
13
|
+
isRegexpStringMatch,
|
|
14
|
+
useLocalPathname,
|
|
15
|
+
} from '@docusaurus/theme-common';
|
|
16
|
+
import NavbarNavLink from '@theme/NavbarItem/NavbarNavLink';
|
|
17
|
+
import NavbarItem from '@theme/NavbarItem';
|
|
18
|
+
const dropdownLinkActiveClass = 'dropdown__link--active';
|
|
19
|
+
|
|
20
|
+
function isItemActive(item, localPathname) {
|
|
21
|
+
if (isSamePath(item.to, localPathname)) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (isRegexpStringMatch(item.activeBaseRegex, localPathname)) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (item.activeBasePath && localPathname.startsWith(item.activeBasePath)) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function containsActiveItems(items, localPathname) {
|
|
37
|
+
return items.some((item) => isItemActive(item, localPathname));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function DropdownNavbarItemDesktop({items, position, className, ...props}) {
|
|
41
|
+
const dropdownRef = useRef(null);
|
|
42
|
+
const [showDropdown, setShowDropdown] = useState(false);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
const handleClickOutside = (event) => {
|
|
45
|
+
if (!dropdownRef.current || dropdownRef.current.contains(event.target)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
setShowDropdown(false);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
53
|
+
document.addEventListener('touchstart', handleClickOutside);
|
|
54
|
+
return () => {
|
|
55
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
56
|
+
document.removeEventListener('touchstart', handleClickOutside);
|
|
57
|
+
};
|
|
58
|
+
}, [dropdownRef]);
|
|
59
|
+
return (
|
|
60
|
+
<div
|
|
61
|
+
ref={dropdownRef}
|
|
62
|
+
className={clsx('navbar__item', 'dropdown', 'dropdown--hoverable', {
|
|
63
|
+
'dropdown--right': position === 'right',
|
|
64
|
+
'dropdown--show': showDropdown,
|
|
65
|
+
})}>
|
|
66
|
+
<NavbarNavLink
|
|
67
|
+
href={props.to ? undefined : '#'}
|
|
68
|
+
className={clsx('navbar__link', className)}
|
|
69
|
+
{...props}
|
|
70
|
+
onClick={props.to ? undefined : (e) => e.preventDefault()}
|
|
71
|
+
onKeyDown={(e) => {
|
|
72
|
+
if (e.key === 'Enter') {
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
setShowDropdown(!showDropdown);
|
|
75
|
+
}
|
|
76
|
+
}}>
|
|
77
|
+
{props.children ?? props.label}
|
|
78
|
+
</NavbarNavLink>
|
|
79
|
+
<ul className="dropdown__menu">
|
|
80
|
+
{items.map((childItemProps, i) => (
|
|
81
|
+
<NavbarItem
|
|
82
|
+
isDropdownItem
|
|
83
|
+
onKeyDown={(e) => {
|
|
84
|
+
if (i === items.length - 1 && e.key === 'Tab') {
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
setShowDropdown(false);
|
|
87
|
+
const nextNavbarItem = dropdownRef.current.nextElementSibling;
|
|
88
|
+
|
|
89
|
+
if (nextNavbarItem) {
|
|
90
|
+
nextNavbarItem.focus();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}}
|
|
94
|
+
activeClassName={dropdownLinkActiveClass}
|
|
95
|
+
{...childItemProps}
|
|
96
|
+
key={i}
|
|
97
|
+
/>
|
|
98
|
+
))}
|
|
99
|
+
</ul>
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function DropdownNavbarItemMobile({
|
|
105
|
+
items,
|
|
106
|
+
className,
|
|
107
|
+
position: _position,
|
|
108
|
+
// Need to destructure position from props so that it doesn't get passed on.
|
|
109
|
+
...props
|
|
110
|
+
}) {
|
|
111
|
+
const localPathname = useLocalPathname();
|
|
112
|
+
const containsActive = containsActiveItems(items, localPathname);
|
|
113
|
+
const {collapsed, toggleCollapsed, setCollapsed} = useCollapsible({
|
|
114
|
+
initialState: () => !containsActive,
|
|
115
|
+
}); // Expand/collapse if any item active after a navigation
|
|
116
|
+
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
if (containsActive) {
|
|
119
|
+
setCollapsed(!containsActive);
|
|
120
|
+
}
|
|
121
|
+
}, [localPathname, containsActive, setCollapsed]);
|
|
122
|
+
return (
|
|
123
|
+
<li
|
|
124
|
+
className={clsx('menu__list-item', {
|
|
125
|
+
'menu__list-item--collapsed': collapsed,
|
|
126
|
+
})}>
|
|
127
|
+
<NavbarNavLink
|
|
128
|
+
role="button"
|
|
129
|
+
className={clsx('menu__link menu__link--sublist', className)}
|
|
130
|
+
{...props}
|
|
131
|
+
onClick={(e) => {
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
toggleCollapsed();
|
|
134
|
+
}}>
|
|
135
|
+
{props.children ?? props.label}
|
|
136
|
+
</NavbarNavLink>
|
|
137
|
+
<Collapsible lazy as="ul" className="menu__list" collapsed={collapsed}>
|
|
138
|
+
{items.map((childItemProps, i) => (
|
|
139
|
+
<NavbarItem
|
|
140
|
+
mobile
|
|
141
|
+
isDropdownItem
|
|
142
|
+
onClick={props.onClick}
|
|
143
|
+
activeClassName="menu__link--active"
|
|
144
|
+
{...childItemProps}
|
|
145
|
+
key={i}
|
|
146
|
+
/>
|
|
147
|
+
))}
|
|
148
|
+
</Collapsible>
|
|
149
|
+
</li>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export default function DropdownNavbarItem({mobile = false, ...props}) {
|
|
154
|
+
const Comp = mobile ? DropdownNavbarItemMobile : DropdownNavbarItemDesktop;
|
|
155
|
+
return <Comp {...props} />;
|
|
156
|
+
}
|
package/lib-next/theme/NavbarItem/{LocaleDropdownNavbarItem.js → LocaleDropdownNavbarItem/index.js}
RENAMED
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import
|
|
8
|
+
import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
|
|
9
9
|
import IconLanguage from '@theme/IconLanguage';
|
|
10
10
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|
11
11
|
import {useAlternatePageUtils} from '@docusaurus/theme-common';
|
|
12
|
+
import {translate} from '@docusaurus/Translate';
|
|
13
|
+
import styles from './styles.module.css';
|
|
12
14
|
export default function LocaleDropdownNavbarItem({
|
|
13
15
|
mobile,
|
|
14
16
|
dropdownItemsBefore,
|
|
@@ -36,27 +38,24 @@ export default function LocaleDropdownNavbarItem({
|
|
|
36
38
|
target: '_self',
|
|
37
39
|
autoAddBaseUrl: false,
|
|
38
40
|
className: locale === currentLocale ? 'dropdown__link--active' : '',
|
|
39
|
-
style: {
|
|
40
|
-
textTransform: 'capitalize',
|
|
41
|
-
},
|
|
42
41
|
};
|
|
43
42
|
});
|
|
44
43
|
const items = [...dropdownItemsBefore, ...localeItems, ...dropdownItemsAfter]; // Mobile is handled a bit differently
|
|
45
44
|
|
|
46
|
-
const dropdownLabel = mobile
|
|
45
|
+
const dropdownLabel = mobile
|
|
46
|
+
? translate({
|
|
47
|
+
message: 'Languages',
|
|
48
|
+
id: 'theme.navbar.mobileLanguageDropdown.label',
|
|
49
|
+
description: 'The label for the mobile language switcher dropdown',
|
|
50
|
+
})
|
|
51
|
+
: getLocaleLabel(currentLocale);
|
|
47
52
|
return (
|
|
48
|
-
<
|
|
53
|
+
<DropdownNavbarItem
|
|
49
54
|
{...props}
|
|
50
|
-
href="#"
|
|
51
55
|
mobile={mobile}
|
|
52
56
|
label={
|
|
53
57
|
<span>
|
|
54
|
-
<IconLanguage
|
|
55
|
-
style={{
|
|
56
|
-
verticalAlign: 'text-bottom',
|
|
57
|
-
marginRight: 5,
|
|
58
|
-
}}
|
|
59
|
-
/>
|
|
58
|
+
<IconLanguage className={styles.iconLanguage} />
|
|
60
59
|
<span>{dropdownLabel}</span>
|
|
61
60
|
</span>
|
|
62
61
|
}
|