welcome.tsx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import {Component} from 'react';
  2. import styled from '@emotion/styled';
  3. import {motion, MotionProps} from 'framer-motion';
  4. import {preloadIcons} from 'platformicons';
  5. import Button from 'sentry/components/button';
  6. import {t, tct} from 'sentry/locale';
  7. import space from 'sentry/styles/space';
  8. import trackAdvancedAnalyticsEvent from 'sentry/utils/analytics/trackAdvancedAnalyticsEvent';
  9. import testableTransition from 'sentry/utils/testableTransition';
  10. import FallingError from './components/fallingError';
  11. import WelcomeBackground from './components/welcomeBackground';
  12. import {StepProps} from './types';
  13. type Props = StepProps;
  14. const easterEggText = [
  15. t('Be careful. She’s barely hanging on as it is.'),
  16. t("You know this error's not real, right?"),
  17. t("It's that big button, right up there."),
  18. t('You could do this all day. But you really shouldn’t.'),
  19. tct("Ok, really, that's enough. Click [ready:I'm Ready].", {ready: <em />}),
  20. tct("Next time you do that, [bold:we're starting].", {bold: <strong />}),
  21. t("We weren't kidding, let's get going."),
  22. ];
  23. const fadeAway: MotionProps = {
  24. variants: {
  25. initial: {opacity: 0},
  26. animate: {opacity: 1, filter: 'blur(0px)'},
  27. exit: {opacity: 0, filter: 'blur(1px)'},
  28. },
  29. transition: testableTransition({duration: 0.8}),
  30. };
  31. class OnboardingWelcome extends Component<Props> {
  32. componentDidMount() {
  33. // Next step will render the platform picker (using both large and small
  34. // icons). Keep things smooth by prefetching them. Preload a bit late to
  35. // avoid jank on welcome animations.
  36. setTimeout(preloadIcons, 1500);
  37. trackAdvancedAnalyticsEvent('growth.onboarding_start_onboarding', {
  38. organization: this.props.organization ?? null,
  39. });
  40. }
  41. render() {
  42. const {onComplete, active} = this.props;
  43. return (
  44. <FallingError
  45. onFall={fallCount => fallCount >= easterEggText.length && onComplete({})}
  46. >
  47. {({fallingError, fallCount, triggerFall}) => (
  48. <Wrapper>
  49. <WelcomeBackground />
  50. <motion.h1 {...fadeAway}>{t('Welcome to Sentry')}</motion.h1>
  51. <motion.p {...fadeAway}>
  52. {t(
  53. 'Find the errors and performance slowdowns that keep you up at night. In two steps.'
  54. )}
  55. </motion.p>
  56. <CTAContainer {...fadeAway}>
  57. <Button
  58. data-test-id="welcome-next"
  59. disabled={!active}
  60. priority="primary"
  61. onClick={() => {
  62. triggerFall();
  63. onComplete({});
  64. }}
  65. >
  66. {t("I'm Ready")}
  67. </Button>
  68. <PositionedFallingError>{fallingError}</PositionedFallingError>
  69. </CTAContainer>
  70. <SecondaryAction {...fadeAway}>
  71. {fallCount > 0 ? easterEggText[fallCount - 1] : <br />}
  72. </SecondaryAction>
  73. </Wrapper>
  74. )}
  75. </FallingError>
  76. );
  77. }
  78. }
  79. const CTAContainer = styled(motion.div)`
  80. margin-bottom: ${space(2)};
  81. position: relative;
  82. button {
  83. position: relative;
  84. z-index: 2;
  85. }
  86. `;
  87. const PositionedFallingError = styled('span')`
  88. display: block;
  89. position: absolute;
  90. top: 30px;
  91. right: -5px;
  92. z-index: 0;
  93. `;
  94. const SecondaryAction = styled(motion.small)`
  95. color: ${p => p.theme.subText};
  96. margin-top: 100px;
  97. `;
  98. const Wrapper = styled(motion.div)`
  99. max-width: 400px;
  100. display: flex;
  101. flex-direction: column;
  102. align-items: center;
  103. text-align: center;
  104. padding-top: 100px;
  105. h1 {
  106. font-size: 42px;
  107. }
  108. `;
  109. Wrapper.defaultProps = {
  110. variants: {exit: {x: 0}},
  111. transition: testableTransition({
  112. staggerChildren: 0.2,
  113. }),
  114. };
  115. export default OnboardingWelcome;