import React from 'react'; import { useResizeDetector } from 'react-resize-detector'; import { ColorTokens } from '../../../foundation/Colors'; import { TypographyTokens } from '../../../foundation/Typography'; import { BorderLine, ComponentBox, TabPillsBox, TabsAndComponentBox, TabsBox, TabStyled, } from './Tabs.styled'; type TabProps = { Component?: React.FunctionComponent | null; disabled?: boolean; id: string; label: string; }; export type MobileTabsProps = { activeTabColorToken: ColorTokens; activeTabId?: TabProps['id'] | null; backgroundColorToken: ColorTokens; borderColorToken: ColorTokens; colorToken: ColorTokens; hoverTabColorToken?: ColorTokens; onTabChange: (id: TabProps['id']) => void; tabs: TabProps[]; typographyToken: TypographyTokens; }; export const MobileTabs: React.FunctionComponent = ({ backgroundColorToken, activeTabColorToken, borderColorToken, typographyToken, colorToken, tabs, activeTabId, onTabChange, hoverTabColorToken, }) => { const { height: tabBoxHeight = 0, ref } = useResizeDetector({ handleHeight: true, }); const activeTab = tabs.find((tab) => tab.id === activeTabId); return ( {tabs.map(({ id, label, disabled }) => ( onTabChange(id)} > {label} ))} {activeTab && activeTab.Component ? ( ) : null} ); };