pageCorners.tsx 4.0 KB

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