utils.tsx 740 B

123456789101112131415161718192021222324252627
  1. import type {Theme} from '@emotion/react';
  2. import {
  3. SIDEBAR_COLLAPSED_WIDTH,
  4. SIDEBAR_EXPANDED_WIDTH,
  5. } from 'sentry/components/sidebar/constants';
  6. import {LayoutKey} from 'sentry/utils/replays/hooks/useReplayLayout';
  7. export const getDefaultLayout = (collapsed: boolean, theme: Theme): LayoutKey => {
  8. const {innerWidth, innerHeight} = window;
  9. const sidebarWidth = parseInt(
  10. collapsed ? SIDEBAR_COLLAPSED_WIDTH : SIDEBAR_EXPANDED_WIDTH,
  11. 10
  12. );
  13. const mediumScreenWidth = parseInt(theme.breakpoints.medium, 10);
  14. const windowsWidth =
  15. innerWidth <= mediumScreenWidth ? innerWidth : innerWidth - sidebarWidth;
  16. if (windowsWidth < innerHeight) {
  17. return LayoutKey.TOPBAR;
  18. }
  19. return LayoutKey.SIDEBAR_LEFT;
  20. };