Skip to content

Commit

Permalink
t
Browse files Browse the repository at this point in the history
  • Loading branch information
usr-icon-foundation committed May 29, 2024
1 parent ef9c14c commit 091c52a
Show file tree
Hide file tree
Showing 8 changed files with 248 additions and 9 deletions.
49 changes: 49 additions & 0 deletions components/topbar.tsx
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",
},
];
118 changes: 118 additions & 0 deletions components/ui/infinite-moving-cards.tsx
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>
);
};
6 changes: 6 additions & 0 deletions lib/utils/cn.ts
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));
}
53 changes: 46 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@
"@mendable/search": "^0.0.183",
"@tailwindcss/typography": "^0.5.9",
"@vercel/analytics": "^1.0.1",
"clsx": "^2.1.1",
"cookies-next": "^2.1.2",
"feed": "^4.2.2",
"framer-motion": "^11.2.6",
"globby": "^11.0.1",
"next": "^13.0.6",
"nextra": "^2.13.2",
"nextra-theme-docs": "^2.13.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sharp": "^0.33.2"
"sharp": "^0.33.2",
"tailwind-merge": "^2.3.0"
},
"devDependencies": {
"@types/node": "18.11.10",
Expand Down
2 changes: 2 additions & 0 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import '../globals.css';
import { Analytics } from '@vercel/analytics/react';
import Layout from '../components/layout';
import { MendableChatBubble } from "@mendable/search";
import { Topbar } from '../components/topbar';

function MyApp({ Component, pageProps }) {
return (
<main lang="en" className="font-montserrat">
<Layout>
<Topbar />
<Component {...pageProps} />
<MendableChatBubble
anon_key='4a621d80-aa5b-43cc-8600-dd155943ba19' cmdShortcutKey='m' style={{ darkMode: true, accentColor: "#00B8CC" }} />
Expand Down
1 change: 1 addition & 0 deletions pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const Homepage = () => {
return (

<main className="font-montserrat text-dark dark:text-light max-w-7xl min-h-screen mx-auto px-0 sm:px-4">


<div className='h-screen-3/4 flex flex-col justify-start px-4 sm:px-0 sm:justify-center pt-28 sm:pt-0 items-start relative overflow-hidden'>
<h1 className='text-5xl mb-4 sm:text-[5rem] font-exo bg-gradient-to-r from-[#404853] to-[#93A0AF] text-transparent bg-clip-text relative z-10'>Full Cross-Chain <br></br> Framework</h1>
Expand Down
23 changes: 22 additions & 1 deletion tailwind.config.js → tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import defaultTheme from "tailwindcss/defaultTheme";

import colors from "tailwindcss/colors";
import { default as flattenColorPalette } from "tailwindcss/lib/util/flattenColorPalette";

/** @type {import('tailwindcss').Config} */
module.exports = {
darkMode: 'class',
Expand Down Expand Up @@ -48,14 +53,30 @@ module.exports = {
'0%': { opacity: '1' },
'100%': { opacity: '0' },
},
scroll: {
to: {
transform: "translate(calc(-50% - 0.5rem))",
},
},
},
animation: {
fadeIn: 'fadeIn 0.3s ease-in-out forwards',
fadeOut: 'fadeOut 0.3s ease-in-out forwards',
scroll: "scroll var(--animation-duration, 40s) var(--animation-direction, forwards) linear infinite",
},
},
},
plugins: [],
plugins: [addVariablesForColors],
mode: 'jit',
}

function addVariablesForColors({ addBase, theme }: any) {
let allColors = flattenColorPalette(theme("colors"));
let newVars = Object.fromEntries(
Object.entries(allColors).map(([key, val]) => [`--${key}`, val])
);

addBase({
":root": newVars,
});
}

0 comments on commit 091c52a

Please sign in to comment.