-
Notifications
You must be signed in to change notification settings - Fork 314
fix(theme): vendor theme-common/internal usages ahead of Docusaurus v4 (#1140) #1502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8d5960a
9ad8bc0
6cf77fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,17 +7,17 @@ | |
|
|
||
| import React, { cloneElement, ReactElement, useEffect, useRef } from "react"; | ||
|
|
||
| import useIsBrowser from "@docusaurus/useIsBrowser"; | ||
| import clsx from "clsx"; | ||
|
|
||
| import { useScrollPositionBlocker } from "@theme/utils/scrollUtils"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still exported, I could consider making it public api |
||
| import { | ||
| sanitizeTabsChildren, | ||
| type TabItemProps, | ||
| type TabProps, | ||
| TabsProvider, | ||
| useScrollPositionBlocker, | ||
| useTabsContextValue, | ||
| } from "@docusaurus/theme-common/internal"; | ||
| import useIsBrowser from "@docusaurus/useIsBrowser"; | ||
| import clsx from "clsx"; | ||
|
|
||
| } from "@theme/utils/tabsUtils"; | ||
| import { Language } from "../CodeSnippets/code-snippets-types"; | ||
|
|
||
| export interface Props { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,21 +13,22 @@ import React, { | |
| ReactElement, | ||
| } from "react"; | ||
|
|
||
| import { | ||
| sanitizeTabsChildren, | ||
| type TabItemProps, | ||
| TabProps, | ||
| TabsProvider, | ||
| useScrollPositionBlocker, | ||
| useTabsContextValue, | ||
| } from "@docusaurus/theme-common/internal"; | ||
| import useIsBrowser from "@docusaurus/useIsBrowser"; | ||
| import { setAccept } from "@theme/ApiExplorer/Accept/slice"; | ||
| import { setContentType } from "@theme/ApiExplorer/ContentType/slice"; | ||
| import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks"; | ||
| import { RootState } from "@theme/ApiItem/store"; | ||
| import clsx from "clsx"; | ||
|
|
||
| import { useScrollPositionBlocker } from "@theme/utils/scrollUtils"; | ||
| import { | ||
| sanitizeTabsChildren, | ||
| type TabItemProps, | ||
| TabProps, | ||
| TabsProvider, | ||
| useTabsContextValue, | ||
| } from "@theme/utils/tabsUtils"; | ||
|
Comment on lines
+23
to
+30
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could become public api |
||
|
|
||
| export interface Props { | ||
| schemaType: any; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* ============================================================================ | ||
| * Portions Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * Portions Copyright (c) Palo Alto Networks | ||
| * | ||
| * Swizzled from @docusaurus/theme-classic/src/theme/TabItem/index.tsx (MIT). | ||
| * Re-points useTabs to our vendored tabsUtils so that <TabItem> reads the same | ||
| * context our swizzled <Tabs> and OpenAPI tab variants (ApiTabs, MimeTabs, | ||
| * SchemaTabs, etc.) provide. See: | ||
| * https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/issues/1140 | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| * ========================================================================== */ | ||
|
|
||
| import React, { type ReactNode } from "react"; | ||
|
|
||
| import clsx from "clsx"; | ||
|
|
||
| import { type TabItemProps, useTabs } from "@theme/utils/tabsUtils"; | ||
|
|
||
| type Props = TabItemProps; | ||
| import styles from "./styles.module.css"; | ||
|
|
||
| function TabItemPanel({ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the purpose of this file, it seems similar to our original component?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Functionally exact copies. The only change is re-routing |
||
| children, | ||
| className, | ||
| hidden, | ||
| }: { | ||
| children: ReactNode; | ||
| className?: string; | ||
| hidden?: boolean; | ||
| }) { | ||
| return ( | ||
| <div | ||
| role="tabpanel" | ||
| className={clsx(styles.tabItem, className)} | ||
| {...{ hidden }} | ||
| > | ||
| {children} | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default function TabItem({ | ||
| children, | ||
| className, | ||
| value, | ||
| }: Props): ReactNode { | ||
| const { selectedValue, lazy } = useTabs(); | ||
| const isSelected = value === selectedValue; | ||
|
|
||
| if (!isSelected && lazy) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <TabItemPanel className={className} hidden={!isSelected}> | ||
| {children} | ||
| </TabItemPanel> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| .tabItem > *:last-child { | ||
| margin-bottom: 0; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using our context-based API instead:
That could be marked as public