sidebarSection.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import space from 'sentry/styles/space';
  4. const Heading = styled('h5')`
  5. display: flex;
  6. align-items: center;
  7. margin-bottom: ${space(2)};
  8. font-size: ${p => p.theme.fontSizeMedium};
  9. line-height: 1;
  10. &:after {
  11. flex: 1;
  12. display: block;
  13. content: '';
  14. border-top: 1px solid ${p => p.theme.innerBorder};
  15. margin-left: ${space(1)};
  16. }
  17. `;
  18. const Subheading = styled('h6')`
  19. color: ${p => p.theme.gray300};
  20. display: flex;
  21. align-items: center;
  22. font-size: ${p => p.theme.fontSizeExtraSmall};
  23. text-transform: uppercase;
  24. margin-bottom: ${space(1)};
  25. line-height: 1;
  26. `;
  27. interface SidebarSectionProps
  28. extends Omit<React.HTMLAttributes<HTMLHeadingElement>, 'title'> {
  29. children: React.ReactNode;
  30. title: React.ReactNode;
  31. secondary?: boolean;
  32. }
  33. /**
  34. * Used to add a new section in Issue Details' sidebar.
  35. */
  36. function SidebarSection({title, children, secondary, ...props}: SidebarSectionProps) {
  37. const HeaderComponent = secondary ? Subheading : Heading;
  38. return (
  39. <Fragment>
  40. <HeaderComponent {...props}>{title}</HeaderComponent>
  41. <SectionContent>{children}</SectionContent>
  42. </Fragment>
  43. );
  44. }
  45. const SectionContent = styled('div')`
  46. margin-bottom: ${space(4)};
  47. line-height: 1;
  48. `;
  49. export default SidebarSection;