styles.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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="sm"
  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. `;
  40. const StyledSectionHeading = styled(SectionHeading)`
  41. margin: 0;
  42. `;
  43. const SectionBody = styled('div')`
  44. font-size: ${p => p.theme.fontSizeExtraLarge};
  45. padding: ${space(0.5)} 0;
  46. max-height: 32px;
  47. `;
  48. const StyledFeatureBadge = styled(FeatureBadge)`
  49. margin: 0;
  50. `;
  51. export const SectionSubtext = styled('div')<{type?: 'error' | 'default'}>`
  52. color: ${p => (p.type === 'error' ? p.theme.error : p.theme.subText)};
  53. font-size: ${p => p.theme.fontSizeMedium};
  54. `;