An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
feat: add interactive blinking logo to welcome screen
Yoshiki Miurac1c164fff893
diff --git a/app/globals.css b/app/globals.cssindex ec3117be..0ab89a89 100644--- a/app/globals.css+++ b/app/globals.css@@ -233,6 +233,15 @@opacity: 1;}}+ @keyframes blink {+ 0%,+ 100% {+ ry: 18;+ }+ 50% {+ ry: 0;+ }+ }@keyframes lookAround {0%,100% {@@ -250,6 +259,10 @@}}+@utility animate-blink {+ animation: blink 0.2s ease-in-out;+}+/* Animation utilities for dropdown menu */@utility animate-in {animation-name: enter;diff --git a/components/chat-panel.tsx b/components/chat-panel.tsxindex e68ad007..c268a494 100644--- a/components/chat-panel.tsx+++ b/components/chat-panel.tsx@@ -14,7 +14,7 @@ import { cn } from '@/lib/utils'import { useArtifact } from './artifact/artifact-context'import { Button } from './ui/button'-import { IconLogo } from './ui/icons'+import { IconBlinkingLogo } from './ui/icons'import { ActionButtons } from './action-buttons'import { FileUploadButton } from './file-upload-button'import { ModelTypeSelector } from './model-type-selector'@@ -151,7 +151,7 @@ export function ChatPanel({>{messages.length === 0 && (<div className="mb-10 flex flex-col items-center gap-4">- <IconLogo className="size-12 text-muted-foreground" />+ <IconBlinkingLogo className="size-12" /><h1 className="text-2xl font-medium text-foreground">What would you like to know?</h1>diff --git a/components/ui/icons.tsx b/components/ui/icons.tsxindex a3c5d344..d7ed7d06 100644--- a/components/ui/icons.tsx+++ b/components/ui/icons.tsx@@ -1,5 +1,7 @@'use client'+import { useEffect, useRef } from 'react'+import { cn } from '@/lib/utils'function IconLogo({ className, ...props }: React.ComponentProps<'svg'>) {@@ -43,4 +45,127 @@ function IconLogoOutline({ className, ...props }: React.ComponentProps<'svg'>) {)}-export { IconLogo, IconLogoOutline }+function IconBlinkingLogo({+ className,+ ...props+}: React.ComponentProps<'svg'>) {+ const svgRef = useRef<SVGSVGElement>(null)++ useEffect(() => {+ const blinkElements = document.querySelectorAll('.blink')+ const initialPositions = Array.from(blinkElements).map(el => ({+ cx: parseFloat(el.getAttribute('cx') || '0'),+ cy: parseFloat(el.getAttribute('cy') || '0')+ }))++ const triggerBlink = () => {+ blinkElements.forEach(el => {+ el.classList.add('animate-blink')+ setTimeout(() => {+ el.classList.remove('animate-blink')+ }, 200)+ })+ }++ const randomInterval = () => Math.random() * 8000 + 2000++ let timeoutId: ReturnType<typeof setTimeout>+ const startBlinking = () => {+ triggerBlink()+ timeoutId = setTimeout(startBlinking, randomInterval())+ }++ startBlinking()++ const handleMove = (clientX: number, clientY: number) => {+ if (svgRef.current) {+ const rect = svgRef.current.getBoundingClientRect()+ const mouseX = clientX - rect.left - rect.width / 2 - 256+ const mouseY = clientY - rect.top - rect.height / 2++ const maxMove = 60++ blinkElements.forEach((el, index) => {+ const { cx, cy } = initialPositions[index]+ const targetDx = Math.min((mouseX - cx) * 0.1, maxMove)+ const targetDy = Math.min((mouseY - cy) * 0.1, maxMove)++ let velocityX = 0+ let velocityY = 0+ const damping = 0.05++ const animate = () => {+ const currentCx = parseFloat(el.getAttribute('cx') || '0')+ const currentCy = parseFloat(el.getAttribute('cy') || '0')++ const dx = (targetDx - (currentCx - cx)) * 0.1+ const dy = (targetDy - (currentCy - cy)) * 0.1++ velocityX = velocityX * damping + dx+ velocityY = velocityY * damping + dy++ el.setAttribute('cx', (currentCx + velocityX).toString())+ el.setAttribute('cy', (currentCy + velocityY).toString())++ if (Math.abs(velocityX) > 0.1 || Math.abs(velocityY) > 0.1) {+ requestAnimationFrame(animate)+ }+ }++ requestAnimationFrame(animate)+ })+ }+ }++ const handleMouseMove = (event: MouseEvent) => {+ handleMove(event.clientX, event.clientY)+ }++ const handleTouchMove = (event: TouchEvent) => {+ if (event.touches.length > 0) {+ handleMove(event.touches[0].clientX, event.touches[0].clientY)+ }+ }++ window.addEventListener('mousemove', handleMouseMove)+ window.addEventListener('touchmove', handleTouchMove)++ return () => {+ clearTimeout(timeoutId)+ window.removeEventListener('mousemove', handleMouseMove)+ window.removeEventListener('touchmove', handleTouchMove)+ }+ }, [])++ return (+ <svg+ ref={svgRef}+ fill="currentColor"+ viewBox="0 0 256 256"+ role="img"+ xmlns="http://www.w3.org/2000/svg"+ className={cn('h-4 w-4', className)}+ {...props}+ >+ <circle cx="128" cy="128" r="128" fill="#222"></circle>+ <ellipse+ cx="102"+ cy="128"+ rx="18"+ ry="18"+ fill="white"+ className="blink"+ ></ellipse>+ <ellipse+ cx="154"+ cy="128"+ rx="18"+ ry="18"+ fill="white"+ className="blink"+ ></ellipse>+ </svg>+ )+}++export { IconBlinkingLogo, IconLogo, IconLogoOutline }