styles.tsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import styled from '@emotion/styled';
  2. import {SectionHeading} from 'sentry/components/charts/styles';
  3. import FeatureBadge from 'sentry/components/featureBadge';
  4. import QuestionTooltip from 'sentry/components/questionTooltip';
  5. import {space} from 'sentry/styles/space';
  6. type MetaDataProps = {
  7. bodyText: React.ReactNode;
  8. headingText: string;
  9. subtext: React.ReactNode;
  10. tooltipText: string;
  11. badge?: 'alpha' | 'beta' | 'new';
  12. };
  13. export function MetaData({
  14. headingText,
  15. tooltipText,
  16. bodyText,
  17. subtext,
  18. badge,
  19. }: MetaDataProps) {
  20. return (
  21. <HeaderInfo>
  22. <StyledSectionHeading>
  23. {headingText}
  24. <QuestionTooltip
  25. position="top"
  26. size="xs"
  27. containerDisplayMode="block"
  28. title={tooltipText}
  29. />
  30. {badge && <StyledFeatureBadge type={badge} />}
  31. </StyledSectionHeading>
  32. <SectionBody>{bodyText}</SectionBody>
  33. <SectionSubtext>{subtext}</SectionSubtext>
  34. </HeaderInfo>
  35. );
  36. }
  37. const HeaderInfo = styled('div')`
  38. min-height: 78px;
  39. white-space: nowrap;
  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. `;