asideTabs.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import styled from '@emotion/styled';
  2. import NavTabs from 'sentry/components/navTabs';
  3. import Placeholder from 'sentry/components/placeholder';
  4. import {t} from 'sentry/locale';
  5. import useUrlParams from 'sentry/utils/replays/hooks/useUrlParams';
  6. import ReplayReader from 'sentry/utils/replays/replayReader';
  7. import Breadcrumbs from './breadcrumbs';
  8. import TagPanel from './tagPanel';
  9. const TABS = {
  10. breadcrumbs: t('Breadcrumbs'),
  11. tags: t('Tags'),
  12. };
  13. type Props = {
  14. replay: ReplayReader | null;
  15. };
  16. function renderTabContent(key: string, loadedReplay: ReplayReader) {
  17. if (key === 'tags') {
  18. return <TagPanel replay={loadedReplay} />;
  19. }
  20. return <Breadcrumbs />;
  21. }
  22. function AsideTabs({replay}: Props) {
  23. const {getParamValue, setParamValue} = useUrlParams('t_side', 'breadcrumbs');
  24. const active = getParamValue();
  25. return (
  26. <Container>
  27. <NavTabs underlined>
  28. {Object.entries(TABS).map(([tab, label]) => {
  29. return (
  30. <li key={tab} className={active === tab ? 'active' : ''}>
  31. <a onClick={() => setParamValue(tab)}>{label}</a>
  32. </li>
  33. );
  34. })}
  35. </NavTabs>
  36. {replay ? renderTabContent(active, replay) : <Placeholder height="100%" />}
  37. </Container>
  38. );
  39. }
  40. // FYI: Since the Replay Player has dynamic height based
  41. // on the width of the window,
  42. // height: 0; will helps us to reset the height
  43. // min-height: 100%; will helps us to grow at the same height of Player
  44. const Container = styled('div')`
  45. width: 100%;
  46. display: grid;
  47. grid-template-rows: auto 1fr;
  48. height: 0;
  49. min-height: 100%;
  50. @media only screen and (max-width: ${p => p.theme.breakpoints.large}) {
  51. height: fit-content;
  52. max-height: 400px;
  53. }
  54. `;
  55. export default AsideTabs;