logo-cloud-04
eldoraui/logo-cloud-04FreeBlock
A logo cloud with motion.
Live preview
live · rendered by the registry
Rendered by eldoraui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://eldoraui.site/r/logo-cloud-04.jsonSource
1"use client"23import { useCallback, useEffect, useMemo, useRef, useState } from "react"45import { cn } from "@/lib/utils"67import { AnimatedLogoColumn, type Logo } from "./animated-logo-column"89const LOGOS: Logo[] = [10 {11 id: 1,12 name: "Google",13 src: "https://pub-b3533f2e1c954842824758490b95c9d5.r2.dev/Google.svg",14 },15 {16 id: 2,17 name: "GitHub",18 src: "https://pub-b3533f2e1c954842824758490b95c9d5.r2.dev/GitHub.svg",19 },20 {21 id: 3,22 name: "Amazon",23 src: "https://pub-b3533f2e1c954842824758490b95c9d5.r2.dev/Amazon.svg",24 },25 {26 id: 4,27 name: "Netflix",28 src: "https://pub-b3533f2e1c954842824758490b95c9d5.r2.dev/Netflix.svg",29 },30 {31 id: 5,32 name: "YouTube",33 src: "https://pub-b3533f2e1c954842824758490b95c9d5.r2.dev/YouTube.svg",34 },35 {36 id: 6,37 name: "Instagram",38 src: "https://pub-b3533f2e1c954842824758490b95c9d5.r2.dev/Instagram.svg",39 },40]4142const TICK_MS = 1004344/**45 * Deterministic distribution (no Math.random) so server and client46 * render the same columns and hydration matches.47 */48function distributeLogos(logos: Logo[], columnCount: number): Logo[][] {49 const result: Logo[][] = Array.from({ length: columnCount }, () => [])5051 logos.forEach((logo, index) => {52 result[index % columnCount].push(logo)53 })5455 const maxLength = Math.max(...result.map((col) => col.length))56 result.forEach((col, colIndex) => {57 while (col.length < maxLength) {58 col.push(logos[(col.length * columnCount + colIndex) % logos.length])59 }60 })6162 return result63}6465export type LogoCarouselVariant = "default" | "compact"6667interface LogoCarouselProps {68 columns?: number69 logos?: Logo[]70 variant?: LogoCarouselVariant71 className?: string72}7374export function LogoCarousel({75 columns = 4,76 logos: logosProp,77 variant = "default",78 className,79}: LogoCarouselProps) {80 const logos = useMemo(() => logosProp ?? LOGOS, [logosProp])81 const distribute = useCallback(82 (count: number) => distributeLogos(logos, count),83 [logos]84 )8586 const [logoColumns, setLogoColumns] = useState<Logo[][]>(() =>87 distributeLogos(logos, columns)88 )89 const [time, setTime] = useState(0)90 const prevColumnsRef = useRef(columns)9192 useEffect(() => {93 if (prevColumnsRef.current !== columns) {94 prevColumnsRef.current = columns95 setLogoColumns(distribute(columns))96 }97 }, [columns, distribute])9899 useEffect(() => {100 const interval = setInterval(() => {101 setTime((prev) => prev + TICK_MS)102// … truncated
What it pulls in
npm packages
Files it writes
More from eldoraui
All 115 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| cta-01cta-01 | eldoraui | Blocks | Free | 2 deps · 2 files | |
| cta-02cta-02 | eldoraui | Blocks | Free | 2 deps · 3 files | |
| cta-03cta-03 | eldoraui | Blocks | Free | 1 dep · 3 files | |
| features-01features-01 | eldoraui | Blocks | Free | 3 deps · 3 files | |
| footer-01footer-01 | eldoraui | Blocks | Free | 1 dep · 3 files | |
| header-01header-01 | eldoraui | Blocks | Free | 3 deps · 5 files | |
| header-02header-02 | eldoraui | Blocks | Free | 3 deps · 2 files | |
| logo-cloud-01logo-cloud-01 | eldoraui | Blocks | Free | 1 dep · 2 files |
