diff --git a/src/components/DocsLayout.tsx b/src/components/DocsLayout.tsx index c37c3aee0..95e9ea2ea 100644 --- a/src/components/DocsLayout.tsx +++ b/src/components/DocsLayout.tsx @@ -73,6 +73,7 @@ function useCurrentFramework(frameworks: Framework[]) { const setFramework = React.useCallback( (framework: string) => { navigate({ + to: '.', params: (prev) => ({ ...prev, framework, @@ -142,6 +143,7 @@ function useCurrentVersion(versions: string[]) { const setVersion = React.useCallback( (version: string) => { navigate({ + to: '.', params: (prev: Record) => ({ ...prev, version, @@ -300,6 +302,84 @@ const useVersionConfig = ({ versions }: { versions: string[] }) => { return versionConfig } +const PrevNextButton = ({ + item, + direction, + colorFrom, + colorTo, + textColor, + libraryId, + currentFramework, + params, +}: { + item: { to: string; label: React.ReactNode } + direction: 'prev' | 'next' + colorFrom: string + colorTo: string + textColor: string + libraryId: string + currentFramework: string + params: Record +}) => { + const buttonContent = ( +
+ {direction === 'prev' ? ( + <> + + {item.label} + + ) : ( + <> + + {item.label} + {' '} + + + )} +
+ ) + + const buttonClassName = + 'py-1 px-2 bg-white/70 text-black dark:bg-gray-500/40 dark:text-white shadow-lg shadow-black/20 flex items-center justify-center backdrop-blur-sm z-20 rounded-lg overflow-hidden' + + if (item.to.startsWith('http')) { + return ( + + {buttonContent} + + ) + } + + return ( + + {buttonContent} + + ) +} + type DocsLayoutProps = { name: string version: string @@ -327,8 +407,9 @@ export function DocsLayout({ }: DocsLayoutProps) { const params = useParams({ strict: false }) const libraryId = params.libraryId || '' - const { _splat } = params + + const { framework: currentFramework } = useCurrentFramework(frameworks) const frameworkConfig = useFrameworkConfig({ frameworks }) const versionConfig = useVersionConfig({ versions }) const menuConfig = useMenuConfig({ config, frameworks, repo }) @@ -580,34 +661,30 @@ export function DocsLayout({
{prevItem ? ( - -
- - {prevItem.label} -
- + ) : null}
{nextItem ? ( - -
- - {nextItem.label} - {' '} - -
- + ) : null}