focusTabs.tsx 910 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import {MouseEvent} from 'react';
  2. import styled from '@emotion/styled';
  3. import NavTabs from 'sentry/components/navTabs';
  4. import useActiveReplayTab, {
  5. ReplayTabs,
  6. } from 'sentry/utils/replays/hooks/useActiveReplayTab';
  7. type Props = {};
  8. function FocusTabs({}: Props) {
  9. const {getActiveTab, setActiveTab} = useActiveReplayTab();
  10. const activeTab = getActiveTab();
  11. return (
  12. <NavTabs underlined>
  13. {Object.entries(ReplayTabs).map(([tab, label]) => (
  14. <Tab key={tab} className={activeTab === tab ? 'active' : ''}>
  15. <a
  16. href={`#${tab}`}
  17. onClick={(e: MouseEvent) => {
  18. setActiveTab(tab);
  19. e.preventDefault();
  20. }}
  21. >
  22. <span>{label}</span>
  23. </a>
  24. </Tab>
  25. ))}
  26. </NavTabs>
  27. );
  28. }
  29. const Tab = styled('li')`
  30. z-index: ${p => p.theme.zIndex.initial + 1};
  31. `;
  32. export default FocusTabs;