card.tsx 912 B

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