59 lines
1.3 KiB
TypeScript
59 lines
1.3 KiB
TypeScript
'use client';
|
|||
|
|
|
||
|
|
import React from 'react';
|
||
|
|
import { cn } from '@/lib/utils';
|
||
|
|
|
||
|
|
// Fallback helper in case cn isn't in @/lib/utils
|
||
|
|
function classNames(...classes: (string | undefined | null | false)[]) {
|
||
|
|
return classes.filter(Boolean).join(' ');
|
||
|
|
}
|
||
|
|
|
||
|
|
interface MarqueeProps {
|
||
|
|
className?: string;
|
||
|
|
reverse?: boolean;
|
||
|
|
pauseOnHover?: boolean;
|
||
|
|
children?: React.ReactNode;
|
||
|
|
vertical?: boolean;
|
||
|
|
repeat?: number;
|
||
|
|
[key: string]: any;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function Marquee({
|
||
|
|
className,
|
||
|
|
reverse,
|
||
|
|
pauseOnHover = true,
|
||
|
|
children,
|
||
|
|
vertical = false,
|
||
|
|
repeat = 4,
|
||
|
|
...props
|
||
|
|
}: MarqueeProps) {
|
||
|
|
return (
|
||
|
|
<div
|
||
|
|
{...props}
|
||
|
|
className={classNames(
|
||
|
|
'group flex overflow-hidden p-2 [--duration:40s] [--gap:1.25rem] [gap:var(--gap)]',
|
||
|
|
vertical ? 'flex-col' : 'flex-row',
|
||
|
|
className
|
||
|
|
)}
|
||
|
|
>
|
||
|
|
{Array(repeat)
|
||
|
|
.fill(0)
|
||
|
|
.map((_, i) => (
|
||
|
|
<div
|
||
|
|
key={i}
|
||
|
|
className={classNames(
|
||
|
|
'flex shrink-0 justify-around [gap:var(--gap)]',
|
||
|
|
vertical
|
||
|
|
? 'animate-marquee-vertical flex-col'
|
||
|
|
: 'animate-marquee flex-row',
|
||
|
|
pauseOnHover && 'group-hover:[animation-play-state:paused]',
|
||
|
|
reverse && '[animation-direction:reverse]'
|
||
|
|
)}
|
||
|
|
>
|
||
|
|
{children}
|
||
|
|
</div>
|
||
|
|
))}
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
}
|