insightChartModal.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import type React from 'react';
  2. import {Fragment} from 'react';
  3. import {css} from '@emotion/react';
  4. import styled from '@emotion/styled';
  5. import type {ModalRenderProps} from 'sentry/actionCreators/modal';
  6. import {space} from 'sentry/styles/space';
  7. import {ChartRenderingContext} from 'sentry/views/insights/common/components/chart';
  8. export type InsightChartModalOptions = {
  9. children: React.ReactNode;
  10. title: React.ReactNode;
  11. };
  12. type Props = ModalRenderProps & InsightChartModalOptions;
  13. export default function InsightChartModal({Header, title, children}: Props) {
  14. return (
  15. <Fragment>
  16. <Container>
  17. <Header closeButton>
  18. <h3>{title}</h3>
  19. </Header>
  20. <ChartRenderingContext.Provider value={{height: 300, isFullscreen: true}}>
  21. {children}
  22. </ChartRenderingContext.Provider>
  23. </Container>
  24. </Fragment>
  25. );
  26. }
  27. const Container = styled('div')<{height?: number | null}>`
  28. height: ${p => (p.height ? `${p.height}px` : 'auto')};
  29. position: relative;
  30. padding-bottom: ${space(3)};
  31. z-index: 1000;
  32. `;
  33. export const modalCss = css`
  34. width: 100%;
  35. max-width: 1200px;
  36. `;