styled.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import styled, { css } from 'styled-components';
  2. const position: {[index: string]: any} = {
  3. left: css`
  4. top: 0;
  5. bottom: 0;
  6. left: 0;
  7. right: auto;
  8. `,
  9. top: css`
  10. top: 0;
  11. bottom: auto;
  12. left: 0;
  13. right: 0;
  14. `,
  15. right: css`
  16. top: 0;
  17. bottom: 0;
  18. left: auto;
  19. right: 0;
  20. `,
  21. bottom: css`
  22. top: auto;
  23. bottom: 0;
  24. left: 0;
  25. right: 0;
  26. `,
  27. };
  28. const close: {[index: string]: any} = {
  29. left: css`
  30. transform: translate(-267px, 0);
  31. `,
  32. top: css`
  33. transform: translate(0, -267px);
  34. `,
  35. right: css`
  36. transform: translate(267px, 0);
  37. `,
  38. bottom: css`
  39. transform: translate(0, 267px);
  40. `,
  41. };
  42. export const Slide = styled('div')<{open: boolean; anchor: string; zIndex: number}>`
  43. position: fixed;
  44. transition: transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms;
  45. z-index: ${props => props.zIndex};
  46. background-color: white;
  47. ${props => position[props.anchor]}
  48. ${props => (props.open ? css`
  49. transform: translate(0, 0);
  50. ` : close[props.anchor]
  51. )}
  52. `;
  53. export const Container = styled.div`
  54. min-width: 267px;
  55. min-height: 267px;
  56. height: 100%;
  57. width: 100%;
  58. box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.24);
  59. `;