card.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import styled from '@emotion/styled';
  2. import {space} from 'sentry/styles/space';
  3. import type {WidgetTemplate} from 'sentry/views/dashboards/widgetLibrary/data';
  4. import {getWidgetIcon} from 'sentry/views/dashboards/widgetLibrary/widgetCard';
  5. interface CardProps {
  6. iconColor: string;
  7. widget: WidgetTemplate;
  8. }
  9. export function Card({widget, iconColor}: CardProps) {
  10. const {title, description, displayType} = widget;
  11. const Icon = getWidgetIcon(displayType);
  12. return (
  13. <Container>
  14. <IconWrapper backgroundColor={iconColor}>
  15. <Icon color="white" />
  16. </IconWrapper>
  17. <Information>
  18. <Heading>{title}</Heading>
  19. <SubHeading>{description}</SubHeading>
  20. </Information>
  21. </Container>
  22. );
  23. }
  24. const Container = styled('div')`
  25. display: flex;
  26. flex-direction: row;
  27. gap: ${space(1)};
  28. `;
  29. const Information = styled('div')`
  30. display: flex;
  31. flex-direction: column;
  32. `;
  33. const Heading = styled('div')`
  34. font-size: ${p => p.theme.fontSizeLarge};
  35. font-weight: ${p => p.theme.fontWeightNormal};
  36. margin-bottom: 0;
  37. color: ${p => p.theme.gray500};
  38. `;
  39. const SubHeading = styled('small')`
  40. color: ${p => p.theme.gray300};
  41. `;
  42. const IconWrapper = styled('div')<{backgroundColor: string}>`
  43. display: flex;
  44. justify-content: center;
  45. align-items: center;
  46. padding: ${space(1)};
  47. min-width: 40px;
  48. height: 40px;
  49. border-radius: ${p => p.theme.borderRadius};
  50. background: ${p => p.backgroundColor};
  51. `;