'use client'; import { forwardRef, HTMLAttributes, ReactNode, useState, useCallback } from 'react'; export interface CornerTab { id: string; label: string; content?: ReactNode; icon?: string; disabled?: boolean; } export interface CornerTabsProps extends HTMLAttributes { /** Tab items */ tabs: CornerTab[]; /** Corner position */ corner?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; /** Default active tab */ defaultActive?: string; /** Callback when tab changes */ onTabChange?: (tabId: string) => void; /** Show tab content panels */ showContent?: boolean; /** Animation style */ animation?: 'slide' | 'fade' | 'scale' | 'glitch'; /** Tab orientation */ orientation?: 'horizontal' | 'vertical'; /** Style variant */ variant?: 'minimal' | 'brutal' | 'neon' | 'ornate'; } export const CornerTabs = forwardRef( ( { tabs, corner = 'top-left', defaultActive, onTabChange, showContent = true, animation = 'slide', orientation = 'horizontal', variant = 'minimal', className, ...props }, ref ) => { const [activeTab, setActiveTab] = useState(defaultActive || tabs[0]?.id); const [isAnimating, setIsAnimating] = useState(false); const handleTabClick = useCallback( (tabId: string) => { if (tabId === activeTab) return; setIsAnimating(true); setActiveTab(tabId); onTabChange?.(tabId); setTimeout(() => setIsAnimating(false), 300); }, [activeTab, onTabChange] ); const activeTabData = tabs.find(tab => tab.id === activeTab); const cornerClasses = { 'top-left': 'top-0 left-0', 'top-right': 'top-0 right-0', 'bottom-left': 'bottom-0 left-0', 'bottom-right': 'bottom-0 right-0', }; const orientationClasses = { horizontal: 'flex-row', vertical: 'flex-col', }; const variantClasses = { minimal: 'text-gray-500 bg-black', brutal: 'bg-rose-500 text-white', neon: 'text-cyan-400', ornate: 'text-gray-400', }; const activeVariantClasses = { minimal: 'text-white', brutal: 'text-black bg-white', neon: '[text-shadow:0_0_10px_#00ffff]', ornate: 'text-white', }; const contentVariantClasses = { minimal: 'bg-black/95 backdrop-blur-md border border-white/10', brutal: 'bg-rose-500 border-3 border-black shadow-[4px_4px_0_#000]', neon: 'bg-[rgba(0,20,30,0.95)] border border-cyan-400/30 shadow-[0_0_30px_rgba(0,255,255,0.1)]', ornate: 'bg-gradient-to-br from-[rgba(20,20,20,0.95)] to-[rgba(40,40,40,0.95)] border border-white/10', }; const borderClasses = { 'top-left': 'border-b border-r border-white/10', 'top-right': 'border-b border-l border-white/10', 'bottom-left': 'border-t border-r border-white/10', 'bottom-right': 'border-t border-l border-white/10', }; const contentPositionClasses = { 'top-left': 'top-full left-0', 'top-right': 'top-full right-0', 'bottom-left': 'bottom-full left-0', 'bottom-right': 'bottom-full right-0', }; const indicatorClasses = { 'top-left': 'bottom-[-1px] left-0 right-0 h-[2px]', 'top-right': 'bottom-[-1px] left-0 right-0 h-[2px]', 'bottom-left': 'top-[-1px] left-0 right-0 h-[2px]', 'bottom-right': 'top-[-1px] left-0 right-0 h-[2px]', }; const isHorizontal = orientation === 'horizontal'; return ( ); } ); CornerTabs.displayName = 'CornerTabs'; export default CornerTabs;