styles.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. badge?: 'alpha' | 'beta' | 'new';
  11. tooltipText?: string;
  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. {tooltipText && (
  25. <QuestionTooltip
  26. position="top"
  27. size="xs"
  28. containerDisplayMode="block"
  29. title={tooltipText}
  30. />
  31. )}
  32. {badge && <StyledFeatureBadge type={badge} />}
  33. </StyledSectionHeading>
  34. <SectionBody>{bodyText}</SectionBody>
  35. <SectionSubtext>{subtext}</SectionSubtext>
  36. </HeaderInfo>
  37. );
  38. }
  39. const HeaderInfo = styled('div')`
  40. min-height: 78px;
  41. white-space: nowrap;
  42. `;
  43. const StyledSectionHeading = styled(SectionHeading)`
  44. margin: 0;
  45. `;
  46. const SectionBody = styled('div')`
  47. font-size: ${p => p.theme.fontSizeExtraLarge};
  48. padding: ${space(0.5)} 0;
  49. max-height: 32px;
  50. `;
  51. const StyledFeatureBadge = styled(FeatureBadge)`
  52. margin: 0;
  53. `;
  54. export const SectionSubtext = styled('div')<{type?: 'error' | 'default'}>`
  55. color: ${p => (p.type === 'error' ? p.theme.error : p.theme.subText)};
  56. font-size: ${p => p.theme.fontSizeMedium};
  57. `;