-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef9c14c
commit 091c52a
Showing
8 changed files
with
248 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
"use client"; | ||
|
||
import React, { useEffect, useState } from "react"; | ||
import { InfiniteMovingCards } from "./ui/infinite-moving-cards"; | ||
|
||
export function Topbar() { | ||
return ( | ||
<div className="h-fit rounded-md flex flex-col antialiased bg-transparent w-full dark:bg-grid-white/[0.05] items-center justify-center relative overflow-hidden"> | ||
<InfiniteMovingCards | ||
items={testimonials} | ||
direction="right" | ||
speed="slow" | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
const testimonials = [ | ||
{ | ||
messages: 2110, | ||
chain: "ICON", | ||
role: "src", | ||
}, | ||
{ | ||
messages: 1926, | ||
chain: "ICON", | ||
role: "dest", | ||
}, | ||
{ | ||
messages: 1092, | ||
chain: "Archway", | ||
role: "src", | ||
}, | ||
{ | ||
messages: 1292, | ||
chain: "Archway", | ||
role: "dest", | ||
}, | ||
{ | ||
messages: 78, | ||
chain: "Injective", | ||
role: "src", | ||
}, | ||
{ | ||
messages: 54, | ||
chain: "Injective", | ||
role: "dest", | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
"use client"; | ||
|
||
import { cn } from "../../lib/utils/cn"; | ||
import React, { useEffect, useState } from "react"; | ||
import Image from "next/image"; | ||
import { it } from "node:test"; | ||
|
||
export const InfiniteMovingCards = ({ | ||
items, | ||
direction = "left", | ||
speed = "fast", | ||
pauseOnHover = true, | ||
className, | ||
}: { | ||
items: { | ||
messages: number; | ||
chain: string; | ||
role: string; | ||
}[]; | ||
direction?: "left" | "right"; | ||
speed?: "fast" | "normal" | "slow"; | ||
pauseOnHover?: boolean; | ||
className?: string; | ||
}) => { | ||
const containerRef = React.useRef<HTMLDivElement>(null); | ||
const scrollerRef = React.useRef<HTMLUListElement>(null); | ||
|
||
useEffect(() => { | ||
addAnimation(); | ||
}, []); | ||
const [start, setStart] = useState(false); | ||
function addAnimation() { | ||
if (containerRef.current && scrollerRef.current) { | ||
const scrollerContent = Array.from(scrollerRef.current.children); | ||
|
||
scrollerContent.forEach((item) => { | ||
const duplicatedItem = item.cloneNode(true); | ||
if (scrollerRef.current) { | ||
scrollerRef.current.appendChild(duplicatedItem); | ||
} | ||
}); | ||
|
||
getDirection(); | ||
getSpeed(); | ||
setStart(true); | ||
} | ||
} | ||
const getDirection = () => { | ||
if (containerRef.current) { | ||
if (direction === "left") { | ||
containerRef.current.style.setProperty( | ||
"--animation-direction", | ||
"forwards" | ||
); | ||
} else { | ||
containerRef.current.style.setProperty( | ||
"--animation-direction", | ||
"reverse" | ||
); | ||
} | ||
} | ||
}; | ||
const getSpeed = () => { | ||
if (containerRef.current) { | ||
if (speed === "fast") { | ||
containerRef.current.style.setProperty("--animation-duration", "20s"); | ||
} else if (speed === "normal") { | ||
containerRef.current.style.setProperty("--animation-duration", "40s"); | ||
} else { | ||
containerRef.current.style.setProperty("--animation-duration", "80s"); | ||
} | ||
} | ||
}; | ||
return ( | ||
<div | ||
ref={containerRef} | ||
className={cn( | ||
"scroller relative z-20 max-w-7xl overflow-hidden [mask-image:linear-gradient(to_right,transparent,white_20%,white_80%,transparent)]", | ||
className | ||
)} | ||
> | ||
<ul | ||
ref={scrollerRef} | ||
className={cn( | ||
" flex min-w-full shrink-0 gap-4 py-2 w-max flex-nowrap", | ||
start && "animate-scroll ", | ||
pauseOnHover && "hover:[animation-play-state:paused]" | ||
)} | ||
> | ||
{items.map((item, idx) => ( | ||
<li | ||
className="w-[350px] max-w-full relative rounded-full border border-b-0 flex-shrink-0 border-slate-700 px-8 py-2 md:w-fit bg-gradient-to-br from-[#111111] via-[#111111] to-black" | ||
key={idx} | ||
> | ||
<blockquote> | ||
<div | ||
aria-hidden="true" | ||
className="user-select-none -z-1 pointer-events-none absolute -left-0.5 -top-0.5 h-[calc(100%_+_4px)] w-[calc(100%_+_4px)]" | ||
></div> | ||
<div className=" relative z-20 text-sm leading-[1.6] text-gray-400 font-normal flex flex-row items-center"> | ||
<span className="mr-1 text-gray-100">{item.messages} messages </span> {item.role === "src" ? "have left" : "have arrived on"} | ||
<div className="flex flex-row items-center ml-2 space-x-2"> | ||
<Image className="w-4" src={`/chainlogos/${item.chain}.svg`} alt={item.chain} height={40} width={40}/> | ||
<span className=" text-sm leading-[1.6] text-gray-400 font-normal"> | ||
{item.chain} | ||
</span> | ||
</div> | ||
</div> | ||
|
||
|
||
|
||
</blockquote> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { ClassValue, clsx } from "clsx"; | ||
import { twMerge } from "tailwind-merge"; | ||
|
||
export function cn(...inputs: ClassValue[]) { | ||
return twMerge(clsx(inputs)); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters