sidebarPanelItem.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import * as React from 'react';
  2. import styled from '@emotion/styled';
  3. import space from 'sentry/styles/space';
  4. import {t} from '../../locale';
  5. import ExternalLink from '../links/externalLink';
  6. type Props = {
  7. children?: React.ReactNode;
  8. cta?: string;
  9. hasSeen?: boolean;
  10. image?: string;
  11. link?: string;
  12. message?: React.ReactNode;
  13. title?: string;
  14. };
  15. const SidebarPanelItem = ({
  16. hasSeen,
  17. title,
  18. image,
  19. message,
  20. link,
  21. cta,
  22. children,
  23. }: Props) => (
  24. <SidebarPanelItemRoot>
  25. {title && <Title hasSeen={hasSeen}>{title}</Title>}
  26. {image && (
  27. <ImageBox>
  28. <img src={image} />
  29. </ImageBox>
  30. )}
  31. {message && <Message>{message}</Message>}
  32. {children}
  33. {link && (
  34. <Text>
  35. <ExternalLink href={link}>{cta || t('Read More')}</ExternalLink>
  36. </Text>
  37. )}
  38. </SidebarPanelItemRoot>
  39. );
  40. export default SidebarPanelItem;
  41. const SidebarPanelItemRoot = styled('div')`
  42. line-height: 1.5;
  43. border-top: 1px solid ${p => p.theme.innerBorder};
  44. background: ${p => p.theme.background};
  45. font-size: ${p => p.theme.fontSizeMedium};
  46. padding: ${space(3)};
  47. `;
  48. const ImageBox = styled('div')`
  49. border: 1px solid #e1e4e5;
  50. padding: ${space(2)};
  51. border-radius: 2px;
  52. `;
  53. const Title = styled('div')<Pick<Props, 'hasSeen'>>`
  54. font-size: ${p => p.theme.fontSizeLarge};
  55. margin-bottom: ${space(1)};
  56. color: ${p => p.theme.textColor};
  57. ${p => !p.hasSeen && 'font-weight: 600;'};
  58. .culprit {
  59. font-weight: normal;
  60. }
  61. `;
  62. const Text = styled('div')`
  63. margin-bottom: ${space(0.5)};
  64. &:last-child {
  65. margin-bottom: 0;
  66. }
  67. `;
  68. const Message = styled(Text)`
  69. color: ${p => p.theme.subText};
  70. `;