templateCard.tsx 1.7 KB

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