import * as Tabs from '@radix-ui/react-tabs'; import classNames from 'classnames'; import type { ReactElement, ReactNode } from 'react'; import { Children, isValidElement, useState } from 'react'; interface GridTabsProps { children: ReactElement[]; } export const GridTabs = ({ children }: GridTabsProps) => { const [activeTab, setActiveTab] = useState(() => { return children[0].props.id; }); return ( setActiveTab(value)} > {Children.map(children, (child) => { if (!isValidElement(child)) return null; const isActive = child.props.id === activeTab; const triggerClass = classNames('py-4', 'px-12', 'capitalize', { 'text-black dark:text-vega-yellow': isActive, 'bg-white dark:bg-black': isActive, 'text-black dark:text-white': !isActive, 'bg-black-10 dark:bg-white-25': !isActive, }); return ( {child.props.name} ); })}
{Children.map(children, (child) => { if (!isValidElement(child)) return null; return ( {child.props.children} ); })}
); }; interface GridTabProps { children: ReactNode; id: string; name: string; } export const GridTab = ({ id, children }: GridTabProps) => { return
{children}
; };