pageCorners.tsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. import {HTMLAttributes} from 'react';
  2. import styled from '@emotion/styled';
  3. import {AnimationControls, motion} from 'framer-motion';
  4. import testableTransition from 'sentry/utils/testableTransition';
  5. type Props = {
  6. animateVariant: AnimationControls;
  7. } & HTMLAttributes<HTMLDivElement>;
  8. const PageCorners = ({animateVariant, ...rest}: Props) => (
  9. <Container {...rest}>
  10. <TopRight
  11. key="tr"
  12. width="874"
  13. height="203"
  14. viewBox="0 0 874 203"
  15. fill="none"
  16. xmlns="http://www.w3.org/2000/svg"
  17. animate={animateVariant}
  18. >
  19. <path
  20. d="M36.5 0H874v203l-288.7-10-7-114-180.2-4.8-3.6-35.2-351.1 2.5L36.5 0z"
  21. fill="currentColor"
  22. />
  23. <path
  24. d="M535.5 111.5v-22l31.8 1 .7 21.5-32.5-.5zM4 43.5L0 21.6 28.5 18l4.2 24.7-28.7.8z"
  25. fill="currentColor"
  26. />
  27. </TopRight>
  28. <BottomLeft
  29. key="bl"
  30. width="494"
  31. height="141"
  32. viewBox="0 0 494 141"
  33. fill="none"
  34. xmlns="http://www.w3.org/2000/svg"
  35. animate={animateVariant}
  36. >
  37. <path d="M494 141H-1V7l140-7v19h33l5 82 308 4 9 36z" fill="currentColor" />
  38. <path d="M219 88h-30l-1-19 31 3v16z" fill="currentColor" />
  39. </BottomLeft>
  40. <TopLeft
  41. key="tl"
  42. width="414"
  43. height="118"
  44. fill="none"
  45. xmlns="http://www.w3.org/2000/svg"
  46. animate={animateVariant}
  47. >
  48. <path
  49. fillRule="evenodd"
  50. clipRule="evenodd"
  51. d="M414 0H0v102h144l5-69 257-3 8-30zM0 112v-10h117v16L0 112z"
  52. fill="currentColor"
  53. />
  54. <path d="M184 44h-25l-1 16 26-2V44z" fill="currentColor" />
  55. </TopLeft>
  56. <BottomRight
  57. key="br"
  58. width="650"
  59. height="151"
  60. fill="none"
  61. xmlns="http://www.w3.org/2000/svg"
  62. animate={animateVariant}
  63. >
  64. <path
  65. fillRule="evenodd"
  66. clipRule="evenodd"
  67. d="M27 151h623V0L435 7l-5 85-134 4-3 26-261-2-5 31z"
  68. fill="currentColor"
  69. />
  70. <path d="M398 68v16h24l1-16h-25zM3 119l-3 16 21 3 3-19H3z" fill="currentColor" />
  71. </BottomRight>
  72. </Container>
  73. );
  74. export default PageCorners;
  75. const transition = testableTransition({
  76. type: 'spring',
  77. duration: 0.8,
  78. });
  79. const TopLeft = styled(motion.svg)`
  80. position: absolute;
  81. top: 0;
  82. left: 0;
  83. `;
  84. TopLeft.defaultProps = {
  85. initial: {x: '-40px', opacity: 0, originX: 0, originY: 0, scale: 'var(--corner-scale)'},
  86. variants: {
  87. none: {x: '-40px', opacity: 0},
  88. 'top-right': {x: '-40px', opacity: 0},
  89. 'top-left': {x: 0, opacity: 1},
  90. },
  91. transition,
  92. };
  93. const TopRight = styled(motion.svg)`
  94. position: absolute;
  95. top: 0;
  96. right: 0;
  97. `;
  98. TopRight.defaultProps = {
  99. initial: {
  100. x: '40px',
  101. opacity: 0,
  102. originX: '100%',
  103. originY: 0,
  104. scale: 'var(--corner-scale)',
  105. },
  106. variants: {
  107. none: {x: '40px', opacity: 0},
  108. 'top-left': {x: '40px', opacity: 0},
  109. 'top-right': {x: 0, opacity: 1},
  110. },
  111. transition,
  112. };
  113. const BottomLeft = styled(motion.svg)`
  114. position: absolute;
  115. bottom: 0;
  116. left: 0;
  117. `;
  118. BottomLeft.defaultProps = {
  119. initial: {
  120. x: '-40px',
  121. opacity: 0,
  122. originX: 0,
  123. originY: '100%',
  124. scale: 'var(--corner-scale)',
  125. },
  126. variants: {
  127. none: {x: '-40px', opacity: 0},
  128. 'top-left': {x: '-40px', opacity: 0},
  129. 'top-right': {x: 0, opacity: 1},
  130. },
  131. transition,
  132. };
  133. const BottomRight = styled(motion.svg)`
  134. position: absolute;
  135. bottom: 0;
  136. right: 0;
  137. `;
  138. BottomRight.defaultProps = {
  139. initial: {
  140. x: '40px',
  141. opacity: 0,
  142. originX: '100%',
  143. originY: '100%',
  144. scale: 'var(--corner-scale)',
  145. },
  146. variants: {
  147. none: {x: '40px', opacity: 0},
  148. 'top-right': {x: '40px', opacity: 0},
  149. 'top-left': {x: 0, opacity: 1},
  150. },
  151. transition,
  152. };
  153. const Container = styled('div')`
  154. pointer-events: none;
  155. position: absolute;
  156. top: 0;
  157. left: 0;
  158. right: 0;
  159. bottom: 0;
  160. color: ${p => p.theme.purple200};
  161. opacity: 0.4;
  162. `;