releaseStats.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import React from 'react';
  2. import styled from '@emotion/styled';
  3. import AvatarList from 'app/components/avatar/avatarList';
  4. import {t, tn} from 'app/locale';
  5. import space from 'app/styles/space';
  6. import {Release} from 'app/types';
  7. type Props = {
  8. release: Release;
  9. withHeading: boolean;
  10. };
  11. const ReleaseStats = ({release, withHeading = true}: Props) => {
  12. const commitCount = release.commitCount || 0;
  13. const authorCount = (release.authors && release.authors.length) || 0;
  14. if (commitCount === 0) {
  15. return null;
  16. }
  17. const releaseSummary = [
  18. tn('%s commit', '%s commits', commitCount),
  19. t('by'),
  20. tn('%s author', '%s authors', authorCount),
  21. ].join(' ');
  22. return (
  23. <div className="release-stats">
  24. {withHeading && <ReleaseSummaryHeading>{releaseSummary}</ReleaseSummaryHeading>}
  25. <span style={{display: 'inline-block'}}>
  26. <AvatarList users={release.authors} avatarSize={25} typeMembers="authors" />
  27. </span>
  28. </div>
  29. );
  30. };
  31. const ReleaseSummaryHeading = styled('div')`
  32. color: ${p => p.theme.gray300};
  33. font-size: ${p => p.theme.fontSizeSmall};
  34. line-height: 1.2;
  35. font-weight: 600;
  36. text-transform: uppercase;
  37. margin-bottom: ${space(0.5)};
  38. `;
  39. export default ReleaseStats;