Skip to content

Commit 35bebd8

Browse files
committed
reduce duplication
1 parent 8d815fc commit 35bebd8

1 file changed

Lines changed: 26 additions & 39 deletions

File tree

src/components/DocsLayout.tsx

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -321,29 +321,32 @@ const PrevNextButton = ({
321321
currentFramework: string
322322
params: Record<string, string>
323323
}) => {
324+
const buttonContent = (
325+
<div className="flex gap-2 items-center font-bold">
326+
{direction === 'prev' ? (
327+
<>
328+
<FaArrowLeft />
329+
{item.label}
330+
</>
331+
) : (
332+
<>
333+
<span
334+
className={`bg-gradient-to-r ${colorFrom} ${colorTo} bg-clip-text text-transparent`}
335+
>
336+
{item.label}
337+
</span>{' '}
338+
<FaArrowRight className={textColor} />
339+
</>
340+
)}
341+
</div>
342+
);
343+
344+
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";
345+
324346
if (item.to.startsWith('http')) {
325347
return (
326-
<a
327-
href={item.to}
328-
className="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"
329-
>
330-
<div className="flex gap-2 items-center font-bold">
331-
{direction === 'prev' ? (
332-
<>
333-
<FaArrowLeft />
334-
{item.label}
335-
</>
336-
) : (
337-
<>
338-
<span
339-
className={`bg-gradient-to-r ${colorFrom} ${colorTo} bg-clip-text text-transparent`}
340-
>
341-
{item.label}
342-
</span>{' '}
343-
<FaArrowRight className={textColor} />
344-
</>
345-
)}
346-
</div>
348+
<a href={item.to} className={buttonClassName}>
349+
{buttonContent}
347350
</a>
348351
)
349352
}
@@ -369,25 +372,9 @@ const PrevNextButton = ({
369372
_splat: item.to,
370373
}),
371374
}}
372-
className="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"
375+
className={buttonClassName}
373376
>
374-
<div className="flex gap-2 items-center font-bold">
375-
{direction === 'prev' ? (
376-
<>
377-
<FaArrowLeft />
378-
{item.label}
379-
</>
380-
) : (
381-
<>
382-
<span
383-
className={`bg-gradient-to-r ${colorFrom} ${colorTo} bg-clip-text text-transparent`}
384-
>
385-
{item.label}
386-
</span>{' '}
387-
<FaArrowRight className={textColor} />
388-
</>
389-
)}
390-
</div>
377+
{buttonContent}
391378
</Link>
392379
)
393380
}

0 commit comments

Comments
 (0)