templateCard.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import styled from '@emotion/styled';
  2. import {Button} from 'sentry/components/button';
  3. import Card from 'sentry/components/card';
  4. import {IconAdd, IconGeneric} from 'sentry/icons';
  5. import {t} from 'sentry/locale';
  6. import space from 'sentry/styles/space';
  7. type Props = {
  8. description: string;
  9. onAdd: () => void;
  10. onPreview: () => void;
  11. title: string;
  12. };
  13. function TemplateCard({title, description, onPreview, onAdd}: Props) {
  14. return (
  15. <StyledCard>
  16. <Header>
  17. <IconGeneric legacySize="48px" />
  18. <Title>
  19. {title}
  20. <Detail>{description}</Detail>
  21. </Title>
  22. </Header>
  23. <ButtonContainer>
  24. <StyledButton onClick={onAdd} icon={<IconAdd isCircled />}>
  25. {t('Add Dashboard')}
  26. </StyledButton>
  27. <StyledButton priority="primary" onClick={onPreview}>
  28. {t('Preview')}
  29. </StyledButton>
  30. </ButtonContainer>
  31. </StyledCard>
  32. );
  33. }
  34. const StyledCard = styled(Card)`
  35. gap: ${space(1)};
  36. padding: ${space(2)};
  37. `;
  38. const Header = styled('div')`
  39. display: flex;
  40. gap: ${space(2)};
  41. `;
  42. const Title = styled('div')`
  43. text-overflow: ellipsis;
  44. white-space: nowrap;
  45. overflow: hidden;
  46. `;
  47. const Detail = styled(Title)`
  48. font-family: ${p => p.theme.text.familyMono};
  49. font-size: ${p => p.theme.fontSizeSmall};
  50. color: ${p => p.theme.gray300};
  51. `;
  52. const ButtonContainer = styled('div')`
  53. display: flex;
  54. flex-wrap: wrap;
  55. gap: ${space(1)};
  56. `;
  57. const StyledButton = styled(Button)`
  58. flex-grow: 1;
  59. `;
  60. export default TemplateCard;