sidebarSection.tsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import * as React from 'react';
  2. import styled from '@emotion/styled';
  3. import space from 'app/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. &:after {
  10. flex: 1;
  11. display: block;
  12. content: '';
  13. border-top: 1px solid ${p => p.theme.innerBorder};
  14. margin-left: ${space(1)};
  15. }
  16. `;
  17. const Subheading = styled('h6')`
  18. color: ${p => p.theme.gray300};
  19. display: flex;
  20. font-size: ${p => p.theme.fontSizeExtraSmall};
  21. text-transform: uppercase;
  22. justify-content: space-between;
  23. margin-bottom: ${space(1)};
  24. `;
  25. type Props = {
  26. title: React.ReactNode;
  27. children: React.ReactNode;
  28. secondary?: boolean;
  29. } & Omit<React.ComponentProps<typeof Heading>, 'title'>;
  30. /**
  31. * Used to add a new section in Issue Details' sidebar.
  32. */
  33. function SidebarSection({title, children, secondary, ...props}: Props) {
  34. const HeaderComponent = secondary ? Subheading : Heading;
  35. return (
  36. <React.Fragment>
  37. <HeaderComponent {...props}>{title}</HeaderComponent>
  38. <SectionContent secondary={secondary}>{children}</SectionContent>
  39. </React.Fragment>
  40. );
  41. }
  42. const SectionContent = styled('div')<{secondary?: boolean}>`
  43. margin-bottom: ${p => (p.secondary ? space(2) : space(3))};
  44. `;
  45. export default SidebarSection;