2import React, { ReactNode, useState, createContext, useContext } from 'react';
3import { AnimatePresence, motion } from 'motion/react';
4import { cn } from '@/lib/utils';
5import { useMediaQuery } from '@/hooks/use-media-query';
14interface TabsContextType {
16 setActiveTab: (id: string) => void;
20const TabsContext = createContext<TabsContextType | undefined>(undefined);
23 const context = useContext(TabsContext);
25 throw new Error('Tabs components must be used within a TabsProvider');
30export function TabsProvider({
39 const [activeTab, setActiveTab] = useState(defaultValue);
40 const isDesktop = useMediaQuery('(min-width: 768px)');
42 <TabsContext.Provider value={{ activeTab, setActiveTab, isDesktop }}>
43 <div className={cn('w-full h-full', className)}>{children}</div>
48export function TabList({
55 return <div className={cn('rounded-sm h-fit', className)}>{children}</div>;
58export function TabItem({
67 const { activeTab, setActiveTab } = useTabs();
71 className={`rounded-lg overflow-hidden mb-2 ${
73 ? 'active border-2 dark:border-[#656fe2] border-[#F2F2F2] dark:bg-[#E0ECFB] bg-[#F2F2F2]'
74 : 'bg-transparent border-2 dark:hover:border-[#656fe2]'
76 onClick={() => setActiveTab(value)}
83export function TabHeader({
90 const { activeTab } = useTabs();
93 className={`p-4 cursor-pointer transition-all font-semibold dark:text-white text-black dark:hover:bg-[#1e2a78] hover:bg-[#F2F2F2] dark:hover:text-white hover:text-black flex justify-between items-center ${
95 ? 'active dark:bg-[#1e2a78] bg-[#F2F2F2]'
96 : 'dark:bg-[#11112b] bg-white'
111 const { activeTab } = useTabs();
113 <AnimatePresence mode='sync'>
114 {activeTab === value && (
116 initial={{ height: 0, opacity: 0 }}
117 animate={{ height: 'auto', opacity: 1 }}
118 exit={{ height: 0, opacity: 0 }}
125 <p className={`dark:bg-white bg-[#F2F2F2] text-black p-3`}>
134export function TabImageContainer({
142 <div className={cn('', className)}>
143 <AnimatePresence mode='popLayout'>{children}</AnimatePresence>
148export function TabImage({
157 const { activeTab, isDesktop } = useTabs();
159 if (activeTab !== value || !isDesktop) return null;
162 <motion.div className='p-4 h-[400px] overflow-hidden'>
164 initial={{ opacity: 0, overflow: 'hidden' }}
165 animate={{ opacity: 1, overflow: 'hidden' }}
166 exit={{ opacity: 0, overflow: 'hidden' }}