resourceCard.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import React from 'react';
  2. import styled from '@emotion/styled';
  3. import ExternalLink from 'app/components/links/externalLink';
  4. import {Panel} from 'app/components/panels';
  5. import space from 'app/styles/space';
  6. import {analytics} from 'app/utils/analytics';
  7. type Props = {
  8. title: string;
  9. link: string;
  10. imgUrl: string;
  11. };
  12. const ResourceCard = ({title, link, imgUrl}: Props) => (
  13. <ResourceCardWrapper
  14. onClick={() => analytics('orgdash.resource_clicked', {link, title})}
  15. >
  16. <StyledLink href={link}>
  17. <StyledImg src={imgUrl} alt={title} />
  18. <StyledTitle>{title}</StyledTitle>
  19. </StyledLink>
  20. </ResourceCardWrapper>
  21. );
  22. export default ResourceCard;
  23. const ResourceCardWrapper = styled(Panel)`
  24. display: flex;
  25. flex: 1;
  26. align-items: center;
  27. padding: ${space(3)};
  28. margin-bottom: 0;
  29. `;
  30. const StyledLink = styled(ExternalLink)`
  31. flex: 1;
  32. `;
  33. const StyledImg = styled('img')`
  34. display: block;
  35. margin: 0 auto ${space(3)} auto;
  36. height: 160px;
  37. `;
  38. const StyledTitle = styled('div')`
  39. color: ${p => p.theme.textColor};
  40. font-size: ${p => p.theme.fontSizeLarge};
  41. text-align: center;
  42. font-weight: bold;
  43. `;