import type { LayoutValue } from '@tamagui/use-element-layout' import React, { useEffect, useState } from 'react' import type { XStackProps } from 'tamagui' import { Circle, XStack } from 'tamagui' import { useTint } from './useTint' // T A M A G U I // default: white white white white red green blue // hover: yellow yellow yellow color-12 red green blue const defaultColors = [ 'var(--color-12)', 'var(--color-12)', 'var(--color-12)', 'var(--color-12)', 'var(--red-9)', 'var(--green-9)', 'var(--blue-9)', ] const hoveredColors = [ 'var(--yellow-9)', 'var(--yellow-9)', 'var(--yellow-9)', 'var(--color-12)', 'var(--red-9)', 'var(--green-9)', 'var(--blue-9)', ] export const LogoWords: React.MemoExoticComponent< ({ downscale, animated, ...props }: XStackProps & { downscale?: number animated?: boolean }) => import('react/jsx-runtime').JSX.Element > = React.memo(({ downscale = 1, animated, ...props }) => { const Tint = useTint() const [hovered, setHovered] = React.useState(false) const [mounted, setMounted] = React.useState<'start' | 'animate' | 'done'>('start') const { tintIndex: index } = Tint useEffect(() => { const idle = window.requestIdleCallback || setTimeout idle(() => { setTimeout(() => { setMounted('animate') }, 50) setTimeout(() => { setMounted('done') }, 1500) }) }, []) useEffect(() => { const handleKeyDown = (event: KeyboardEvent) => { const index = Number.parseInt(event.key, 10) - 1 // Convert key to index (0-based) if (!Number.isNaN(index) && index >= 0 && index < Tint.tints.length) { Tint.setTintIndex(index) } } window.addEventListener('keydown', handleKeyDown) return () => { window.removeEventListener('keydown', handleKeyDown) } }, [Tint]) const getColor = (i: number) => { if (hovered) return `var(--${Tint.tints[i]}-9)` return defaultColors[i] } const x = Math.round( index * 18.5 + (18 / 2) * (index / defaultColors.length) + 3 + (index === 6 ? -3 : 0) ) const [layout, setLayout] = useState() return ( setHovered(true)} onMouseLeave={() => setHovered(false)} paddingVertical="2" marginVertical="-2" position="relative" {...props} data-tauri-drag-region className="logo-words" onLayout={(e) => { setLayout(e.nativeEvent.layout as any) }} onMouseMove={(e: React.MouseEvent) => { if (!layout) return const x = e.clientX - layout.pageX // Total width divided into 7 sections (one for each letter) const sectionWidth = layout.width / 7 // Calculate which section we're in (0-6) const section = Math.min(6, Math.floor(x / sectionWidth)) Tint.setTintIndex(section) }} > {animated && ( )} Tint.setTintIndex(0)} /> Tint.setTintIndex(1)} /> Tint.setTintIndex(2)} /> Tint.setTintIndex(3)} /> Tint.setTintIndex(4)} /> Tint.setTintIndex(5)} /> Tint.setTintIndex(6)} /> ) })