styles.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import * as React from 'react';
  2. import styled from '@emotion/styled';
  3. import {SectionHeading} from 'sentry/components/charts/styles';
  4. import FeatureBadge from 'sentry/components/featureBadge';
  5. import QuestionTooltip from 'sentry/components/questionTooltip';
  6. import space from 'sentry/styles/space';
  7. type MetaDataProps = {
  8. bodyText: React.ReactNode;
  9. headingText: string;
  10. subtext: React.ReactNode;
  11. tooltipText: string;
  12. badge?: 'alpha' | 'beta' | 'new';
  13. };
  14. export function MetaData({
  15. headingText,
  16. tooltipText,
  17. bodyText,
  18. subtext,
  19. badge,
  20. }: MetaDataProps) {
  21. return (
  22. <HeaderInfo>
  23. <StyledSectionHeading>
  24. {headingText}
  25. <QuestionTooltip
  26. position="top"
  27. size="sm"
  28. containerDisplayMode="block"
  29. title={tooltipText}
  30. />
  31. {badge && <StyledFeatureBadge type={badge} />}
  32. </StyledSectionHeading>
  33. <SectionBody>{bodyText}</SectionBody>
  34. <SectionSubtext>{subtext}</SectionSubtext>
  35. </HeaderInfo>
  36. );
  37. }
  38. const HeaderInfo = styled('div')`
  39. height: 78px;
  40. `;
  41. const StyledSectionHeading = styled(SectionHeading)`
  42. margin: 0;
  43. `;
  44. const SectionBody = styled('div')`
  45. font-size: ${p => p.theme.fontSizeExtraLarge};
  46. padding: ${space(0.5)} 0;
  47. max-height: 32px;
  48. `;
  49. const StyledFeatureBadge = styled(FeatureBadge)`
  50. margin: 0;
  51. `;
  52. export const SectionSubtext = styled('div')<{type?: 'error' | 'default'}>`
  53. color: ${p => (p.type === 'error' ? p.theme.error : p.theme.subText)};
  54. font-size: ${p => p.theme.fontSizeMedium};
  55. `;