styled.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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')<{
  43. open: boolean;
  44. anchor: string;
  45. zIndex: number;
  46. }>`
  47. position: fixed;
  48. transition: transform 225ms cubic-bezier(0, 0, 0.2, 1) 0ms;
  49. z-index: ${props => props.zIndex};
  50. background-color: white;
  51. ${props => position[props.anchor]}
  52. ${props =>
  53. props.open
  54. ? css`
  55. transform: translate(0, 0);
  56. `
  57. : close[props.anchor]}
  58. `;
  59. export const Wrapper = styled.div`
  60. min-width: 267px;
  61. min-height: 267px;
  62. height: 100%;
  63. width: 100%;
  64. box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.24);
  65. -ms-overflow-style: none;
  66. overflow: auto;
  67. `;