card.tsx 810 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import {css} from '@emotion/react';
  2. import styled from '@emotion/styled';
  3. import Panel from 'sentry/components/panels/panel';
  4. type Props = {
  5. /**
  6. * Adds hover and focus states to the card
  7. */
  8. interactive?: boolean;
  9. };
  10. const hoverStyle = css`
  11. &:focus,
  12. &:hover {
  13. box-shadow: 0px 0px 0px 6px rgba(209, 202, 216, 0.2);
  14. outline: none;
  15. }
  16. &:active {
  17. box-shadow: 0px 0px 0px 6px rgba(209, 202, 216, 0.5);
  18. }
  19. /* This is to ensure the graph is visually clickable */
  20. * {
  21. cursor: pointer;
  22. }
  23. `;
  24. const Card = styled(Panel)<Props>`
  25. display: flex;
  26. align-items: stretch;
  27. flex-direction: column;
  28. transition: box-shadow 0.2s ease;
  29. text-align: left;
  30. padding: 0;
  31. ${p => p.interactive && 'cursor: pointer'};
  32. ${p => p.interactive && hoverStyle};
  33. `;
  34. export default Card;