demoHeader.tsx 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. import styled from '@emotion/styled';
  2. import Button from 'sentry/components/button';
  3. import ExternalLink from 'sentry/components/links/externalLink';
  4. import LogoSentry from 'sentry/components/logoSentry';
  5. import {t} from 'sentry/locale';
  6. import PreferencesStore from 'sentry/stores/preferencesStore';
  7. import {useLegacyStore} from 'sentry/stores/useLegacyStore';
  8. import space from 'sentry/styles/space';
  9. import trackAdvancedAnalyticsEvent from 'sentry/utils/analytics/trackAdvancedAnalyticsEvent';
  10. import {
  11. extraQueryParameter,
  12. extraQueryParameterWithEmail,
  13. urlAttachQueryParams,
  14. } from 'sentry/utils/demoMode';
  15. export default function DemoHeader() {
  16. const sandboxData = window.SandboxData;
  17. // if the user came from a SaaS org, we should send them back to upgrade when they leave the sandbox
  18. const extraSearchParams = extraQueryParameter();
  19. const collapsed = !!useLegacyStore(PreferencesStore).collapsed;
  20. return (
  21. <Wrapper collapsed={collapsed}>
  22. <StyledLogoSentry />
  23. <StyledExternalLink
  24. onClick={() =>
  25. trackAdvancedAnalyticsEvent('growth.demo_click_docs', {organization: null})
  26. }
  27. href={urlAttachQueryParams('https://docs.sentry.io/', extraSearchParams)}
  28. openInNewTab
  29. >
  30. {t('Documentation')}
  31. </StyledExternalLink>
  32. <RequestDemoBtn
  33. priority="form"
  34. onClick={() =>
  35. trackAdvancedAnalyticsEvent('growth.demo_click_request_demo', {
  36. organization: null,
  37. })
  38. }
  39. href={urlAttachQueryParams('https://sentry.io/_/demo/', extraSearchParams)}
  40. target="_blank"
  41. rel="noreferrer noopener"
  42. >
  43. {t('Request a Demo')}
  44. </RequestDemoBtn>
  45. <GetStarted
  46. onClick={() => {
  47. const url =
  48. sandboxData?.cta?.url ||
  49. urlAttachQueryParams(
  50. 'https://sentry.io/signup/',
  51. extraQueryParameterWithEmail()
  52. );
  53. // Using window.open instead of href={} because we need to read `email`
  54. // from localStorage when the user clicks the button.
  55. window.open(url, '_blank');
  56. trackAdvancedAnalyticsEvent('growth.demo_click_get_started', {
  57. cta: sandboxData?.cta?.id,
  58. organization: null,
  59. });
  60. }}
  61. target="_blank"
  62. rel="noreferrer noopener"
  63. >
  64. <GetStartedTextLong>
  65. {sandboxData?.cta?.title || t('Sign Up for Free')}
  66. </GetStartedTextLong>
  67. <GetStartedTextShort>
  68. {sandboxData?.cta?.shortTitle || t('Sign Up')}
  69. </GetStartedTextShort>
  70. </GetStarted>
  71. </Wrapper>
  72. );
  73. }
  74. // Note many of the colors don't come from the theme as they come from the marketing site
  75. const Wrapper = styled('div')<{collapsed: boolean}>`
  76. padding-right: ${space(3)};
  77. background-color: ${p => p.theme.white};
  78. height: ${p => p.theme.demo.headerSize};
  79. display: flex;
  80. justify-content: space-between;
  81. text-transform: uppercase;
  82. align-items: center;
  83. white-space: nowrap;
  84. gap: ${space(4)};
  85. margin-left: calc(
  86. -1 * ${p => (p.collapsed ? p.theme.sidebar.collapsedWidth : p.theme.sidebar.expandedWidth)}
  87. );
  88. position: fixed;
  89. width: 100%;
  90. border-bottom: 1px solid ${p => p.theme.border};
  91. z-index: ${p => p.theme.zIndex.settingsSidebarNav};
  92. @media (max-width: ${p => p.theme.breakpoints.medium}) {
  93. height: ${p => p.theme.sidebar.mobileHeight};
  94. margin-left: 0;
  95. }
  96. `;
  97. const StyledLogoSentry = styled(LogoSentry)`
  98. margin-top: auto;
  99. margin-bottom: auto;
  100. margin-left: 20px;
  101. margin-right: auto;
  102. width: 130px;
  103. height: 30px;
  104. color: ${p => p.theme.textColor};
  105. `;
  106. const BaseButton = styled(Button)`
  107. border-radius: 2rem;
  108. text-transform: uppercase;
  109. `;
  110. const RequestDemoBtn = styled(BaseButton)`
  111. @media (max-width: ${p => p.theme.breakpoints.small}) {
  112. display: none;
  113. }
  114. `;
  115. const GetStartedTextShort = styled('span')`
  116. display: none;
  117. `;
  118. const GetStartedTextLong = styled('span')``;
  119. // Note many of the colors don't come from the theme as they come from the marketing site
  120. const GetStarted = styled(BaseButton)`
  121. border-color: transparent;
  122. box-shadow: 0 2px 0 rgb(54 45 89 / 10%);
  123. background-color: #e1567c;
  124. color: #fff;
  125. .short-text {
  126. display: none;
  127. }
  128. @media (max-width: 650px) {
  129. ${GetStartedTextLong} {
  130. display: none;
  131. }
  132. ${GetStartedTextShort} {
  133. display: inline;
  134. }
  135. }
  136. `;
  137. const StyledExternalLink = styled(ExternalLink)`
  138. color: #584774;
  139. @media (max-width: 500px) {
  140. display: none;
  141. }
  142. `;