chooseLayout.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import CompactSelect from 'sentry/components/forms/compactSelect';
  4. import {t} from 'sentry/locale';
  5. import space from 'sentry/styles/space';
  6. import useReplayLayout, {LayoutKey} from 'sentry/utils/replays/hooks/useReplayLayout';
  7. const layoutToLabel: Record<LayoutKey, string> = {
  8. topbar: t('Player Top'),
  9. sidebar_left: t('Player Left'),
  10. sidebar_right: t('Player Right'),
  11. top: t('Top'),
  12. no_video: t('Data Only'),
  13. video_only: t('Video Only'),
  14. };
  15. type Props = {};
  16. function ChooseLayout({}: Props) {
  17. const {getLayout, setLayout} = useReplayLayout();
  18. const currentLabel = layoutToLabel[getLayout()];
  19. return (
  20. <CompactSelect
  21. triggerProps={{size: 'xs'}}
  22. triggerLabel={
  23. <Fragment>
  24. Page Layout: <Current>{currentLabel}</Current>
  25. </Fragment>
  26. }
  27. value={getLayout()}
  28. placement="bottom right"
  29. onChange={opt => setLayout(opt?.value)}
  30. options={Object.entries(layoutToLabel).map(([value, label]) => ({
  31. value,
  32. label,
  33. }))}
  34. />
  35. );
  36. }
  37. const Current = styled('span')`
  38. font-weight: normal;
  39. padding-left: ${space(0.5)};
  40. `;
  41. export default ChooseLayout;