Streamline <PathLoaderButton />
This commit is contained in:
parent
25b7629a60
commit
0cfb9442c4
@ -1,39 +1,24 @@
|
||||
'use client';
|
||||
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { ReactNode, useEffect, useState, useTransition } from 'react';
|
||||
import { SpinnerColor } from '../Spinner';
|
||||
import { ComponentProps, useEffect, useState, useTransition } from 'react';
|
||||
import LoaderButton from '@/components/primitives/LoaderButton';
|
||||
|
||||
export default function PathLoaderButton({
|
||||
path,
|
||||
icon,
|
||||
title,
|
||||
prefetch,
|
||||
loaderDelay = 100,
|
||||
shouldScroll = true,
|
||||
shouldReplace,
|
||||
spinnerColor,
|
||||
shouldPreventDefault,
|
||||
styleAs,
|
||||
hideTextOnMobile,
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: {
|
||||
path: string
|
||||
icon?: ReactNode
|
||||
title?: string
|
||||
prefetch?: boolean
|
||||
loaderDelay?: number
|
||||
shouldScroll?: boolean
|
||||
shouldReplace?: boolean
|
||||
spinnerColor?: SpinnerColor
|
||||
shouldPreventDefault?: boolean
|
||||
styleAs?: 'button' | 'link' | 'link-without-hover'
|
||||
hideTextOnMobile?: boolean
|
||||
className?: string
|
||||
children?: ReactNode
|
||||
}) {
|
||||
} & ComponentProps<typeof LoaderButton>) {
|
||||
const router = useRouter();
|
||||
|
||||
const [isPending, startTransition] = useTransition();
|
||||
@ -59,9 +44,7 @@ export default function PathLoaderButton({
|
||||
|
||||
return (
|
||||
<LoaderButton
|
||||
icon={icon}
|
||||
title={title}
|
||||
className={className}
|
||||
{...props}
|
||||
onClick={() => {
|
||||
startTransition(() => {
|
||||
if (shouldReplace) {
|
||||
@ -71,11 +54,7 @@ export default function PathLoaderButton({
|
||||
}
|
||||
});
|
||||
}}
|
||||
shouldPreventDefault={shouldPreventDefault}
|
||||
isLoading={shouldShowLoader}
|
||||
spinnerColor={spinnerColor}
|
||||
styleAs={styleAs}
|
||||
hideTextOnMobile={hideTextOnMobile}
|
||||
>
|
||||
{children}
|
||||
</LoaderButton>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user